Completed
Push — master ( 6980ff...8cab2f )
by Yannick
32:47
created
scripts/daemon-spotter.php 3 patches
Indentation   +1218 added lines, -1218 removed lines patch added patch discarded remove patch
@@ -15,65 +15,65 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) {
18
-    require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19 19
 }
20 20
 if (isset($globalMarine) && $globalMarine) {
21
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25 25
 if (!isset($globalDebug)) $globalDebug = FALSE;
26 26
 
27 27
 if ($globalInstalled === FALSE) {
28
-    echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
-    sleep(5);
30
-    die();
28
+	echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
+	sleep(5);
30
+	die();
31 31
 }
32 32
 
33 33
 
34 34
 // Check if schema is at latest version
35 35
 $Connection = new Connection();
36 36
 if ($Connection->connectionExists() === false) {
37
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
-    exit();
37
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
+	exit();
39 39
 }
40 40
 if ($Connection->latest() === false) {
41
-    echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
-    exit();
41
+	echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
+	exit();
43 43
 }
44 44
 if (PHP_SAPI != 'cli') {
45
-    echo "This script MUST be called from console, not a web browser.";
45
+	echo "This script MUST be called from console, not a web browser.";
46 46
 //    exit();
47 47
 }
48 48
 
49 49
 // This is to be compatible with old version of settings.php
50 50
 if (!isset($globalSources)) {
51
-    if (isset($globalSBS1Hosts)) {
52
-        //$hosts = $globalSBS1Hosts;
53
-        foreach ($globalSBS1Hosts as $host) {
54
-	    $globalSources[] = array('host' => $host);
55
-    	}
56
-    } else {
57
-        if (!isset($globalSBS1Host)) {
58
-	    echo '$globalSources MUST be defined !';
59
-	    die;
51
+	if (isset($globalSBS1Hosts)) {
52
+		//$hosts = $globalSBS1Hosts;
53
+		foreach ($globalSBS1Hosts as $host) {
54
+		$globalSources[] = array('host' => $host);
55
+		}
56
+	} else {
57
+		if (!isset($globalSBS1Host)) {
58
+		echo '$globalSources MUST be defined !';
59
+		die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62 62
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
63
-    }
63
+	}
64 64
 }
65 65
 
66 66
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70
-    $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
70
+	$globalSources = array();
71
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
+	else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74
-    $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
74
+	$globalSources = array();
75
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
+	else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
79 79
 	$globalServerAPRS = TRUE;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 if (isset($options['idsource'])) $id_source = $options['idsource'];
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
115
+	if ($globalDebug) echo "Using Server Mode\n";
116
+	$SI=new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
126
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
126
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 128
 }
129 129
 
130 130
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
131 131
 if (isset($globalMarine) && $globalMarine) {
132
-    $AIS = new AIS();
133
-    $MI = new MarineImport($Connection->db);
132
+	$AIS = new AIS();
133
+	$MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136 136
 $SBS=new SBS();
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
147
-        global $sockets;
148
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
-        die("Bye!\n");
150
-    });
151
-    pcntl_signal_dispatch();
146
+	pcntl_signal(SIGINT,  function() {
147
+		global $sockets;
148
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
+		die("Bye!\n");
150
+	});
151
+	pcntl_signal_dispatch();
152 152
 }
153 153
 
154 154
 // let's try and connect
@@ -158,47 +158,47 @@  discard block
 block discarded – undo
158 158
 $reset = 0;
159 159
 
160 160
 function connect_all($hosts) {
161
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
-    $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
165
-    foreach ($hosts as $id => $value) {
161
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
+	$reset++;
164
+	if ($globalDebug) echo 'Connect to all...'."\n";
165
+	foreach ($hosts as $id => $value) {
166 166
 	$host = $value['host'];
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170 170
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
172
-        	//$formats[$id] = 'deltadbtxt';
173
-        	$globalSources[$id]['format'] = 'deltadbtxt';
174
-        	//$last_exec['deltadbtxt'] = 0;
175
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
177
-        	//$formats[$id] = 'vatsimtxt';
178
-        	$globalSources[$id]['format'] = 'vatsimtxt';
179
-        	//$last_exec['vatsimtxt'] = 0;
180
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
182
-        	//$formats[$id] = 'aircraftlistjson';
183
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
187
-        	//$formats[$id] = 'aircraftjson';
188
-        	$globalSources[$id]['format'] = 'aircraftjson';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
192
-        	//$formats[$id] = 'planefinderclient';
193
-        	$globalSources[$id]['format'] = 'planefinderclient';
194
-        	//$last_exec['aircraftlistjson'] = 0;
195
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
197
-        	//$formats[$id] = 'aircraftlistjson';
198
-        	$globalSources[$id]['format'] = 'opensky';
199
-        	//$last_exec['aircraftlistjson'] = 0;
200
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
201
-    	    /*
171
+			if (preg_match('/deltadb.txt$/i',$host)) {
172
+			//$formats[$id] = 'deltadbtxt';
173
+			$globalSources[$id]['format'] = 'deltadbtxt';
174
+			//$last_exec['deltadbtxt'] = 0;
175
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
177
+			//$formats[$id] = 'vatsimtxt';
178
+			$globalSources[$id]['format'] = 'vatsimtxt';
179
+			//$last_exec['vatsimtxt'] = 0;
180
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
182
+			//$formats[$id] = 'aircraftlistjson';
183
+			$globalSources[$id]['format'] = 'aircraftlistjson';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
+			} else if (preg_match('/aircraft.json$/i',$host)) {
187
+			//$formats[$id] = 'aircraftjson';
188
+			$globalSources[$id]['format'] = 'aircraftjson';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
+			} else if (preg_match('/aircraft$/i',$host)) {
192
+			//$formats[$id] = 'planefinderclient';
193
+			$globalSources[$id]['format'] = 'planefinderclient';
194
+			//$last_exec['aircraftlistjson'] = 0;
195
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
+			} else if (preg_match('/opensky/i',$host)) {
197
+			//$formats[$id] = 'aircraftlistjson';
198
+			$globalSources[$id]['format'] = 'opensky';
199
+			//$last_exec['aircraftlistjson'] = 0;
200
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
201
+			/*
202 202
     	    // Disabled for now, site change source format
203 203
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
204 204
         	//$formats[$id] = 'radarvirtueljson';
@@ -210,131 +210,131 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
214
-        	//$formats[$id] = 'planeupdatefaa';
215
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
216
-        	//$last_exec['planeupdatefaa'] = 0;
217
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
218
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220
-        	    exit(0);
221
-        	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'phpvmacars';
225
-        	//$last_exec['phpvmacars'] = 0;
226
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228
-        	//$formats[$id] = 'phpvmacars';
229
-        	$globalSources[$id]['format'] = 'vaos';
230
-        	//$last_exec['phpvmacars'] = 0;
231
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
233
-        	//$formats[$id] = 'phpvmacars';
234
-        	$globalSources[$id]['format'] = 'vam';
235
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
237
-        	//$formats[$id] = 'whazzup';
238
-        	$globalSources[$id]['format'] = 'whazzup';
239
-        	//$last_exec['whazzup'] = 0;
240
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
242
-        	$globalSources[$id]['format'] = 'blitzortung';
243
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
245
-        	$globalSources[$id]['format'] = 'airwhere';
246
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
248
-        	//$formats[$id] = 'pirepsjson';
249
-        	$globalSources[$id]['format'] = 'pirepsjson';
250
-        	//$last_exec['pirepsjson'] = 0;
251
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253
-        	//$formats[$id] = 'fr24json';
254
-        	$globalSources[$id]['format'] = 'fr24json';
255
-        	//$last_exec['fr24json'] = 0;
256
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
257
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259
-        	    exit(0);
260
-        	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
262
-        	//$formats[$id] = 'fr24json';
263
-        	$globalSources[$id]['format'] = 'myshiptracking';
264
-        	//$last_exec['fr24json'] = 0;
265
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
266
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268
-        	    exit(0);
269
-        	}
270
-            //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272
-        	//$formats[$id] = 'tsv';
273
-        	$globalSources[$id]['format'] = 'tsv';
274
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275
-            }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
279
-    		    if ($idf !== false) {
280
-    			$httpfeeds[$id] = $idf;
281
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
-    		elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
286
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287
-	    $hostport = explode(':',$host);
288
-	    if (isset($hostport[1])) {
213
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
214
+			//$formats[$id] = 'planeupdatefaa';
215
+			$globalSources[$id]['format'] = 'planeupdatefaa';
216
+			//$last_exec['planeupdatefaa'] = 0;
217
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
218
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220
+				exit(0);
221
+			}
222
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'phpvmacars';
225
+			//$last_exec['phpvmacars'] = 0;
226
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228
+			//$formats[$id] = 'phpvmacars';
229
+			$globalSources[$id]['format'] = 'vaos';
230
+			//$last_exec['phpvmacars'] = 0;
231
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
233
+			//$formats[$id] = 'phpvmacars';
234
+			$globalSources[$id]['format'] = 'vam';
235
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
+			} else if (preg_match('/whazzup/i',$host)) {
237
+			//$formats[$id] = 'whazzup';
238
+			$globalSources[$id]['format'] = 'whazzup';
239
+			//$last_exec['whazzup'] = 0;
240
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
+			} else if (preg_match('/blitzortung/i',$host)) {
242
+			$globalSources[$id]['format'] = 'blitzortung';
243
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
+			} else if (preg_match('/airwhere/i',$host)) {
245
+			$globalSources[$id]['format'] = 'airwhere';
246
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
+			} else if (preg_match('/recentpireps/i',$host)) {
248
+			//$formats[$id] = 'pirepsjson';
249
+			$globalSources[$id]['format'] = 'pirepsjson';
250
+			//$last_exec['pirepsjson'] = 0;
251
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253
+			//$formats[$id] = 'fr24json';
254
+			$globalSources[$id]['format'] = 'fr24json';
255
+			//$last_exec['fr24json'] = 0;
256
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
257
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259
+				exit(0);
260
+			}
261
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
262
+			//$formats[$id] = 'fr24json';
263
+			$globalSources[$id]['format'] = 'myshiptracking';
264
+			//$last_exec['fr24json'] = 0;
265
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
266
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268
+				exit(0);
269
+			}
270
+			//} else if (preg_match('/10001/',$host)) {
271
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272
+			//$formats[$id] = 'tsv';
273
+			$globalSources[$id]['format'] = 'tsv';
274
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275
+			}
276
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277
+			if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
279
+				if ($idf !== false) {
280
+				$httpfeeds[$id] = $idf;
281
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
+			} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
+			elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285
+			elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
286
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287
+		$hostport = explode(':',$host);
288
+		if (isset($hostport[1])) {
289 289
 		$port = $hostport[1];
290 290
 		$hostn = $hostport[0];
291
-	    } else {
291
+		} else {
292 292
 		$port = $globalSources[$id]['port'];
293 293
 		$hostn = $globalSources[$id]['host'];
294
-	    }
295
-	    $Common = new Common();
296
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
297
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
298
-    	    } else {
299
-    		$udp = true;
300
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
301
-	    }
302
-	    if ($s) {
303
-    	        $sockets[$id] = $s;
304
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
305
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
294
+		}
295
+		$Common = new Common();
296
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
297
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
298
+			} else {
299
+			$udp = true;
300
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
301
+		}
302
+		if ($s) {
303
+				$sockets[$id] = $s;
304
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
305
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
306 306
 			//$formats[$id] = 'aprs';
307 307
 			$globalSources[$id]['format'] = 'aprs';
308 308
 			//$aprs_connect = 0;
309 309
 			//$use_aprs = true;
310
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
311 311
 			$globalSources[$id]['format'] = 'vrstcp';
312
-    		    } elseif ($port == '10001') {
313
-        		//$formats[$id] = 'tsv';
314
-        		$globalSources[$id]['format'] = 'tsv';
315
-		    } elseif ($port == '30002') {
316
-        		//$formats[$id] = 'raw';
317
-        		$globalSources[$id]['format'] = 'raw';
318
-		    } elseif ($port == '5001') {
319
-        		//$formats[$id] = 'raw';
320
-        		$globalSources[$id]['format'] = 'flightgearmp';
321
-		    } elseif ($port == '30005') {
312
+				} elseif ($port == '10001') {
313
+				//$formats[$id] = 'tsv';
314
+				$globalSources[$id]['format'] = 'tsv';
315
+			} elseif ($port == '30002') {
316
+				//$formats[$id] = 'raw';
317
+				$globalSources[$id]['format'] = 'raw';
318
+			} elseif ($port == '5001') {
319
+				//$formats[$id] = 'raw';
320
+				$globalSources[$id]['format'] = 'flightgearmp';
321
+			} elseif ($port == '30005') {
322 322
 			// Not yet supported
323
-        		//$formats[$id] = 'beast';
324
-        		$globalSources[$id]['format'] = 'beast';
325
-		    //} else $formats[$id] = 'sbs';
326
-		    } else $globalSources[$id]['format'] = 'sbs';
327
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
323
+				//$formats[$id] = 'beast';
324
+				$globalSources[$id]['format'] = 'beast';
325
+			//} else $formats[$id] = 'sbs';
326
+			} else $globalSources[$id]['format'] = 'sbs';
327
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
328 328
 		}
329 329
 		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330 330
 		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
331
-            } else {
331
+			} else {
332 332
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
333 333
 		sleep(10);
334 334
 		connect_all($hosts);
335
-    	    }
336
-        }
337
-    }
335
+			}
336
+		}
337
+	}
338 338
 }
339 339
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
340 340
 
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 //connect_all($globalSources);
358 358
 
359 359
 if (isset($globalProxy) && $globalProxy) {
360
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
360
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
361 361
 } else {
362
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
362
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
363 363
 }
364 364
 
365 365
 // APRS Configuration
@@ -368,21 +368,21 @@  discard block
 block discarded – undo
368 368
 	die;
369 369
 }
370 370
 foreach ($globalSources as $key => $source) {
371
-    if (!isset($source['format'])) {
372
-        $globalSources[$key]['format'] = 'auto';
373
-    }
374
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
375
-        unset($globalSources[$key]);
376
-    }
371
+	if (!isset($source['format'])) {
372
+		$globalSources[$key]['format'] = 'auto';
373
+	}
374
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
375
+		unset($globalSources[$key]);
376
+	}
377 377
 }
378 378
 connect_all($globalSources);
379 379
 foreach ($globalSources as $key => $source) {
380
-    if (isset($source['format']) && $source['format'] == 'aprs') {
380
+	if (isset($source['format']) && $source['format'] == 'aprs') {
381 381
 	$aprs_connect = 0;
382 382
 	$use_aprs = true;
383 383
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
384 384
 	break;
385
-    }
385
+	}
386 386
 }
387 387
 
388 388
 if ($use_aprs) {
@@ -423,173 +423,173 @@  discard block
 block discarded – undo
423 423
 
424 424
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
425 425
 while ($i > 0) {
426
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
426
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
427 427
 
428
-    if (!$globalDaemon) $i = $endtime-time();
429
-    // Delete old ATC
430
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
428
+	if (!$globalDaemon) $i = $endtime-time();
429
+	// Delete old ATC
430
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
431 431
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
432
-        $ATC->deleteOldATC();
433
-    }
432
+		$ATC->deleteOldATC();
433
+	}
434 434
     
435
-    if (count($last_exec) == count($globalSources)) {
435
+	if (count($last_exec) == count($globalSources)) {
436 436
 	$max = $globalMinFetch;
437 437
 	foreach ($last_exec as $last) {
438
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
438
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
439 439
 	}
440 440
 	if ($max < $globalMinFetch) {
441
-	    if ($globalDebug) echo 'Sleeping...'."\n";
442
-	    sleep($globalMinFetch-$max+2);
441
+		if ($globalDebug) echo 'Sleeping...'."\n";
442
+		sleep($globalMinFetch-$max+2);
443
+	}
443 444
 	}
444
-    }
445 445
 
446 446
     
447
-    //foreach ($formats as $id => $value) {
448
-    foreach ($globalSources as $id => $value) {
447
+	//foreach ($formats as $id => $value) {
448
+	foreach ($globalSources as $id => $value) {
449 449
 	date_default_timezone_set('UTC');
450 450
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
451 451
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
452 452
 	if ($value['format'] === 'deltadbtxt' && 
453
-	    (
453
+		(
454 454
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
455 455
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
456
-	    )
456
+		)
457 457
 	) {
458
-        //$buffer = $Common->getData($hosts[$id]);
459
-        $buffer = $Common->getData($value['host']);
460
-        if ($buffer != '') $reset = 0;
461
-        $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
462
-        $buffer = explode('\n', $buffer);
463
-        foreach ($buffer as $line) {
464
-            if ($line != '' && count($line) > 7) {
465
-                $line = explode(',', $line);
466
-                $data = array();
467
-                $data['hex'] = $line[1]; // hex
468
-                $data['ident'] = $line[2]; // ident
469
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
470
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
471
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
472
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
473
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
474
-                $data['verticalrate'] = ''; // vertical rate
475
-                //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
476
-                $data['emergency'] = ''; // emergency
477
-                $data['datetime'] = date('Y-m-d H:i:s');
478
-                $data['format_source'] = 'deltadbtxt';
479
-                $data['id_source'] = $id_source;
480
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
481
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
483
-                $SI->add($data);
484
-                unset($data);
485
-            }
486
-        }
487
-        $last_exec[$id]['last'] = time();
488
-    } elseif ($value['format'] === 'radarcapejson' &&
489
-            (
490
-                (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
491
-                (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
492
-            )
493
-        ) {
494
-            //$buffer = $Common->getData($hosts[$id]);
495
-            $buffer = $Common->getData($value['host']);
496
-            if ($buffer != '') {
497
-                $all_data = json_decode($buffer,true);
498
-                foreach ($all_data as $line) {
499
-                    $data = array();
500
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
501
-                    $data['hex'] = $line['hex']; // hex
502
-                    $data['ident'] = $line['fli']; // ident
503
-                    $data['altitude'] = $line['alt']; // altitude
504
-                    $data['speed'] = $line['spd']; // speed
505
-                    $data['heading'] = $line['trk']; // heading
506
-                    $data['latitude'] = $line['lat']; // lat
507
-                    $data['longitude'] = $line['lon']; // long
508
-                    $data['verticalrate'] = $line['vrt']; // vertical rate
509
-                    $data['squawk'] = $line['squ']; // squawk
510
-                    $data['ground'] = $line['gda']; // ground
511
-                    $data['registration'] = $line['reg'];
512
-                    //$data['emergency'] = ''; // emergency
513
-                    $data['datetime'] = date('Y-m-d H:i:s');
514
-                    $data['format_source'] = 'radarcapejson';
515
-                    $data['id_source'] = $id_source;
516
-                    if (isset($value['name']) && $value['name'] != '') {
517
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
518
-                        else $data['source_name'] = $value['name'];
519
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
520
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
521
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
458
+		//$buffer = $Common->getData($hosts[$id]);
459
+		$buffer = $Common->getData($value['host']);
460
+		if ($buffer != '') $reset = 0;
461
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
462
+		$buffer = explode('\n', $buffer);
463
+		foreach ($buffer as $line) {
464
+			if ($line != '' && count($line) > 7) {
465
+				$line = explode(',', $line);
466
+				$data = array();
467
+				$data['hex'] = $line[1]; // hex
468
+				$data['ident'] = $line[2]; // ident
469
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
470
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
471
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
472
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
473
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
474
+				$data['verticalrate'] = ''; // vertical rate
475
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
476
+				$data['emergency'] = ''; // emergency
477
+				$data['datetime'] = date('Y-m-d H:i:s');
478
+				$data['format_source'] = 'deltadbtxt';
479
+				$data['id_source'] = $id_source;
480
+				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
481
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482
+				if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
483
+				$SI->add($data);
484
+				unset($data);
485
+			}
486
+		}
487
+		$last_exec[$id]['last'] = time();
488
+	} elseif ($value['format'] === 'radarcapejson' &&
489
+			(
490
+				(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
491
+				(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
492
+			)
493
+		) {
494
+			//$buffer = $Common->getData($hosts[$id]);
495
+			$buffer = $Common->getData($value['host']);
496
+			if ($buffer != '') {
497
+				$all_data = json_decode($buffer,true);
498
+				foreach ($all_data as $line) {
499
+					$data = array();
500
+					$data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
501
+					$data['hex'] = $line['hex']; // hex
502
+					$data['ident'] = $line['fli']; // ident
503
+					$data['altitude'] = $line['alt']; // altitude
504
+					$data['speed'] = $line['spd']; // speed
505
+					$data['heading'] = $line['trk']; // heading
506
+					$data['latitude'] = $line['lat']; // lat
507
+					$data['longitude'] = $line['lon']; // long
508
+					$data['verticalrate'] = $line['vrt']; // vertical rate
509
+					$data['squawk'] = $line['squ']; // squawk
510
+					$data['ground'] = $line['gda']; // ground
511
+					$data['registration'] = $line['reg'];
512
+					//$data['emergency'] = ''; // emergency
513
+					$data['datetime'] = date('Y-m-d H:i:s');
514
+					$data['format_source'] = 'radarcapejson';
515
+					$data['id_source'] = $id_source;
516
+					if (isset($value['name']) && $value['name'] != '') {
517
+						if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
518
+						else $data['source_name'] = $value['name'];
519
+					} elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
520
+					if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
521
+					if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
522 522
 
523
-                    $SI->add($data);
524
-                    unset($data);
525
-                }
526
-            }
527
-            $last_exec[$id]['last'] = time();
523
+					$SI->add($data);
524
+					unset($data);
525
+				}
526
+			}
527
+			$last_exec[$id]['last'] = time();
528 528
 	} elseif ($value['format'] === 'aisnmeatxt' && 
529
-	    (
529
+		(
530 530
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
531 531
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
532
-	    )
532
+		)
533 533
 	) {
534
-	    date_default_timezone_set('CET');
535
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
536
-	    date_default_timezone_set('UTC');
537
-	    if ($buffer != '') $reset = 0;
538
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
-	    $buffer = explode('\n',$buffer);
540
-	    foreach ($buffer as $line) {
534
+		date_default_timezone_set('CET');
535
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
536
+		date_default_timezone_set('UTC');
537
+		if ($buffer != '') $reset = 0;
538
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
+		$buffer = explode('\n',$buffer);
540
+		foreach ($buffer as $line) {
541 541
 		if ($line != '') {
542
-		    //echo "'".$line."'\n";
543
-		    $add = false;
544
-		    $ais_data = $AIS->parse_line(trim($line));
545
-		    $data = array();
546
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
548
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
551
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
552
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
553
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
554
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
555
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
556
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
558
-		    if (isset($ais_data['timestamp'])) {
542
+			//echo "'".$line."'\n";
543
+			$add = false;
544
+			$ais_data = $AIS->parse_line(trim($line));
545
+			$data = array();
546
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
548
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
551
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
552
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
553
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
554
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
555
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
556
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
558
+			if (isset($ais_data['timestamp'])) {
559 559
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
560 560
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
561
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
562
-			    $add = true;
561
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
562
+				$add = true;
563 563
 			}
564
-		    } else {
564
+			} else {
565 565
 			$data['datetime'] = date('Y-m-d H:i:s');
566 566
 			$add = true;
567
-		    }
568
-		    $data['format_source'] = 'aisnmeatxt';
569
-    		    $data['id_source'] = $id_source;
570
-		    //print_r($data);
571
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
572
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
573
-		    unset($data);
567
+			}
568
+			$data['format_source'] = 'aisnmeatxt';
569
+				$data['id_source'] = $id_source;
570
+			//print_r($data);
571
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
572
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
573
+			unset($data);
574 574
 		}
575
-    	    }
576
-    	    $last_exec[$id]['last'] = time();
575
+			}
576
+			$last_exec[$id]['last'] = time();
577 577
 	} elseif ($value['format'] === 'aisnmeahttp') {
578
-	    $arr = $httpfeeds;
579
-	    $w = $e = null;
578
+		$arr = $httpfeeds;
579
+		$w = $e = null;
580 580
 	    
581
-	    if (isset($arr[$id])) {
581
+		if (isset($arr[$id])) {
582 582
 		$nn = stream_select($arr,$w,$e,$timeout);
583 583
 		if ($nn > 0) {
584
-		    foreach ($httpfeeds as $feed) {
584
+			foreach ($httpfeeds as $feed) {
585 585
 			$buffer = stream_get_line($feed,2000,"\n");
586 586
 			if ($buffer === FALSE) {
587
-			    connect_all($globalSources);
587
+				connect_all($globalSources);
588 588
 			}
589 589
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
590 590
 			$buffer = explode('\n',$buffer);
591 591
 			foreach ($buffer as $line) {
592
-			    if ($line != '') {
592
+				if ($line != '') {
593 593
 				$ais_data = $AIS->parse_line(trim($line));
594 594
 				$data = array();
595 595
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -607,117 +607,117 @@  discard block
 block discarded – undo
607 607
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
608 608
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
609 609
 				if (isset($ais_data['timestamp'])) {
610
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
611 611
 				} else {
612
-				    $data['datetime'] = date('Y-m-d H:i:s');
612
+					$data['datetime'] = date('Y-m-d H:i:s');
613 613
 				}
614 614
 				$data['format_source'] = 'aisnmeahttp';
615 615
 				$data['id_source'] = $id_source;
616 616
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
617 617
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
618 618
 				unset($data);
619
-			    }
619
+				}
620
+			}
620 621
 			}
621
-		    }
622 622
 		} else {
623
-		    $format = $value['format'];
624
-		    if (isset($tt[$format])) $tt[$format]++;
625
-		    else $tt[$format] = 0;
626
-		    if ($tt[$format] > 30) {
623
+			$format = $value['format'];
624
+			if (isset($tt[$format])) $tt[$format]++;
625
+			else $tt[$format] = 0;
626
+			if ($tt[$format] > 30) {
627 627
 			if ($globalDebug) echo 'Reconnect...'."\n";
628 628
 			sleep(2);
629 629
 			//$sourceeen[] = $value;
630 630
 			//connect_all($sourceeen);
631 631
 			//$sourceeen = array();
632 632
 			connect_all($globalSources);
633
-		    }
633
+			}
634
+		}
634 635
 		}
635
-	    }
636 636
 	} elseif ($value['format'] === 'myshiptracking' && 
637
-	    (
637
+		(
638 638
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
639 639
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
640
-	    )
640
+		)
641 641
 	) {
642
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
643
-	    if ($buffer != '') {
642
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
643
+		if ($buffer != '') {
644 644
 		//echo $buffer;
645 645
 		$all_data = json_decode($buffer,true);
646 646
 		//print_r($all_data);
647 647
 		if (isset($all_data[0]['DATA'])) {
648
-		    foreach ($all_data[0]['DATA'] as $line) {
648
+			foreach ($all_data[0]['DATA'] as $line) {
649 649
 			if ($line != '') {
650
-			    $data = array();
651
-			    $data['ident'] = $line['NAME'];
652
-			    $data['mmsi'] = $line['MMSI'];
653
-			    if (strlen($data['mmsi']) > 9) {
650
+				$data = array();
651
+				$data['ident'] = $line['NAME'];
652
+				$data['mmsi'] = $line['MMSI'];
653
+				if (strlen($data['mmsi']) > 9) {
654 654
 				$data['mmsi'] = substr($data['mmsi'],-9);
655
-			    }
656
-			    $data['speed'] = $line['SOG'];
657
-			    $data['heading'] = $line['COG'];
658
-			    $data['latitude'] = $line['LAT'];
659
-			    $data['longitude'] = $line['LNG'];
660
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
661
-			    //$data['type_id'] = $line['TYPE'];
662
-			    $data['imo'] = $line['IMO'];
663
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
665
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
666
-			    $data['format_source'] = 'myshiptracking';
667
-			    $data['id_source'] = $id_source;
668
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
669
-			    $MI->add($data);
670
-			    unset($data);
655
+				}
656
+				$data['speed'] = $line['SOG'];
657
+				$data['heading'] = $line['COG'];
658
+				$data['latitude'] = $line['LAT'];
659
+				$data['longitude'] = $line['LNG'];
660
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
661
+				//$data['type_id'] = $line['TYPE'];
662
+				$data['imo'] = $line['IMO'];
663
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
665
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
666
+				$data['format_source'] = 'myshiptracking';
667
+				$data['id_source'] = $id_source;
668
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
669
+				$MI->add($data);
670
+				unset($data);
671
+			}
671 672
 			}
672
-		    }
673 673
 		}
674
-	    }
675
-	    $last_exec[$id]['last'] = time();
674
+		}
675
+		$last_exec[$id]['last'] = time();
676 676
 	} elseif ($value['format'] === 'boatbeaconapp' && 
677
-	    (
677
+		(
678 678
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
679 679
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
680
-	    )
680
+		)
681 681
 	) {
682
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
683
-	    if ($buffer != '') {
682
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
683
+		if ($buffer != '') {
684 684
 		$all_data = json_decode($buffer,true);
685 685
 		if (isset($all_data[0]['mmsi'])) {
686
-		    foreach ($all_data as $line) {
686
+			foreach ($all_data as $line) {
687 687
 			if ($line != '') {
688
-			    $data = array();
689
-			    $data['ident'] = $line['shipname'];
690
-			    $data['callsign'] = $line['callsign'];
691
-			    $data['mmsi'] = substr($line['mmsi'],-9);
692
-			    $data['speed'] = $line['sog'];
693
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
694
-			    $data['latitude'] = $line['latitude'];
695
-			    $data['longitude'] = $line['longitude'];
696
-			    $data['type_id'] = $line['shiptype'];
697
-			    $data['arrival_code'] = $line['destination'];
698
-			    $data['datetime'] = $line['time'];
699
-			    $data['format_source'] = 'boatbeaconapp';
700
-			    $data['id_source'] = $id_source;
701
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
702
-			    $MI->add($data);
703
-			    unset($data);
688
+				$data = array();
689
+				$data['ident'] = $line['shipname'];
690
+				$data['callsign'] = $line['callsign'];
691
+				$data['mmsi'] = substr($line['mmsi'],-9);
692
+				$data['speed'] = $line['sog'];
693
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
694
+				$data['latitude'] = $line['latitude'];
695
+				$data['longitude'] = $line['longitude'];
696
+				$data['type_id'] = $line['shiptype'];
697
+				$data['arrival_code'] = $line['destination'];
698
+				$data['datetime'] = $line['time'];
699
+				$data['format_source'] = 'boatbeaconapp';
700
+				$data['id_source'] = $id_source;
701
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
702
+				$MI->add($data);
703
+				unset($data);
704
+			}
704 705
 			}
705
-		    }
706 706
 		}
707 707
 		
708
-	    }
709
-    	    $last_exec[$id]['last'] = time();
708
+		}
709
+			$last_exec[$id]['last'] = time();
710 710
 	} elseif ($value['format'] === 'boatnerd' && 
711
-	    (
711
+		(
712 712
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
713 713
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
714
-	    )
714
+		)
715 715
 	) {
716
-	    $buffer = $Common->getData($value['host']);
717
-	    if ($buffer != '') {
716
+		$buffer = $Common->getData($value['host']);
717
+		if ($buffer != '') {
718 718
 		$all_data = json_decode($buffer,true);
719 719
 		if (isset($all_data['features'][0]['id'])) {
720
-		    foreach ($all_data['features'] as $line) {
720
+			foreach ($all_data['features'] as $line) {
721 721
 			print_r($line);
722 722
 			$data = array();
723 723
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -737,75 +737,75 @@  discard block
 block discarded – undo
737 737
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
738 738
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
739 739
 			unset($data);
740
-		    }
740
+			}
741 741
 		}
742 742
 		
743
-	    }
744
-    	    $last_exec[$id]['last'] = time();
743
+		}
744
+			$last_exec[$id]['last'] = time();
745 745
 	} elseif ($value['format'] === 'shipplotter' && 
746
-	    (
746
+		(
747 747
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
748 748
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
749
-	    )
749
+		)
750 750
 	) {
751
-	    if ($globalDebug) echo 'download...';
752
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
753
-	    if ($globalDebug) echo 'done !'."\n";
754
-	    // FIXME: Need more work
755
-	    if ($buffer != '') $reset = 0;
756
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757
-	    $buffer = explode('\n',$buffer);
758
-	    foreach ($buffer as $line) {
751
+		if ($globalDebug) echo 'download...';
752
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
753
+		if ($globalDebug) echo 'done !'."\n";
754
+		// FIXME: Need more work
755
+		if ($buffer != '') $reset = 0;
756
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757
+		$buffer = explode('\n',$buffer);
758
+		foreach ($buffer as $line) {
759 759
 		if ($line != '') {
760
-		    $data = array();
761
-		    //echo $line."\n";
762
-		    $data['mmsi'] = (int)substr($line,0,9);
763
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
764
-		    $data['status_id'] = substr($line,21,2);
765
-		    $data['type_id'] = substr($line,24,3);
766
-		    $data['latitude'] = substr($line,29,9);
767
-		    $data['longitude'] = substr($line,41,9);
768
-		    $data['speed'] = round(substr($line,51,5));
769
-		    //$data['course'] = substr($line,57,5);
770
-		    $data['heading'] = round(substr($line,63,3));
771
-		    //$data['draft'] = substr($line,67,4);
772
-		    //$data['length'] = substr($line,72,3);
773
-		    //$data['beam'] = substr($line,76,2);
774
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
775
-		    //$data['callsign'] = trim(substr($line,100,7);
776
-		    $data['arrival_code'] = substr($line,108,20);
777
-		    //$data['etaDate'] = substr($line,129,5);
778
-		    //$data['etaTime'] = substr($line,135,5);
779
-		    $data['format_source'] = 'shipplotter';
780
-    		    $data['id_source'] = $id_source;
781
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
782
-		    //print_r($data);
783
-		    //echo 'Add...'."\n";
784
-		    $MI->add($data);
785
-		    unset($data);
760
+			$data = array();
761
+			//echo $line."\n";
762
+			$data['mmsi'] = (int)substr($line,0,9);
763
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
764
+			$data['status_id'] = substr($line,21,2);
765
+			$data['type_id'] = substr($line,24,3);
766
+			$data['latitude'] = substr($line,29,9);
767
+			$data['longitude'] = substr($line,41,9);
768
+			$data['speed'] = round(substr($line,51,5));
769
+			//$data['course'] = substr($line,57,5);
770
+			$data['heading'] = round(substr($line,63,3));
771
+			//$data['draft'] = substr($line,67,4);
772
+			//$data['length'] = substr($line,72,3);
773
+			//$data['beam'] = substr($line,76,2);
774
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
775
+			//$data['callsign'] = trim(substr($line,100,7);
776
+			$data['arrival_code'] = substr($line,108,20);
777
+			//$data['etaDate'] = substr($line,129,5);
778
+			//$data['etaTime'] = substr($line,135,5);
779
+			$data['format_source'] = 'shipplotter';
780
+				$data['id_source'] = $id_source;
781
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
782
+			//print_r($data);
783
+			//echo 'Add...'."\n";
784
+			$MI->add($data);
785
+			unset($data);
786 786
 		}
787
-    	    }
788
-    	    $last_exec[$id]['last'] = time();
787
+			}
788
+			$last_exec[$id]['last'] = time();
789 789
 	} elseif ($value['format'] === 'sailawayfull' && 
790
-	    (
790
+		(
791 791
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 5*60))
792
-	    )
792
+		)
793 793
 	) {
794
-	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
794
+		if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
795 795
 		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
796 796
 		//echo $authsailaway;
797 797
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
798 798
 		if (isset($setcookie[1][0])) {
799
-		    $sailaway_authcookie = $setcookie[1][0];
799
+			$sailaway_authcookie = $setcookie[1][0];
800
+		}
800 801
 		}
801
-	    }
802 802
 
803
-	    if ($globalDebug) echo '! Download... ';
804
-	    for ($i =0; $i <= 1; $i++) {
803
+		if ($globalDebug) echo '! Download... ';
804
+		for ($i =0; $i <= 1; $i++) {
805 805
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
806 806
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
807
-	    if ($globalDebug) echo 'done'."\n";
808
-	    if ($buffer != '') {
807
+		if ($globalDebug) echo 'done'."\n";
808
+		if ($buffer != '') {
809 809
 		$all_data = json_decode($buffer,true);
810 810
 		if (isset($all_data['missions'])) {
811 811
 			foreach ($all_data['missions'] as $mission) {
@@ -826,19 +826,19 @@  discard block
 block discarded – undo
826 826
 					//print_r($race_data);
827 827
 					unset($racebuffer);
828 828
 					if (isset($race_data['mission'])) {
829
-					    $datar = array();
830
-					    $datar['id'] = $mission['misnr'];
831
-					    $datar['desc'] = $race_data['mission']['misdescr'];
832
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
833
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
834
-					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
835
-					    $markers = array();
836
-					    foreach ($race_data['mission']['course'] as $course) {
829
+						$datar = array();
830
+						$datar['id'] = $mission['misnr'];
831
+						$datar['desc'] = $race_data['mission']['misdescr'];
832
+						$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
833
+						$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
834
+						$datar['startdate'] = $race_data['mission']['misstartdatetime'];
835
+						$markers = array();
836
+						foreach ($race_data['mission']['course'] as $course) {
837 837
 						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
838
-					    }
839
-					    $datar['markers'] = json_encode($markers);
840
-					    //print_r($datar);
841
-					    $MI->race_add($datar);
838
+						}
839
+						$datar['markers'] = json_encode($markers);
840
+						//print_r($datar);
841
+						$MI->race_add($datar);
842 842
 					}
843 843
 				}
844 844
 				if ($bufferm != '') {
@@ -903,16 +903,16 @@  discard block
 block discarded – undo
903 903
 				sleep(30);
904 904
 			}
905 905
 		}
906
-	    }
907
-	    sleep(5);
908
-	    }
909
-    	    $last_exec[$id]['last'] = time();
906
+		}
907
+		sleep(5);
908
+		}
909
+			$last_exec[$id]['last'] = time();
910 910
 	} elseif ($value['format'] === 'sailaway' && 
911
-	    (
911
+		(
912 912
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 5*60))
913
-	    )
913
+		)
914 914
 	) {
915
-	    /*
915
+		/*
916 916
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
917 917
 		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
918 918
 		//echo $authsailaway;
@@ -923,17 +923,17 @@  discard block
 block discarded – undo
923 923
 		}
924 924
 	    }
925 925
 	    */
926
-	    if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') {
926
+		if (!isset($globalSailaway['key']) || $globalSailaway['key'] == '') {
927 927
 		echo 'Sailaway API key MUST be defined';
928 928
 		exit(0);
929
-	    }
930
-	    if ($globalDebug) echo '! Download... ';
931
-	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key']);
932
-	    if ($buffer != '') {
929
+		}
930
+		if ($globalDebug) echo '! Download... ';
931
+		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key']);
932
+		if ($buffer != '') {
933 933
 		$data = json_decode($buffer,true);
934 934
 		//print_r($race_data);
935 935
 		if (isset($data['boats'])) {
936
-		    foreach ($data['boats'] as $sail) {
936
+			foreach ($data['boats'] as $sail) {
937 937
 			$data = array();
938 938
 			$data['id'] = $sail['ubtnr'];
939 939
 			$data['datetime'] = date('Y-m-d H:i:s');
@@ -949,35 +949,35 @@  discard block
 block discarded – undo
949 949
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
950 950
 			$MI->add($data);
951 951
 			unset($data);
952
-		    }
952
+			}
953 953
 		}
954
-	    }
955
-    	    $last_exec[$id]['last'] = time();
954
+		}
955
+			$last_exec[$id]['last'] = time();
956 956
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
957 957
 	} elseif (
958
-	    (
958
+		(
959 959
 		$value['format'] === 'whazzup' && 
960 960
 		(
961
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
962
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
961
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
962
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
963 963
 		)
964
-	    ) || (
964
+		) || (
965 965
 		$value['format'] === 'vatsimtxt' && 
966 966
 		(
967
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
968
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
967
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
968
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
969
+		)
969 970
 		)
970
-	    )
971 971
 	) {
972
-	    //$buffer = $Common->getData($hosts[$id]);
973
-	    $buffer = $Common->getData($value['host']);
974
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
975
-	    $buffer = explode('\n',$buffer);
976
-	    $reset = 0;
977
-	    foreach ($buffer as $line) {
978
-    		if ($line != '') {
979
-    		    $line = explode(':', $line);
980
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
972
+		//$buffer = $Common->getData($hosts[$id]);
973
+		$buffer = $Common->getData($value['host']);
974
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
975
+		$buffer = explode('\n',$buffer);
976
+		$reset = 0;
977
+		foreach ($buffer as $line) {
978
+			if ($line != '') {
979
+				$line = explode(':', $line);
980
+				if (count($line) > 30 && $line[0] != 'callsign') {
981 981
 			$data = array();
982 982
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
983 983
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -990,37 +990,37 @@  discard block
 block discarded – undo
990 990
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
991 991
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
992 992
 			$data['latitude'] = $line[5]; // lat
993
-	        	$data['longitude'] = $line[6]; // long
994
-	        	$data['verticalrate'] = ''; // vertical rate
995
-	        	$data['squawk'] = ''; // squawk
996
-	        	$data['emergency'] = ''; // emergency
997
-	        	$data['waypoints'] = $line[30];
993
+				$data['longitude'] = $line[6]; // long
994
+				$data['verticalrate'] = ''; // vertical rate
995
+				$data['squawk'] = ''; // squawk
996
+				$data['emergency'] = ''; // emergency
997
+				$data['waypoints'] = $line[30];
998 998
 			$data['datetime'] = date('Y-m-d H:i:s');
999 999
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
1000 1000
 			//if (isset($line[37])) $data['last_update'] = $line[37];
1001
-		        $data['departure_airport_icao'] = $line[11];
1002
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
1003
-		        $data['arrival_airport_icao'] = $line[13];
1001
+				$data['departure_airport_icao'] = $line[11];
1002
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
1003
+				$data['arrival_airport_icao'] = $line[13];
1004 1004
 			$data['frequency'] = $line[4];
1005 1005
 			$data['type'] = $line[18];
1006 1006
 			$data['range'] = $line[19];
1007 1007
 			if (isset($line[35])) $data['info'] = $line[35];
1008
-    			$data['id_source'] = $id_source;
1009
-	    		//$data['arrival_airport_time'] = ;
1010
-	    		if ($line[9] != '') {
1011
-	    		    $aircraft_data = explode('/',$line[9]);
1012
-	    		    if (isset($aircraft_data[1])) {
1013
-	    			$data['aircraft_icao'] = $aircraft_data[1];
1014
-	    		    }
1015
-        		}
1016
-	    		/*
1008
+				$data['id_source'] = $id_source;
1009
+				//$data['arrival_airport_time'] = ;
1010
+				if ($line[9] != '') {
1011
+					$aircraft_data = explode('/',$line[9]);
1012
+					if (isset($aircraft_data[1])) {
1013
+					$data['aircraft_icao'] = $aircraft_data[1];
1014
+					}
1015
+				}
1016
+				/*
1017 1017
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
1018 1018
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
1019 1019
 	    		*/
1020
-	    		$data['format_source'] = $value['format'];
1020
+				$data['format_source'] = $value['format'];
1021 1021
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1022 1022
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1023
-    			if ($line[3] === 'PILOT') $SI->add($data);
1023
+				if ($line[3] === 'PILOT') $SI->add($data);
1024 1024
 			elseif ($line[3] === 'ATC') {
1025 1025
 				//print_r($data);
1026 1026
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -1041,21 +1041,21 @@  discard block
 block discarded – undo
1041 1041
 					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']);
1042 1042
 				}
1043 1043
 			}
1044
-    			unset($data);
1045
-    		    }
1046
-    		}
1047
-    	    }
1048
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
1049
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
1050
-    	    $last_exec[$id]['last'] = time();
1051
-    	} elseif ($value['format'] === 'airwhere' && 
1052
-    	    (
1053
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1054
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1055
-    	    )
1056
-    	) {
1057
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1058
-	    if ($buffer != '') {
1044
+				unset($data);
1045
+				}
1046
+			}
1047
+			}
1048
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
1049
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
1050
+			$last_exec[$id]['last'] = time();
1051
+		} elseif ($value['format'] === 'airwhere' && 
1052
+			(
1053
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1054
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1055
+			)
1056
+		) {
1057
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1058
+		if ($buffer != '') {
1059 1059
 		$all_data = simplexml_load_string($buffer);
1060 1060
 		foreach($all_data->children() as $childdata) {
1061 1061
 			$data = array();
@@ -1077,10 +1077,10 @@  discard block
 block discarded – undo
1077 1077
 			$SI->add($data);
1078 1078
 			unset($data);
1079 1079
 		}
1080
-	    }
1081
-	    $Source->deleteOldLocationByType('gs');
1082
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1083
-	    if ($buffer != '') {
1080
+		}
1081
+		$Source->deleteOldLocationByType('gs');
1082
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1083
+		if ($buffer != '') {
1084 1084
 		$all_data = simplexml_load_string($buffer);
1085 1085
 		foreach($all_data->children() as $childdata) {
1086 1086
 			$data = array();
@@ -1098,8 +1098,8 @@  discard block
 block discarded – undo
1098 1098
 			}
1099 1099
 			unset($data);
1100 1100
 		}
1101
-	    }
1102
-	    $last_exec[$id]['last'] = time();
1101
+		}
1102
+		$last_exec[$id]['last'] = time();
1103 1103
 	/*
1104 1104
 	} if ($value['format'] === 'aircraftlistjson') {
1105 1105
 	    print_r($globalSources);
@@ -1107,17 +1107,17 @@  discard block
 block discarded – undo
1107 1107
 	    echo $globalMinFetch;
1108 1108
 	*/
1109 1109
 	} elseif ($value['format'] === 'aircraftlistjson' && 
1110
-	    (
1110
+		(
1111 1111
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1112 1112
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1113
-	    )
1113
+		)
1114 1114
 	) {
1115
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1116
-	    if ($buffer != '') {
1117
-	        $all_data = json_decode($buffer,true);
1115
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
1116
+		if ($buffer != '') {
1117
+			$all_data = json_decode($buffer,true);
1118 1118
 		if (isset($all_data['acList'])) {
1119
-		    $reset = 0;
1120
-		    foreach ($all_data['acList'] as $line) {
1119
+			$reset = 0;
1120
+			foreach ($all_data['acList'] as $line) {
1121 1121
 			$data = array();
1122 1122
 			$data['hex'] = $line['Icao']; // hex
1123 1123
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1140,10 +1140,10 @@  discard block
 block discarded – undo
1140 1140
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1141 1141
 			if (isset($data['latitude'])) $SI->add($data);
1142 1142
 			unset($data);
1143
-		    }
1143
+			}
1144 1144
 		} elseif (is_array($all_data)) {
1145
-		    $reset = 0;
1146
-		    foreach ($all_data as $line) {
1145
+			$reset = 0;
1146
+			foreach ($all_data as $line) {
1147 1147
 			$data = array();
1148 1148
 			$data['hex'] = $line['hex']; // hex
1149 1149
 			$data['ident'] = $line['flight']; // ident
@@ -1163,291 +1163,291 @@  discard block
 block discarded – undo
1163 1163
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1164 1164
 			$SI->add($data);
1165 1165
 			unset($data);
1166
-		    }
1166
+			}
1167 1167
 		}
1168
-	    } elseif ($globalDebug) echo 'No data'."\n";
1169
-    	    //$last_exec['aircraftlistjson'] = time();
1170
-    	    $last_exec[$id]['last'] = time();
1171
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1172
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1173
-    	    (
1174
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1175
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1176
-    	    )
1177
-    	) {
1178
-	    $buffer = $Common->getData($value['host']);
1179
-	    $all_data = json_decode($buffer,true);
1180
-	    if (isset($all_data['planes'])) {
1168
+		} elseif ($globalDebug) echo 'No data'."\n";
1169
+			//$last_exec['aircraftlistjson'] = time();
1170
+			$last_exec[$id]['last'] = time();
1171
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1172
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1173
+			(
1174
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1175
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1176
+			)
1177
+		) {
1178
+		$buffer = $Common->getData($value['host']);
1179
+		$all_data = json_decode($buffer,true);
1180
+		if (isset($all_data['planes'])) {
1181 1181
 		$reset = 0;
1182 1182
 		foreach ($all_data['planes'] as $key => $line) {
1183
-		    $data = array();
1184
-		    $data['hex'] = $key; // hex
1185
-		    $data['ident'] = $line[3]; // ident
1186
-		    $data['altitude'] = $line[6]; // altitude
1187
-		    $data['speed'] = $line[8]; // speed
1188
-		    $data['heading'] = $line[7]; // heading
1189
-		    $data['latitude'] = $line[4]; // lat
1190
-		    $data['longitude'] = $line[5]; // long
1191
-		    //$data['verticalrate'] = $line[]; // verticale rate
1192
-		    $data['squawk'] = $line[10]; // squawk
1193
-		    $data['emergency'] = ''; // emergency
1194
-		    $data['registration'] = $line[2];
1195
-		    $data['aircraft_icao'] = $line[0];
1196
-		    $deparr = explode('-',$line[1]);
1197
-		    if (count($deparr) === 2) {
1183
+			$data = array();
1184
+			$data['hex'] = $key; // hex
1185
+			$data['ident'] = $line[3]; // ident
1186
+			$data['altitude'] = $line[6]; // altitude
1187
+			$data['speed'] = $line[8]; // speed
1188
+			$data['heading'] = $line[7]; // heading
1189
+			$data['latitude'] = $line[4]; // lat
1190
+			$data['longitude'] = $line[5]; // long
1191
+			//$data['verticalrate'] = $line[]; // verticale rate
1192
+			$data['squawk'] = $line[10]; // squawk
1193
+			$data['emergency'] = ''; // emergency
1194
+			$data['registration'] = $line[2];
1195
+			$data['aircraft_icao'] = $line[0];
1196
+			$deparr = explode('-',$line[1]);
1197
+			if (count($deparr) === 2) {
1198 1198
 			$data['departure_airport_icao'] = $deparr[0];
1199 1199
 			$data['arrival_airport_icao'] = $deparr[1];
1200
-		    }
1201
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1202
-	    	    $data['format_source'] = 'planeupdatefaa';
1203
-    		    $data['id_source'] = $id_source;
1204
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1205
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1206
-		    $SI->add($data);
1207
-		    unset($data);
1200
+			}
1201
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1202
+				$data['format_source'] = 'planeupdatefaa';
1203
+				$data['id_source'] = $id_source;
1204
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1205
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1206
+			$SI->add($data);
1207
+			unset($data);
1208 1208
 		}
1209
-	    }
1210
-	    //$last_exec['planeupdatefaa'] = time();
1211
-	    $last_exec[$id]['last'] = time();
1209
+		}
1210
+		//$last_exec['planeupdatefaa'] = time();
1211
+		$last_exec[$id]['last'] = time();
1212 1212
 	} elseif ($value['format'] === 'opensky' && 
1213
-	    (
1213
+		(
1214 1214
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1215 1215
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1216
-	    )
1216
+		)
1217 1217
 	) {
1218
-	    $buffer = $Common->getData($value['host']);
1219
-	    $all_data = json_decode($buffer,true);
1220
-	    if (isset($all_data['states'])) {
1218
+		$buffer = $Common->getData($value['host']);
1219
+		$all_data = json_decode($buffer,true);
1220
+		if (isset($all_data['states'])) {
1221 1221
 		$reset = 0;
1222 1222
 		foreach ($all_data['states'] as $key => $line) {
1223
-		    $data = array();
1224
-		    $data['hex'] = $line[0]; // hex
1225
-		    $data['ident'] = trim($line[1]); // ident
1226
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1227
-		    $data['speed'] = round($line[9]*1.94384); // speed
1228
-		    $data['heading'] = round($line[10]); // heading
1229
-		    $data['latitude'] = $line[6]; // lat
1230
-		    $data['longitude'] = $line[5]; // long
1231
-		    $data['verticalrate'] = $line[11]; // verticale rate
1232
-		    //$data['squawk'] = $line[10]; // squawk
1233
-		    //$data['emergency'] = ''; // emergency
1234
-		    //$data['registration'] = $line[2];
1235
-		    //$data['aircraft_icao'] = $line[0];
1236
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1237
-		    $data['format_source'] = 'opensky';
1238
-		    $data['id_source'] = $id_source;
1239
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1240
-		    $SI->add($data);
1241
-		    unset($data);
1223
+			$data = array();
1224
+			$data['hex'] = $line[0]; // hex
1225
+			$data['ident'] = trim($line[1]); // ident
1226
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1227
+			$data['speed'] = round($line[9]*1.94384); // speed
1228
+			$data['heading'] = round($line[10]); // heading
1229
+			$data['latitude'] = $line[6]; // lat
1230
+			$data['longitude'] = $line[5]; // long
1231
+			$data['verticalrate'] = $line[11]; // verticale rate
1232
+			//$data['squawk'] = $line[10]; // squawk
1233
+			//$data['emergency'] = ''; // emergency
1234
+			//$data['registration'] = $line[2];
1235
+			//$data['aircraft_icao'] = $line[0];
1236
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1237
+			$data['format_source'] = 'opensky';
1238
+			$data['id_source'] = $id_source;
1239
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1240
+			$SI->add($data);
1241
+			unset($data);
1242 1242
 		}
1243
-	    }
1244
-	    //$last_exec['planeupdatefaa'] = time();
1245
-	    $last_exec[$id]['last'] = time();
1243
+		}
1244
+		//$last_exec['planeupdatefaa'] = time();
1245
+		$last_exec[$id]['last'] = time();
1246 1246
 	} elseif ($value['format'] === 'aircraftjson' && 
1247
-	    (
1247
+		(
1248 1248
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1249 1249
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1250
-	    )
1250
+		)
1251 1251
 	) {
1252
-	    $buffer = $Common->getData($value['host']);
1253
-	    $all_data = json_decode($buffer,true);
1254
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1252
+		$buffer = $Common->getData($value['host']);
1253
+		$all_data = json_decode($buffer,true);
1254
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1255 1255
 		$reset = 0;
1256 1256
 		foreach ($all_data['aircraft'] as $key => $line) {
1257
-		    $data = array();
1258
-		    // add support for ground vehicule with ~ in front of hex
1259
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1260
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1261
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1262
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1263
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1264
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1265
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1266
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1267
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1268
-		    //$data['emergency'] = ''; // emergency
1269
-		    //$data['registration'] = $line[2];
1270
-		    //$data['aircraft_icao'] = $line[0];
1271
-		    $data['datetime'] = date('Y-m-d H:i:s');
1272
-		    $data['format_source'] = 'aircraftjson';
1273
-		    $data['id_source'] = $id_source;
1274
-		    if (isset($value['name']) && $value['name'] != '') {
1275
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1276
-			    else $data['source_name'] = $value['name'];
1277
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1278
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1279
-		    $SI->add($data);
1280
-		    unset($data);
1257
+			$data = array();
1258
+			// add support for ground vehicule with ~ in front of hex
1259
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1260
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1261
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1262
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1263
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1264
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1265
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1266
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1267
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1268
+			//$data['emergency'] = ''; // emergency
1269
+			//$data['registration'] = $line[2];
1270
+			//$data['aircraft_icao'] = $line[0];
1271
+			$data['datetime'] = date('Y-m-d H:i:s');
1272
+			$data['format_source'] = 'aircraftjson';
1273
+			$data['id_source'] = $id_source;
1274
+			if (isset($value['name']) && $value['name'] != '') {
1275
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1276
+				else $data['source_name'] = $value['name'];
1277
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1278
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1279
+			$SI->add($data);
1280
+			unset($data);
1281 1281
 		}
1282
-	    }
1283
-	    //$last_exec['planeupdatefaa'] = time();
1284
-	    $last_exec[$id]['last'] = time();
1282
+		}
1283
+		//$last_exec['planeupdatefaa'] = time();
1284
+		$last_exec[$id]['last'] = time();
1285 1285
 	} elseif ($value['format'] === 'planefinderclient' && 
1286
-	    (
1286
+		(
1287 1287
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1288 1288
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1289
-	    )
1289
+		)
1290 1290
 	) {
1291
-	    $buffer = $Common->getData($value['host']);
1292
-	    $all_data = json_decode($buffer,true);
1293
-	    if (isset($all_data['aircraft'])) {
1291
+		$buffer = $Common->getData($value['host']);
1292
+		$all_data = json_decode($buffer,true);
1293
+		if (isset($all_data['aircraft'])) {
1294 1294
 		$reset = 0;
1295 1295
 		foreach ($all_data['aircraft'] as $key => $line) {
1296
-		    $data = array();
1297
-		    $data['hex'] = $key; // hex
1298
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1299
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1300
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1301
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1302
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1303
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1304
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1305
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1306
-		    //$data['emergency'] = ''; // emergency
1307
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1308
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1309
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1310
-		    $data['format_source'] = 'planefinderclient';
1311
-		    $data['id_source'] = $id_source;
1312
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1313
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1314
-		    $SI->add($data);
1315
-		    unset($data);
1296
+			$data = array();
1297
+			$data['hex'] = $key; // hex
1298
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1299
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1300
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1301
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1302
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1303
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1304
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1305
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1306
+			//$data['emergency'] = ''; // emergency
1307
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1308
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1309
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1310
+			$data['format_source'] = 'planefinderclient';
1311
+			$data['id_source'] = $id_source;
1312
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1313
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1314
+			$SI->add($data);
1315
+			unset($data);
1316 1316
 		}
1317
-	    }
1318
-	    $last_exec[$id]['last'] = time();
1317
+		}
1318
+		$last_exec[$id]['last'] = time();
1319 1319
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1320 1320
 	} elseif ($value['format'] === 'fr24json' && 
1321
-	    (
1321
+		(
1322 1322
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1323 1323
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1324
-	    )
1324
+		)
1325 1325
 	) {
1326
-	    //$buffer = $Common->getData($hosts[$id]);
1327
-	    $buffer = $Common->getData($value['host']);
1328
-	    $all_data = json_decode($buffer,true);
1329
-	    if (!empty($all_data)) $reset = 0;
1330
-	    foreach ($all_data as $key => $line) {
1326
+		//$buffer = $Common->getData($hosts[$id]);
1327
+		$buffer = $Common->getData($value['host']);
1328
+		$all_data = json_decode($buffer,true);
1329
+		if (!empty($all_data)) $reset = 0;
1330
+		foreach ($all_data as $key => $line) {
1331 1331
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1332
-		    $data = array();
1333
-		    $data['hex'] = $line[0];
1334
-		    $data['ident'] = $line[16]; //$line[13]
1335
-	    	    $data['altitude'] = $line[4]; // altitude
1336
-	    	    $data['speed'] = $line[5]; // speed
1337
-	    	    $data['heading'] = $line[3]; // heading
1338
-	    	    $data['latitude'] = $line[1]; // lat
1339
-	    	    $data['longitude'] = $line[2]; // long
1340
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1341
-	    	    $data['squawk'] = $line[6]; // squawk
1342
-	    	    $data['aircraft_icao'] = $line[8];
1343
-	    	    $data['registration'] = $line[9];
1344
-		    $data['departure_airport_iata'] = $line[11];
1345
-		    $data['arrival_airport_iata'] = $line[12];
1346
-	    	    $data['emergency'] = ''; // emergency
1347
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1348
-	    	    $data['format_source'] = 'fr24json';
1349
-    		    $data['id_source'] = $id_source;
1350
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1351
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1352
-		    $SI->add($data);
1353
-		    unset($data);
1332
+			$data = array();
1333
+			$data['hex'] = $line[0];
1334
+			$data['ident'] = $line[16]; //$line[13]
1335
+				$data['altitude'] = $line[4]; // altitude
1336
+				$data['speed'] = $line[5]; // speed
1337
+				$data['heading'] = $line[3]; // heading
1338
+				$data['latitude'] = $line[1]; // lat
1339
+				$data['longitude'] = $line[2]; // long
1340
+				$data['verticalrate'] = $line[15]; // verticale rate
1341
+				$data['squawk'] = $line[6]; // squawk
1342
+				$data['aircraft_icao'] = $line[8];
1343
+				$data['registration'] = $line[9];
1344
+			$data['departure_airport_iata'] = $line[11];
1345
+			$data['arrival_airport_iata'] = $line[12];
1346
+				$data['emergency'] = ''; // emergency
1347
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1348
+				$data['format_source'] = 'fr24json';
1349
+				$data['id_source'] = $id_source;
1350
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1351
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1352
+			$SI->add($data);
1353
+			unset($data);
1354 1354
 		}
1355
-	    }
1356
-	    //$last_exec['fr24json'] = time();
1357
-	    $last_exec[$id]['last'] = time();
1355
+		}
1356
+		//$last_exec['fr24json'] = time();
1357
+		$last_exec[$id]['last'] = time();
1358 1358
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1359 1359
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1360
-	    (
1360
+		(
1361 1361
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1362 1362
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1363
-	    )
1363
+		)
1364 1364
 	) {
1365
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1366
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1367
-	    //echo $buffer;
1368
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1369
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1370
-	    $all_data = json_decode($buffer,true);
1371
-	    if (json_last_error() != JSON_ERROR_NONE) {
1365
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1366
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1367
+		//echo $buffer;
1368
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1369
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1370
+		$all_data = json_decode($buffer,true);
1371
+		if (json_last_error() != JSON_ERROR_NONE) {
1372 1372
 		die(json_last_error_msg());
1373
-	    }
1374
-	    if (isset($all_data['mrkrs'])) {
1373
+		}
1374
+		if (isset($all_data['mrkrs'])) {
1375 1375
 		$reset = 0;
1376 1376
 		foreach ($all_data['mrkrs'] as $key => $line) {
1377
-		    if (isset($line['inf'])) {
1377
+			if (isset($line['inf'])) {
1378 1378
 			$data = array();
1379 1379
 			$data['hex'] = $line['inf']['ia'];
1380 1380
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1381
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1382
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1383
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1384
-	    		$data['latitude'] = $line['pt'][0]; // lat
1385
-	    		$data['longitude'] = $line['pt'][1]; // long
1386
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1387
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1388
-	    		//$data['aircraft_icao'] = $line[8];
1389
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1381
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1382
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1383
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1384
+				$data['latitude'] = $line['pt'][0]; // lat
1385
+				$data['longitude'] = $line['pt'][1]; // long
1386
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1387
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1388
+				//$data['aircraft_icao'] = $line[8];
1389
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1390 1390
 			//$data['departure_airport_iata'] = $line[11];
1391 1391
 			//$data['arrival_airport_iata'] = $line[12];
1392
-	    		//$data['emergency'] = ''; // emergency
1392
+				//$data['emergency'] = ''; // emergency
1393 1393
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1394
-	    		$data['format_source'] = 'radarvirtueljson';
1395
-    			$data['id_source'] = $id_source;
1394
+				$data['format_source'] = 'radarvirtueljson';
1395
+				$data['id_source'] = $id_source;
1396 1396
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1397 1397
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1398 1398
 			$SI->add($data);
1399 1399
 			unset($data);
1400
-		    }
1400
+			}
1401 1401
 		}
1402
-	    }
1403
-	    //$last_exec['radarvirtueljson'] = time();
1404
-	    $last_exec[$id]['last'] = time();
1402
+		}
1403
+		//$last_exec['radarvirtueljson'] = time();
1404
+		$last_exec[$id]['last'] = time();
1405 1405
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1406 1406
 	} elseif ($value['format'] === 'pirepsjson' && 
1407
-	    (
1407
+		(
1408 1408
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1409 1409
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1410
-	    )
1410
+		)
1411 1411
 	) {
1412
-	    //$buffer = $Common->getData($hosts[$id]);
1413
-	    $buffer = $Common->getData($value['host'].'?'.time());
1414
-	    $all_data = json_decode(utf8_encode($buffer),true);
1412
+		//$buffer = $Common->getData($hosts[$id]);
1413
+		$buffer = $Common->getData($value['host'].'?'.time());
1414
+		$all_data = json_decode(utf8_encode($buffer),true);
1415 1415
 	    
1416
-	    if (isset($all_data['pireps'])) {
1416
+		if (isset($all_data['pireps'])) {
1417 1417
 		$reset = 0;
1418
-	        foreach ($all_data['pireps'] as $line) {
1419
-		    $data = array();
1420
-		    $data['id'] = $line['id'];
1421
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1422
-		    $data['ident'] = $line['callsign']; // ident
1423
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1424
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1425
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1426
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1427
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1428
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1429
-		    $data['latitude'] = $line['lat']; // lat
1430
-		    $data['longitude'] = $line['lon']; // long
1431
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1432
-		    //$data['squawk'] = $line['squawk']; // squawk
1433
-		    //$data['emergency'] = ''; // emergency
1434
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1435
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1436
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1437
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1438
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1439
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1440
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1441
-		    else $data['info'] = '';
1442
-		    $data['format_source'] = 'pireps';
1443
-    		    $data['id_source'] = $id_source;
1444
-		    $data['datetime'] = date('Y-m-d H:i:s');
1445
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1446
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1447
-		    if ($line['icon'] === 'plane') {
1418
+			foreach ($all_data['pireps'] as $line) {
1419
+			$data = array();
1420
+			$data['id'] = $line['id'];
1421
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1422
+			$data['ident'] = $line['callsign']; // ident
1423
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1424
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1425
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1426
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1427
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1428
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1429
+			$data['latitude'] = $line['lat']; // lat
1430
+			$data['longitude'] = $line['lon']; // long
1431
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1432
+			//$data['squawk'] = $line['squawk']; // squawk
1433
+			//$data['emergency'] = ''; // emergency
1434
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1435
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1436
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1437
+			//$data['arrival_airport_time'] = $line['arrtime'];
1438
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1439
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1440
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1441
+			else $data['info'] = '';
1442
+			$data['format_source'] = 'pireps';
1443
+				$data['id_source'] = $id_source;
1444
+			$data['datetime'] = date('Y-m-d H:i:s');
1445
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1446
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1447
+			if ($line['icon'] === 'plane') {
1448 1448
 			$SI->add($data);
1449
-		    //    print_r($data);
1450
-    		    } elseif ($line['icon'] === 'ct') {
1449
+			//    print_r($data);
1450
+				} elseif ($line['icon'] === 'ct') {
1451 1451
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1452 1452
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1453 1453
 			$typec = substr($data['ident'],-3);
@@ -1462,209 +1462,209 @@  discard block
 block discarded – undo
1462 1462
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1463 1463
 			else $data['type'] = 'Observer';
1464 1464
 			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']);
1465
-		    }
1466
-		    unset($data);
1465
+			}
1466
+			unset($data);
1467 1467
 		}
1468
-	    }
1469
-	    //$last_exec['pirepsjson'] = time();
1470
-	    $last_exec[$id]['last'] = time();
1468
+		}
1469
+		//$last_exec['pirepsjson'] = time();
1470
+		$last_exec[$id]['last'] = time();
1471 1471
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1472 1472
 	} elseif ($value['format'] === 'phpvmacars' && 
1473
-	    (
1473
+		(
1474 1474
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1475 1475
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1476
-	    )
1476
+		)
1477 1477
 	) {
1478
-	    //$buffer = $Common->getData($hosts[$id]);
1479
-	    if ($globalDebug) echo 'Get Data...'."\n";
1480
-	    $buffer = $Common->getData($value['host']);
1481
-	    $all_data = json_decode($buffer,true);
1482
-	    if ($buffer != '' && is_array($all_data)) {
1478
+		//$buffer = $Common->getData($hosts[$id]);
1479
+		if ($globalDebug) echo 'Get Data...'."\n";
1480
+		$buffer = $Common->getData($value['host']);
1481
+		$all_data = json_decode($buffer,true);
1482
+		if ($buffer != '' && is_array($all_data)) {
1483 1483
 		$reset = 0;
1484 1484
 		foreach ($all_data as $line) {
1485
-	    	    $data = array();
1486
-	    	    //$data['id'] = $line['id']; // id not usable
1487
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1488
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1489
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1490
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1491
-	    	    $data['ident'] = $line['flightnum']; // ident
1492
-	    	    $data['altitude'] = $line['alt']; // altitude
1493
-	    	    $data['speed'] = $line['gs']; // speed
1494
-	    	    $data['heading'] = $line['heading']; // heading
1495
-	    	    $data['latitude'] = $line['lat']; // lat
1496
-	    	    $data['longitude'] = $line['lng']; // long
1497
-	    	    $data['verticalrate'] = ''; // verticale rate
1498
-	    	    $data['squawk'] = ''; // squawk
1499
-	    	    $data['emergency'] = ''; // emergency
1500
-	    	    //$data['datetime'] = $line['lastupdate'];
1501
-	    	    //$data['last_update'] = $line['lastupdate'];
1502
-	    	    if (isset($value['timezone'])) {
1503
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1504
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1505
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1506
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1507
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1508
-	    	    $data['departure_airport_time'] = $line['deptime'];
1509
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1510
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1511
-    		    if (isset($line['registration'])) {
1512
-    			$data['registration'] = $line['registration'];
1513
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1514
-    		    } else $data['registration'] = $line['aircraft'];
1515
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1516
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1517
-		    if (isset($line['aircraftname'])) {
1485
+				$data = array();
1486
+				//$data['id'] = $line['id']; // id not usable
1487
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1488
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1489
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1490
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1491
+				$data['ident'] = $line['flightnum']; // ident
1492
+				$data['altitude'] = $line['alt']; // altitude
1493
+				$data['speed'] = $line['gs']; // speed
1494
+				$data['heading'] = $line['heading']; // heading
1495
+				$data['latitude'] = $line['lat']; // lat
1496
+				$data['longitude'] = $line['lng']; // long
1497
+				$data['verticalrate'] = ''; // verticale rate
1498
+				$data['squawk'] = ''; // squawk
1499
+				$data['emergency'] = ''; // emergency
1500
+				//$data['datetime'] = $line['lastupdate'];
1501
+				//$data['last_update'] = $line['lastupdate'];
1502
+				if (isset($value['timezone'])) {
1503
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1504
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1505
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1506
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1507
+				$data['departure_airport_icao'] = $line['depicao'];
1508
+				$data['departure_airport_time'] = $line['deptime'];
1509
+				$data['arrival_airport_icao'] = $line['arricao'];
1510
+				$data['arrival_airport_time'] = $line['arrtime'];
1511
+				if (isset($line['registration'])) {
1512
+				$data['registration'] = $line['registration'];
1513
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1514
+				} else $data['registration'] = $line['aircraft'];
1515
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1516
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1517
+			if (isset($line['aircraftname'])) {
1518 1518
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1519 1519
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1520
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1521
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1522
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1523
-	    		else {
1524
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1525
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1526
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1527
-	    		}
1528
-	    	    }
1529
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1530
-    		    $data['id_source'] = $id_source;
1531
-	    	    $data['format_source'] = 'phpvmacars';
1532
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1533
-		    $SI->add($data);
1534
-		    unset($data);
1520
+				$aircraft_data = explode('-',$line['aircraftname']);
1521
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1522
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1523
+				else {
1524
+					$aircraft_data = explode(' ',$line['aircraftname']);
1525
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1526
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1527
+				}
1528
+				}
1529
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1530
+				$data['id_source'] = $id_source;
1531
+				$data['format_source'] = 'phpvmacars';
1532
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1533
+			$SI->add($data);
1534
+			unset($data);
1535 1535
 		}
1536 1536
 		if ($globalDebug) echo 'No more data...'."\n";
1537 1537
 		unset($buffer);
1538 1538
 		unset($all_data);
1539
-	    }
1540
-	    //$last_exec['phpvmacars'] = time();
1541
-	    $last_exec[$id]['last'] = time();
1539
+		}
1540
+		//$last_exec['phpvmacars'] = time();
1541
+		$last_exec[$id]['last'] = time();
1542 1542
 	} elseif ($value['format'] === 'vaos' && 
1543
-	    (
1543
+		(
1544 1544
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1545 1545
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1546
-	    )
1546
+		)
1547 1547
 	) {
1548
-	    //$buffer = $Common->getData($hosts[$id]);
1549
-	    if ($globalDebug) echo 'Get Data...'."\n";
1550
-	    $buffer = $Common->getData($value['host']);
1551
-	    $all_data = json_decode($buffer,true);
1552
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1548
+		//$buffer = $Common->getData($hosts[$id]);
1549
+		if ($globalDebug) echo 'Get Data...'."\n";
1550
+		$buffer = $Common->getData($value['host']);
1551
+		$all_data = json_decode($buffer,true);
1552
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1553 1553
 		$reset = 0;
1554 1554
 		foreach ($all_data['ACARSData'] as $line) {
1555
-		    //print_r($line);
1556
-	    	    $data = array();
1557
-	    	    //$data['id'] = $line['id']; // id not usable
1558
-	    	    $data['id'] = $line['id'];
1559
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1560
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1561
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1562
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1563
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1564
-	    	    $data['altitude'] = $line['altitude']; // altitude
1565
-	    	    $data['speed'] = $line['groundspeed']; // speed
1566
-	    	    $data['heading'] = $line['heading']; // heading
1567
-	    	    $data['latitude'] = $line['lat']; // lat
1568
-	    	    $data['longitude'] = $line['lon']; // long
1569
-	    	    //$data['verticalrate'] = ''; // verticale rate
1570
-	    	    //$data['squawk'] = ''; // squawk
1571
-	    	    //$data['emergency'] = ''; // emergency
1572
-	    	    if (isset($value['timezone'])) {
1573
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1574
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1575
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1576
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1555
+			//print_r($line);
1556
+				$data = array();
1557
+				//$data['id'] = $line['id']; // id not usable
1558
+				$data['id'] = $line['id'];
1559
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1560
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1561
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1562
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1563
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1564
+				$data['altitude'] = $line['altitude']; // altitude
1565
+				$data['speed'] = $line['groundspeed']; // speed
1566
+				$data['heading'] = $line['heading']; // heading
1567
+				$data['latitude'] = $line['lat']; // lat
1568
+				$data['longitude'] = $line['lon']; // long
1569
+				//$data['verticalrate'] = ''; // verticale rate
1570
+				//$data['squawk'] = ''; // squawk
1571
+				//$data['emergency'] = ''; // emergency
1572
+				if (isset($value['timezone'])) {
1573
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1574
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1575
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1576
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1577 1577
 	    	    
1578
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1579
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1580
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1581
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1582
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1578
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1579
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1580
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1581
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1582
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1583 1583
 
1584
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1585
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1586
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1584
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1585
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1586
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1587 1587
 
1588
-    		    $data['id_source'] = $id_source;
1589
-	    	    $data['format_source'] = 'vaos';
1590
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1591
-		    $SI->add($data);
1592
-		    unset($data);
1588
+				$data['id_source'] = $id_source;
1589
+				$data['format_source'] = 'vaos';
1590
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1591
+			$SI->add($data);
1592
+			unset($data);
1593 1593
 		}
1594 1594
 		if ($globalDebug) echo 'No more data...'."\n";
1595 1595
 		unset($buffer);
1596 1596
 		unset($all_data);
1597
-	    }
1598
-	    //$last_exec['phpvmacars'] = time();
1599
-	    $last_exec[$id]['last'] = time();
1597
+		}
1598
+		//$last_exec['phpvmacars'] = time();
1599
+		$last_exec[$id]['last'] = time();
1600 1600
 	} elseif ($value['format'] === 'vam' && 
1601
-	    (
1601
+		(
1602 1602
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1603 1603
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1604
-	    )
1604
+		)
1605 1605
 	) {
1606
-	    //$buffer = $Common->getData($hosts[$id]);
1607
-	    if ($globalDebug) echo 'Get Data...'."\n";
1608
-	    $buffer = $Common->getData($value['host']);
1609
-	    $all_data = json_decode($buffer,true);
1610
-	    if ($buffer != '' && is_array($all_data)) {
1606
+		//$buffer = $Common->getData($hosts[$id]);
1607
+		if ($globalDebug) echo 'Get Data...'."\n";
1608
+		$buffer = $Common->getData($value['host']);
1609
+		$all_data = json_decode($buffer,true);
1610
+		if ($buffer != '' && is_array($all_data)) {
1611 1611
 		$reset = 0;
1612 1612
 		foreach ($all_data as $line) {
1613
-	    	    $data = array();
1614
-	    	    //$data['id'] = $line['id']; // id not usable
1615
-	    	    $data['id'] = trim($line['flight_id']);
1616
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1617
-	    	    $data['pilot_name'] = $line['pilot_name'];
1618
-	    	    $data['pilot_id'] = $line['pilot_id'];
1619
-	    	    $data['ident'] = trim($line['callsign']); // ident
1620
-	    	    $data['altitude'] = $line['altitude']; // altitude
1621
-	    	    $data['speed'] = $line['gs']; // speed
1622
-	    	    $data['heading'] = $line['heading']; // heading
1623
-	    	    $data['latitude'] = $line['latitude']; // lat
1624
-	    	    $data['longitude'] = $line['longitude']; // long
1625
-	    	    $data['verticalrate'] = ''; // verticale rate
1626
-	    	    $data['squawk'] = ''; // squawk
1627
-	    	    $data['emergency'] = ''; // emergency
1628
-	    	    //$data['datetime'] = $line['lastupdate'];
1629
-	    	    $data['last_update'] = $line['last_update'];
1630
-		    $data['datetime'] = date('Y-m-d H:i:s');
1631
-	    	    $data['departure_airport_icao'] = $line['departure'];
1632
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1633
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1634
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1635
-    		    //$data['registration'] = $line['aircraft'];
1636
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1637
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1638
-    		    $data['id_source'] = $id_source;
1639
-	    	    $data['format_source'] = 'vam';
1640
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1641
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1642
-		    $SI->add($data);
1643
-		    unset($data);
1613
+				$data = array();
1614
+				//$data['id'] = $line['id']; // id not usable
1615
+				$data['id'] = trim($line['flight_id']);
1616
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1617
+				$data['pilot_name'] = $line['pilot_name'];
1618
+				$data['pilot_id'] = $line['pilot_id'];
1619
+				$data['ident'] = trim($line['callsign']); // ident
1620
+				$data['altitude'] = $line['altitude']; // altitude
1621
+				$data['speed'] = $line['gs']; // speed
1622
+				$data['heading'] = $line['heading']; // heading
1623
+				$data['latitude'] = $line['latitude']; // lat
1624
+				$data['longitude'] = $line['longitude']; // long
1625
+				$data['verticalrate'] = ''; // verticale rate
1626
+				$data['squawk'] = ''; // squawk
1627
+				$data['emergency'] = ''; // emergency
1628
+				//$data['datetime'] = $line['lastupdate'];
1629
+				$data['last_update'] = $line['last_update'];
1630
+			$data['datetime'] = date('Y-m-d H:i:s');
1631
+				$data['departure_airport_icao'] = $line['departure'];
1632
+				//$data['departure_airport_time'] = $line['departure_time'];
1633
+				$data['arrival_airport_icao'] = $line['arrival'];
1634
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1635
+				//$data['registration'] = $line['aircraft'];
1636
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1637
+				$data['aircraft_icao'] = $line['plane_type'];
1638
+				$data['id_source'] = $id_source;
1639
+				$data['format_source'] = 'vam';
1640
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1641
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1642
+			$SI->add($data);
1643
+			unset($data);
1644 1644
 		}
1645 1645
 		if ($globalDebug) echo 'No more data...'."\n";
1646 1646
 		unset($buffer);
1647 1647
 		unset($all_data);
1648
-	    }
1649
-	    //$last_exec['phpvmacars'] = time();
1650
-	    $last_exec[$id]['last'] = time();
1648
+		}
1649
+		//$last_exec['phpvmacars'] = time();
1650
+		$last_exec[$id]['last'] = time();
1651 1651
 	} elseif ($value['format'] === 'blitzortung' && 
1652
-	    (
1652
+		(
1653 1653
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1654 1654
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1655
-	    )
1655
+		)
1656 1656
 	) {
1657
-	    //$buffer = $Common->getData($hosts[$id]);
1658
-	    if ($globalDebug) echo 'Get Data...'."\n";
1659
-	    $buffer = $Common->getData($value['host']);
1660
-	    $all_data = json_decode($buffer,true);
1661
-	    if ($buffer != '') {
1657
+		//$buffer = $Common->getData($hosts[$id]);
1658
+		if ($globalDebug) echo 'Get Data...'."\n";
1659
+		$buffer = $Common->getData($value['host']);
1660
+		$all_data = json_decode($buffer,true);
1661
+		if ($buffer != '') {
1662 1662
 		$Source->deleteLocationBySource('blitzortung');
1663 1663
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1664 1664
 		$buffer = explode('\n',$buffer);
1665 1665
 		foreach ($buffer as $buffer_line) {
1666
-		    $line = json_decode($buffer_line,true);
1667
-		    if (isset($line['time'])) {
1666
+			$line = json_decode($buffer_line,true);
1667
+			if (isset($line['time'])) {
1668 1668
 			$data = array();
1669 1669
 			$data['altitude'] = $line['alt']; // altitude
1670 1670
 			$data['latitude'] = $line['lat']; // lat
@@ -1676,92 +1676,92 @@  discard block
 block discarded – undo
1676 1676
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1677 1677
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1678 1678
 			unset($data);
1679
-		    }
1679
+			}
1680 1680
 		}
1681 1681
 		if ($globalDebug) echo 'No more data...'."\n";
1682 1682
 		unset($buffer);
1683
-	    }
1684
-	    $last_exec[$id]['last'] = time();
1683
+		}
1684
+		$last_exec[$id]['last'] = time();
1685 1685
 	} elseif ($value['format'] === 'acarsjson') {
1686
-        $arr = $httpfeeds;
1687
-        $w = $e = null;
1688
-        if (isset($arr[$id])) {
1689
-            $nn = stream_select($arr,$w,$e,$timeout);
1690
-            if ($nn > 0) {
1691
-                foreach ($httpfeeds as $feed) {
1692
-                    $buffer = stream_get_line($feed,2000,"\n");
1693
-                    if ($buffer === FALSE) {
1694
-                        connect_all($globalSources);
1695
-                    }
1696
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1697
-                    $buffer = explode('\n',$buffer);
1698
-                    foreach ($buffer as $line) {
1699
-                        if ($line != '') {
1700
-                            $line = json_decode($line, true);
1701
-                            if (!empty($line)) {
1702
-                                $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1703
-                                $ACARS->deleteLiveAcarsData();
1704
-                            }
1705
-                        }
1706
-                    }
1707
-                }
1708
-            } else {
1709
-                $format = $value['format'];
1710
-                if (isset($tt[$format])) $tt[$format]++;
1711
-                else $tt[$format] = 0;
1712
-                if ($tt[$format] > 30) {
1713
-                    if ($globalDebug) echo 'Reconnect...'."\n";
1714
-                    sleep(2);
1715
-                    //$sourceeen[] = $value;
1716
-                    //connect_all($sourceeen);
1717
-                    //$sourceeen = array();
1718
-                    connect_all($globalSources);
1719
-                }
1720
-            }
1721
-        }
1686
+		$arr = $httpfeeds;
1687
+		$w = $e = null;
1688
+		if (isset($arr[$id])) {
1689
+			$nn = stream_select($arr,$w,$e,$timeout);
1690
+			if ($nn > 0) {
1691
+				foreach ($httpfeeds as $feed) {
1692
+					$buffer = stream_get_line($feed,2000,"\n");
1693
+					if ($buffer === FALSE) {
1694
+						connect_all($globalSources);
1695
+					}
1696
+					$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1697
+					$buffer = explode('\n',$buffer);
1698
+					foreach ($buffer as $line) {
1699
+						if ($line != '') {
1700
+							$line = json_decode($line, true);
1701
+							if (!empty($line)) {
1702
+								$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1703
+								$ACARS->deleteLiveAcarsData();
1704
+							}
1705
+						}
1706
+					}
1707
+				}
1708
+			} else {
1709
+				$format = $value['format'];
1710
+				if (isset($tt[$format])) $tt[$format]++;
1711
+				else $tt[$format] = 0;
1712
+				if ($tt[$format] > 30) {
1713
+					if ($globalDebug) echo 'Reconnect...'."\n";
1714
+					sleep(2);
1715
+					//$sourceeen[] = $value;
1716
+					//connect_all($sourceeen);
1717
+					//$sourceeen = array();
1718
+					connect_all($globalSources);
1719
+				}
1720
+			}
1721
+		}
1722 1722
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1723 1723
 	} 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'] === 'acarsjsonudp' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1724
-	    //$last_exec[$id]['last'] = time();
1725
-	    //$read = array( $sockets[$id] );
1726
-	    $read = $sockets;
1727
-	    $write = NULL;
1728
-	    $e = NULL;
1729
-	    $n = socket_select($read, $write, $e, $timeout);
1730
-	    if ($e != NULL) var_dump($e);
1731
-	    if ($n > 0) {
1724
+		//$last_exec[$id]['last'] = time();
1725
+		//$read = array( $sockets[$id] );
1726
+		$read = $sockets;
1727
+		$write = NULL;
1728
+		$e = NULL;
1729
+		$n = socket_select($read, $write, $e, $timeout);
1730
+		if ($e != NULL) var_dump($e);
1731
+		if ($n > 0) {
1732 1732
 		$reset = 0;
1733 1733
 		foreach ($read as $nb => $r) {
1734
-		    //$value = $formats[$nb];
1735
-		    $format = $globalSources[$nb]['format'];
1736
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1734
+			//$value = $formats[$nb];
1735
+			$format = $globalSources[$nb]['format'];
1736
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1737 1737
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1738
-		    } elseif ($format === 'vrstcp') {
1738
+			} elseif ($format === 'vrstcp') {
1739 1739
 			$buffer = @socket_read($r, 6000);
1740
-		    } else {
1740
+			} else {
1741 1741
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1742
-		    }
1743
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1744
-		    //echo $buffer."\n";
1745
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1746
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1747
-		    $error = false;
1748
-		    //$SI::del();
1749
-		    if ($buffer !== FALSE) {
1742
+			}
1743
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1744
+			//echo $buffer."\n";
1745
+			// lets play nice and handle signals such as ctrl-c/kill properly
1746
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1747
+			$error = false;
1748
+			//$SI::del();
1749
+			if ($buffer !== FALSE) {
1750 1750
 			if ($format === 'vrstcp') {
1751
-			    $buffer = explode('},{',$buffer);
1751
+				$buffer = explode('},{',$buffer);
1752 1752
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1753
-		    }
1754
-		    // SBS format is CSV format
1755
-		    if ($buffer !== FALSE && $buffer !== '') {
1753
+			}
1754
+			// SBS format is CSV format
1755
+			if ($buffer !== FALSE && $buffer !== '') {
1756 1756
 			$tt[$format] = 0;
1757 1757
 			if ($format === 'acarssbs3') {
1758
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1759
-			    $ACARS->add(trim($buffer));
1760
-			    $ACARS->deleteLiveAcarsData();
1758
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1759
+				$ACARS->add(trim($buffer));
1760
+				$ACARS->deleteLiveAcarsData();
1761 1761
 			} elseif ($format === 'raw') {
1762
-			    // AVR format
1763
-			    $data = $SBS->parse($buffer);
1764
-			    if (is_array($data)) {
1762
+				// AVR format
1763
+				$data = $SBS->parse($buffer);
1764
+				if (is_array($data)) {
1765 1765
 				//if (!empty($data)) print_r($data);
1766 1766
 				$data['datetime'] = date('Y-m-d H:i:s');
1767 1767
 				$data['format_source'] = 'raw';
@@ -1771,39 +1771,39 @@  discard block
 block discarded – undo
1771 1771
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1772 1772
 				$SI->add($data);
1773 1773
 				unset($data);
1774
-			    }
1774
+				}
1775 1775
 			} elseif ($format === 'ais') {
1776
-			    $ais_data = $AIS->parse_line(trim($buffer));
1777
-			    $data = array();
1778
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1779
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1780
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1781
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1782
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1783
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1784
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1785
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1786
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1787
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1788
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1789
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1790
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1791
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1792
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1793
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1776
+				$ais_data = $AIS->parse_line(trim($buffer));
1777
+				$data = array();
1778
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1779
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1780
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1781
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1782
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1783
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1784
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1785
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1786
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1787
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1788
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1789
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1790
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1791
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1792
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1793
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1794 1794
 
1795
-			    if (isset($ais_data['timestamp'])) {
1795
+				if (isset($ais_data['timestamp'])) {
1796 1796
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1797
-			    } else {
1797
+				} else {
1798 1798
 				$data['datetime'] = date('Y-m-d H:i:s');
1799
-			    }
1800
-			    $data['format_source'] = 'aisnmea';
1801
-    			    $data['id_source'] = $id_source;
1802
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1803
-			    unset($data);
1804
-                        } elseif ($format === 'flightgearsp') {
1805
-                    	    //echo $buffer."\n";
1806
-                    	    if (strlen($buffer) > 5) {
1799
+				}
1800
+				$data['format_source'] = 'aisnmea';
1801
+					$data['id_source'] = $id_source;
1802
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1803
+				unset($data);
1804
+						} elseif ($format === 'flightgearsp') {
1805
+							//echo $buffer."\n";
1806
+							if (strlen($buffer) > 5) {
1807 1807
 				$line = explode(',',$buffer);
1808 1808
 				$data = array();
1809 1809
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1820,47 +1820,47 @@  discard block
 block discarded – undo
1820 1820
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1821 1821
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1822 1822
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1823
-			    }
1824
-                        } elseif ($format === 'acars') {
1825
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1826
-			    $ACARS->add(trim($buffer));
1827
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1828
-			    $ACARS->deleteLiveAcarsData();
1823
+				}
1824
+						} elseif ($format === 'acars') {
1825
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1826
+				$ACARS->add(trim($buffer));
1827
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1828
+				$ACARS->deleteLiveAcarsData();
1829 1829
 			} elseif ($format === 'acarsjsonudp') {
1830
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1831
-                            $line = json_decode(trim($buffer), true);
1832
-                            if (!empty($line)) {
1830
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1831
+							$line = json_decode(trim($buffer), true);
1832
+							if (!empty($line)) {
1833 1833
 				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1834
-                                $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1835
-                                $ACARS->deleteLiveAcarsData();
1836
-                            }
1837
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1834
+								$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1835
+								$ACARS->deleteLiveAcarsData();
1836
+							}
1837
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1838 1838
 			} elseif ($format === 'flightgearmp') {
1839
-			    if (substr($buffer,0,1) != '#') {
1839
+				if (substr($buffer,0,1) != '#') {
1840 1840
 				$data = array();
1841 1841
 				//echo $buffer."\n";
1842 1842
 				$line = explode(' ',$buffer);
1843 1843
 				if (count($line) === 11) {
1844
-				    $userserver = explode('@',$line[0]);
1845
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1846
-				    $data['ident'] = $userserver[0];
1847
-				    $data['registration'] = $userserver[0];
1848
-				    $data['latitude'] = $line[4];
1849
-				    $data['longitude'] = $line[5];
1850
-				    $data['altitude'] = $line[6];
1851
-				    $data['datetime'] = date('Y-m-d H:i:s');
1852
-				    $aircraft_type = $line[10];
1853
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1854
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1855
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1856
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1844
+					$userserver = explode('@',$line[0]);
1845
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1846
+					$data['ident'] = $userserver[0];
1847
+					$data['registration'] = $userserver[0];
1848
+					$data['latitude'] = $line[4];
1849
+					$data['longitude'] = $line[5];
1850
+					$data['altitude'] = $line[6];
1851
+					$data['datetime'] = date('Y-m-d H:i:s');
1852
+					$aircraft_type = $line[10];
1853
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1854
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1855
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1856
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1857
+				}
1857 1858
 				}
1858
-			    }
1859 1859
 			} elseif ($format === 'beast') {
1860
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1861
-			    die;
1860
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1861
+				die;
1862 1862
 			} elseif ($format === 'vrstcp') {
1863
-			    foreach($buffer as $all_data) {
1863
+				foreach($buffer as $all_data) {
1864 1864
 				$line = json_decode('{'.$all_data.'}',true);
1865 1865
 				$data = array();
1866 1866
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1880,158 +1880,158 @@  discard block
 block discarded – undo
1880 1880
 				*/
1881 1881
 				$data['datetime'] = date('Y-m-d H:i:s');
1882 1882
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1883
-		    		$data['format_source'] = 'vrstcp';
1883
+					$data['format_source'] = 'vrstcp';
1884 1884
 				$data['id_source'] = $id_source;
1885 1885
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1886 1886
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1887 1887
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1888 1888
 				unset($data);
1889
-			    }
1889
+				}
1890 1890
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1891
-			    $line = explode("\t", $buffer);
1892
-			    for($k = 0; $k < count($line); $k=$k+2) {
1891
+				$line = explode("\t", $buffer);
1892
+				for($k = 0; $k < count($line); $k=$k+2) {
1893 1893
 				$key = $line[$k];
1894
-			        $lined[$key] = $line[$k+1];
1895
-			    }
1896
-    			    if (count($lined) > 3) {
1897
-    				$data['hex'] = $lined['hexid'];
1898
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1899
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1900
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1901
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1902
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1903
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1904
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1905
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1906
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1907
-    				$data['id_source'] = $id_source;
1908
-    				$data['format_source'] = 'tsv';
1909
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1910
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1894
+					$lined[$key] = $line[$k+1];
1895
+				}
1896
+					if (count($lined) > 3) {
1897
+					$data['hex'] = $lined['hexid'];
1898
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1899
+					$data['datetime'] = date('Y-m-d H:i:s');;
1900
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1901
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1902
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1903
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1904
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1905
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1906
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1907
+					$data['id_source'] = $id_source;
1908
+					$data['format_source'] = 'tsv';
1909
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1910
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1911 1911
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1912
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1913
-    				unset($lined);
1914
-    				unset($data);
1915
-    			    } else $error = true;
1912
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1913
+					unset($lined);
1914
+					unset($data);
1915
+					} else $error = true;
1916 1916
 			} elseif ($format === 'aprs' && $use_aprs) {
1917
-			    if ($aprs_connect === 0) {
1917
+				if ($aprs_connect === 0) {
1918 1918
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1919 1919
 				$aprs_connect = 1;
1920
-			    }
1920
+				}
1921 1921
 			    
1922
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1922
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1923 1923
 				$aprs_last_tx = time();
1924 1924
 				$data_aprs = "# Keep alive";
1925 1925
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1926
-			    }
1926
+				}
1927 1927
 			    
1928
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1929
-			    //echo 'APRS data : '.$buffer."\n";
1930
-			    $buffer = str_replace('APRS <- ','',$buffer);
1931
-			    $buffer = str_replace('APRS -> ','',$buffer);
1932
-			    //echo $buffer."\n";
1933
-			    date_default_timezone_set('UTC');
1934
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1928
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1929
+				//echo 'APRS data : '.$buffer."\n";
1930
+				$buffer = str_replace('APRS <- ','',$buffer);
1931
+				$buffer = str_replace('APRS -> ','',$buffer);
1932
+				//echo $buffer."\n";
1933
+				date_default_timezone_set('UTC');
1934
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1935 1935
 				$line = $APRS->parse($buffer);
1936 1936
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1937 1937
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1938
-				    $aprs_last_tx = time();
1939
-				    $data = array();
1940
-				    //print_r($line);
1941
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1942
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1943
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1944
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1945
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1946
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1947
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1948
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1949
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1950
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1951
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1952
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1953
-				    $data['latitude'] = $line['latitude'];
1954
-				    $data['longitude'] = $line['longitude'];
1955
-				    //$data['verticalrate'] = $line[16];
1956
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1957
-				    //else $data['speed'] = 0;
1958
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1959
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1960
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1961
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1938
+					$aprs_last_tx = time();
1939
+					$data = array();
1940
+					//print_r($line);
1941
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1942
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1943
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1944
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1945
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1946
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1947
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1948
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1949
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1950
+					else $data['datetime'] = date('Y-m-d H:i:s');
1951
+					//$data['datetime'] = date('Y-m-d H:i:s');
1952
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1953
+					$data['latitude'] = $line['latitude'];
1954
+					$data['longitude'] = $line['longitude'];
1955
+					//$data['verticalrate'] = $line[16];
1956
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1957
+					//else $data['speed'] = 0;
1958
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1959
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1960
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1961
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1962 1962
 				    
1963
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1964
-				    //else echo 'No heading...'."\n";
1965
-				    //else $data['heading'] = 0;
1966
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1967
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1968
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1969
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1970
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1971
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1972
-    				    $data['id_source'] = $id_source;
1973
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1974
-				    else $data['format_source'] = 'aprs';
1975
-				    $data['source_name'] = $line['source'];
1976
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1977
-				    else $data['source_type'] = 'flarm';
1978
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1979
-				    $currentdate = date('Y-m-d H:i:s');
1980
-				    $aprsdate = strtotime($data['datetime']);
1981
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1982
-				    // Accept data if time <= system time + 20s
1983
-				    //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'])))) {
1984
-				    if (
1963
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1964
+					//else echo 'No heading...'."\n";
1965
+					//else $data['heading'] = 0;
1966
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1967
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1968
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1969
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1970
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1971
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1972
+						$data['id_source'] = $id_source;
1973
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1974
+					else $data['format_source'] = 'aprs';
1975
+					$data['source_name'] = $line['source'];
1976
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1977
+					else $data['source_type'] = 'flarm';
1978
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1979
+					$currentdate = date('Y-m-d H:i:s');
1980
+					$aprsdate = strtotime($data['datetime']);
1981
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1982
+					// Accept data if time <= system time + 20s
1983
+					//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'])))) {
1984
+					if (
1985 1985
 					($data['source_type'] === 'modes') || 
1986 1986
 					isset($line['stealth']) && 
1987 1987
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1988 1988
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1989 1989
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1990 1990
 					$send = $SI->add($data);
1991
-				    } elseif ($data['source_type'] === 'ais') {
1991
+					} elseif ($data['source_type'] === 'ais') {
1992 1992
 					$data['type'] = '';
1993 1993
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1994
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1994
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1995 1995
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1996
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1997
-					    //$line['symbol'] === 'Balloon' ||
1998
-					    $line['symbol'] === 'Glider' || 
1999
-					    $line['symbol'] === 'No. Plane' || 
2000
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
2001
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
2002
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2003
-					    $send = $SI->add($data);
2004
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
2005
-					    $line['symbol'] === 'Yacht (Sail)' || 
2006
-					    $line['symbol'] === 'Ship (Power Boat)')) {
2007
-					    $send = $MI->add($data);
2008
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
2009
-					    $line['symbol'] === 'Car' || 
2010
-					    $line['symbol'] === 'Ambulance' || 
2011
-					    $line['symbol'] === 'Van' || 
2012
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
2013
-					    $line['symbol'] === 'Motorcycle' || 
2014
-					    $line['symbol'] === 'Tractor' || 
2015
-					    $line['symbol'] === 'Police' || 
2016
-					    $line['symbol'] === 'Bike' || 
2017
-					    $line['symbol'] === 'Jogger' || 
2018
-					    $line['symbol'] === 'Horse' || 
2019
-					    $line['symbol'] === 'Bus' || 
2020
-					    $line['symbol'] === 'Jeep' || 
2021
-					    $line['symbol'] === 'Recreational Vehicle' || 
2022
-					    $line['symbol'] === 'Yacht (Sail)' || 
2023
-					    $line['symbol'] === 'Ship (Power Boat)' || 
2024
-					    $line['symbol'] === 'Firetruck' || 
2025
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
2026
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
2027
-					    $line['symbol'] === 'SUV' ||
2028
-					    $line['symbol'] === 'Snowmobile' ||
2029
-					    $line['symbol'] === 'Mobile Satellite Station')) {
2030
-				    //} 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') {
1996
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1997
+						//$line['symbol'] === 'Balloon' ||
1998
+						$line['symbol'] === 'Glider' || 
1999
+						$line['symbol'] === 'No. Plane' || 
2000
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
2001
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
2002
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2003
+						$send = $SI->add($data);
2004
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
2005
+						$line['symbol'] === 'Yacht (Sail)' || 
2006
+						$line['symbol'] === 'Ship (Power Boat)')) {
2007
+						$send = $MI->add($data);
2008
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
2009
+						$line['symbol'] === 'Car' || 
2010
+						$line['symbol'] === 'Ambulance' || 
2011
+						$line['symbol'] === 'Van' || 
2012
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
2013
+						$line['symbol'] === 'Motorcycle' || 
2014
+						$line['symbol'] === 'Tractor' || 
2015
+						$line['symbol'] === 'Police' || 
2016
+						$line['symbol'] === 'Bike' || 
2017
+						$line['symbol'] === 'Jogger' || 
2018
+						$line['symbol'] === 'Horse' || 
2019
+						$line['symbol'] === 'Bus' || 
2020
+						$line['symbol'] === 'Jeep' || 
2021
+						$line['symbol'] === 'Recreational Vehicle' || 
2022
+						$line['symbol'] === 'Yacht (Sail)' || 
2023
+						$line['symbol'] === 'Ship (Power Boat)' || 
2024
+						$line['symbol'] === 'Firetruck' || 
2025
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
2026
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
2027
+						$line['symbol'] === 'SUV' ||
2028
+						$line['symbol'] === 'Snowmobile' ||
2029
+						$line['symbol'] === 'Mobile Satellite Station')) {
2030
+					//} 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') {
2031 2031
 				//    } 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') {
2032 2032
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
2033 2033
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2034
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2034
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2035 2035
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
2036 2036
 					$Source->deleteOldLocationByType('gs');
2037 2037
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
 					} else {
2040 2040
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2041 2041
 					}
2042
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2042
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2043 2043
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2044 2044
 					if ($globalDebug) echo '# Weather Station added'."\n";
2045 2045
 					$Source->deleteOldLocationByType('wx');
@@ -2049,7 +2049,7 @@  discard block
 block discarded – undo
2049 2049
 					} else {
2050 2050
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2051 2051
 					}
2052
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2052
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2053 2053
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2054 2054
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2055 2055
 					$Source->deleteOldLocationByType('lightning');
@@ -2058,11 +2058,11 @@  discard block
 block discarded – undo
2058 2058
 					} else {
2059 2059
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2060 2060
 					}
2061
-				    } elseif ($globalDebug) {
2062
-				    	echo '/!\ Not added: '.$buffer."\n";
2063
-				    	print_r($line);
2064
-				    }
2065
-				    unset($data);
2061
+					} elseif ($globalDebug) {
2062
+						echo '/!\ Not added: '.$buffer."\n";
2063
+						print_r($line);
2064
+					}
2065
+					unset($data);
2066 2066
 				}
2067 2067
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2068 2068
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -2081,13 +2081,13 @@  discard block
 block discarded – undo
2081 2081
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
2082 2082
 					$globalSources[$nb]['last_weather_clean'] = time();
2083 2083
 				}
2084
-			    }
2084
+				}
2085 2085
 			} else {
2086
-			    $line = explode(',', $buffer);
2087
-			    //print_r($line);
2088
-    			    if (count($line) > 20) {
2089
-    			    	$data['hex'] = $line[4];
2090
-    				/*
2086
+				$line = explode(',', $buffer);
2087
+				//print_r($line);
2088
+					if (count($line) > 20) {
2089
+						$data['hex'] = $line[4];
2090
+					/*
2091 2091
     				$data['datetime'] = $line[6].' '.$line[7];
2092 2092
     					date_default_timezone_set($globalTimezone);
2093 2093
     					$datetime = new DateTime($data['datetime']);
@@ -2095,31 +2095,31 @@  discard block
 block discarded – undo
2095 2095
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
2096 2096
     					date_default_timezone_set('UTC');
2097 2097
     				*/
2098
-    				// Force datetime to current UTC datetime
2099
-    				date_default_timezone_set('UTC');
2100
-    				$data['datetime'] = date('Y-m-d H:i:s');
2101
-    				$data['ident'] = trim($line[10]);
2102
-    				$data['latitude'] = $line[14];
2103
-    				$data['longitude'] = $line[15];
2104
-    				$data['verticalrate'] = $line[16];
2105
-    				$data['emergency'] = $line[20];
2106
-    				$data['speed'] = $line[12];
2107
-    				$data['squawk'] = $line[17];
2108
-    				$data['altitude'] = $line[11];
2109
-    				$data['heading'] = $line[13];
2110
-    				$data['ground'] = $line[21];
2111
-    				$data['emergency'] = $line[19];
2112
-    				$data['format_source'] = 'sbs';
2098
+					// Force datetime to current UTC datetime
2099
+					date_default_timezone_set('UTC');
2100
+					$data['datetime'] = date('Y-m-d H:i:s');
2101
+					$data['ident'] = trim($line[10]);
2102
+					$data['latitude'] = $line[14];
2103
+					$data['longitude'] = $line[15];
2104
+					$data['verticalrate'] = $line[16];
2105
+					$data['emergency'] = $line[20];
2106
+					$data['speed'] = $line[12];
2107
+					$data['squawk'] = $line[17];
2108
+					$data['altitude'] = $line[11];
2109
+					$data['heading'] = $line[13];
2110
+					$data['ground'] = $line[21];
2111
+					$data['emergency'] = $line[19];
2112
+					$data['format_source'] = 'sbs';
2113 2113
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2114 2114
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2115 2115
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2116 2116
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2117
-    				$data['id_source'] = $id_source;
2118
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2119
-    				else $error = true;
2120
-    				unset($data);
2121
-    			    } else $error = true;
2122
-			    if ($error) {
2117
+					$data['id_source'] = $id_source;
2118
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2119
+					else $error = true;
2120
+					unset($data);
2121
+					} else $error = true;
2122
+				if ($error) {
2123 2123
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2124 2124
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
2125 2125
 				} else {
@@ -2135,13 +2135,13 @@  discard block
 block discarded – undo
2135 2135
 					connect_all($sourceer);
2136 2136
 					$sourceer = array();
2137 2137
 				}
2138
-			    }
2138
+				}
2139 2139
 			}
2140 2140
 			// Sleep for xxx microseconds
2141 2141
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2142
-		    } else {
2142
+			} else {
2143 2143
 			if ($format === 'flightgearmp') {
2144
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2144
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
2145 2145
 				//@socket_close($r);
2146 2146
 				sleep($globalMinFetch);
2147 2147
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2150,9 +2150,9 @@  discard block
 block discarded – undo
2150 2150
 				break;
2151 2151
 				
2152 2152
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2153
-			    if (isset($tt[$format])) $tt[$format]++;
2154
-			    else $tt[$format] = 0;
2155
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
2153
+				if (isset($tt[$format])) $tt[$format]++;
2154
+				else $tt[$format] = 0;
2155
+				if ($tt[$format] > 30 || $buffer === FALSE) {
2156 2156
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2157 2157
 				//@socket_close($r);
2158 2158
 				sleep(2);
@@ -2163,24 +2163,24 @@  discard block
 block discarded – undo
2163 2163
 				//connect_all($globalSources);
2164 2164
 				$tt[$format]=0;
2165 2165
 				break;
2166
-			    } 
2167
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2166
+				} 
2167
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2168
+			}
2168 2169
 			}
2169
-		    }
2170 2170
 		}
2171
-	    } else {
2171
+		} else {
2172 2172
 		$error = socket_strerror(socket_last_error());
2173 2173
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2174 2174
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2175 2175
 			if (isset($globalDebug)) echo "Restarting...\n";
2176 2176
 			// Restart the script if possible
2177 2177
 			if (is_array($sockets)) {
2178
-			    if ($globalDebug) echo "Shutdown all sockets...";
2178
+				if ($globalDebug) echo "Shutdown all sockets...";
2179 2179
 			    
2180
-			    foreach ($sockets as $sock) {
2180
+				foreach ($sockets as $sock) {
2181 2181
 				@socket_shutdown($sock,2);
2182 2182
 				@socket_close($sock);
2183
-			    }
2183
+				}
2184 2184
 			    
2185 2185
 			}
2186 2186
 			if ($globalDebug) echo "Waiting...";
@@ -2195,15 +2195,15 @@  discard block
 block discarded – undo
2195 2195
 			if ($globalDebug) echo "Restart all connections...";
2196 2196
 			connect_all($globalSources);
2197 2197
 		}
2198
-	    }
2198
+		}
2199 2199
 	}
2200 2200
 	if ($globalDaemon === false) {
2201
-	    if ($globalDebug) echo 'Check all...'."\n";
2202
-	    if (isset($SI)) $SI->checkAll();
2203
-	    if (isset($TI)) $TI->checkAll();
2204
-	    if (isset($MI)) $MI->checkAll();
2201
+		if ($globalDebug) echo 'Check all...'."\n";
2202
+		if (isset($SI)) $SI->checkAll();
2203
+		if (isset($TI)) $TI->checkAll();
2204
+		if (isset($MI)) $MI->checkAll();
2205
+	}
2205 2206
 	}
2206
-    }
2207 2207
 }
2208 2208
 
2209 2209
 ?>
Please login to merge, or discard this patch.
Spacing   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 	    die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
62
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
63 63
     }
64 64
 }
65 65
 
66
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
66
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70 70
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
71
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
72 72
     else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74 74
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
76 76
     else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115 115
     if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
116
+    $SI = new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
120 120
     $SI->connect();
121 121
 */
122
-} else $SI=new SpotterImport($Connection->db);
122
+} else $SI = new SpotterImport($Connection->db);
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     $MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136
-$SBS=new SBS();
136
+$SBS = new SBS();
137 137
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
-	$ACARS=new ACARS($Connection->db,true);
139
-	$Source=new Source($Connection->db);
138
+	$ACARS = new ACARS($Connection->db, true);
139
+	$Source = new Source($Connection->db);
140 140
 }
141
-$Common=new Common();
141
+$Common = new Common();
142 142
 date_default_timezone_set('UTC');
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
146
+    pcntl_signal(SIGINT, function() {
147 147
         global $sockets;
148 148
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149 149
         die("Bye!\n");
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
 function connect_all($hosts) {
161 161
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
162
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
163 163
     $reset++;
164 164
     if ($globalDebug) echo 'Connect to all...'."\n";
165 165
     foreach ($hosts as $id => $value) {
@@ -167,33 +167,33 @@  discard block
 block discarded – undo
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
170
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
+            if (preg_match('/deltadb.txt$/i', $host)) {
172 172
         	//$formats[$id] = 'deltadbtxt';
173 173
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 174
         	//$last_exec['deltadbtxt'] = 0;
175 175
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
177 177
         	//$formats[$id] = 'vatsimtxt';
178 178
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 179
         	//$last_exec['vatsimtxt'] = 0;
180 180
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
186
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftjson';
188 188
         	$globalSources[$id]['format'] = 'aircraftjson';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
190 190
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
191
+    	    } else if (preg_match('/aircraft$/i', $host)) {
192 192
         	//$formats[$id] = 'planefinderclient';
193 193
         	$globalSources[$id]['format'] = 'planefinderclient';
194 194
         	//$last_exec['aircraftlistjson'] = 0;
195 195
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
196
+    	    } else if (preg_match('/opensky/i', $host)) {
197 197
         	//$formats[$id] = 'aircraftlistjson';
198 198
         	$globalSources[$id]['format'] = 'opensky';
199 199
         	//$last_exec['aircraftlistjson'] = 0;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
213
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
214 214
         	//$formats[$id] = 'planeupdatefaa';
215 215
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 216
         	//$last_exec['planeupdatefaa'] = 0;
@@ -219,37 +219,37 @@  discard block
 block discarded – undo
219 219
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 220
         	    exit(0);
221 221
         	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
222
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'phpvmacars';
225 225
         	//$last_exec['phpvmacars'] = 0;
226 226
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
228 228
         	//$formats[$id] = 'phpvmacars';
229 229
         	$globalSources[$id]['format'] = 'vaos';
230 230
         	//$last_exec['phpvmacars'] = 0;
231 231
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
232
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
233 233
         	//$formats[$id] = 'phpvmacars';
234 234
         	$globalSources[$id]['format'] = 'vam';
235 235
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
236
+            } else if (preg_match('/whazzup/i', $host)) {
237 237
         	//$formats[$id] = 'whazzup';
238 238
         	$globalSources[$id]['format'] = 'whazzup';
239 239
         	//$last_exec['whazzup'] = 0;
240 240
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
241
+            } else if (preg_match('/blitzortung/i', $host)) {
242 242
         	$globalSources[$id]['format'] = 'blitzortung';
243 243
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
244
+            } else if (preg_match('/airwhere/i', $host)) {
245 245
         	$globalSources[$id]['format'] = 'airwhere';
246 246
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
247
+            } else if (preg_match('/recentpireps/i', $host)) {
248 248
         	//$formats[$id] = 'pirepsjson';
249 249
         	$globalSources[$id]['format'] = 'pirepsjson';
250 250
         	//$last_exec['pirepsjson'] = 0;
251 251
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
253 253
         	//$formats[$id] = 'fr24json';
254 254
         	$globalSources[$id]['format'] = 'fr24json';
255 255
         	//$last_exec['fr24json'] = 0;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 259
         	    exit(0);
260 260
         	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
261
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
262 262
         	//$formats[$id] = 'fr24json';
263 263
         	$globalSources[$id]['format'] = 'myshiptracking';
264 264
         	//$last_exec['fr24json'] = 0;
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
         	    exit(0);
269 269
         	}
270 270
             //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 272
         	//$formats[$id] = 'tsv';
273 273
         	$globalSources[$id]['format'] = 'tsv';
274 274
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275 275
             }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 277
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
279 279
     		    if ($idf !== false) {
280 280
     			$httpfeeds[$id] = $idf;
281 281
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284 284
     		elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285 285
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
286
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287
-	    $hostport = explode(':',$host);
286
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
287
+	    $hostport = explode(':', $host);
288 288
 	    if (isset($hostport[1])) {
289 289
 		$port = $hostport[1];
290 290
 		$hostn = $hostport[0];
@@ -294,20 +294,20 @@  discard block
 block discarded – undo
294 294
 	    }
295 295
 	    $Common = new Common();
296 296
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
297
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
297
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
298 298
     	    } else {
299 299
     		$udp = true;
300
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
300
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
301 301
 	    }
302 302
 	    if ($s) {
303 303
     	        $sockets[$id] = $s;
304 304
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
305
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
305
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
306 306
 			//$formats[$id] = 'aprs';
307 307
 			$globalSources[$id]['format'] = 'aprs';
308 308
 			//$aprs_connect = 0;
309 309
 			//$use_aprs = true;
310
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
311 311
 			$globalSources[$id]['format'] = 'vrstcp';
312 312
     		    } elseif ($port == '10001') {
313 313
         		//$formats[$id] = 'tsv';
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
350 350
 else $timeout = 20;
351 351
 $errno = '';
352
-$errstr='';
352
+$errstr = '';
353 353
 
354 354
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
355 355
 /* Initiate connections to all the hosts simultaneously */
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 //connect_all($globalSources);
358 358
 
359 359
 if (isset($globalProxy) && $globalProxy) {
360
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
360
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
361 361
 } else {
362 362
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
363 363
 }
@@ -387,16 +387,16 @@  discard block
 block discarded – undo
387 387
 
388 388
 if ($use_aprs) {
389 389
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
390
-	$APRS=new APRS();
390
+	$APRS = new APRS();
391 391
 	$aprs_connect = 0;
392 392
 	$aprs_keep = 120;
393 393
 	$aprs_last_tx = time();
394 394
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
395
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
395
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
396 396
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
397
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
397
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
398 398
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
399
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
399
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
400 400
 	if ($aprs_full) $aprs_filter = '';
401 401
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
402 402
 	else $aprs_pass = '-1';
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 sleep(1);
411 411
 if ($globalDebug) echo "SCAN MODE \n\n";
412 412
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
413
-$endtime = time()+$globalCronEnd;
413
+$endtime = time() + $globalCronEnd;
414 414
 $i = 1;
415 415
 $tt = array();
416 416
 // Delete all ATC
417 417
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
418
-	$ATC=new ATC($Connection->db);
418
+	$ATC = new ATC($Connection->db);
419 419
 }
420 420
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
421 421
 	$ATC->deleteAll();
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 while ($i > 0) {
426 426
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
427 427
 
428
-    if (!$globalDaemon) $i = $endtime-time();
428
+    if (!$globalDaemon) $i = $endtime - time();
429 429
     // Delete old ATC
430 430
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
431 431
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	}
440 440
 	if ($max < $globalMinFetch) {
441 441
 	    if ($globalDebug) echo 'Sleeping...'."\n";
442
-	    sleep($globalMinFetch-$max+2);
442
+	    sleep($globalMinFetch - $max + 2);
443 443
 	}
444 444
     }
445 445
 
@@ -494,10 +494,10 @@  discard block
 block discarded – undo
494 494
             //$buffer = $Common->getData($hosts[$id]);
495 495
             $buffer = $Common->getData($value['host']);
496 496
             if ($buffer != '') {
497
-                $all_data = json_decode($buffer,true);
497
+                $all_data = json_decode($buffer, true);
498 498
                 foreach ($all_data as $line) {
499 499
                     $data = array();
500
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
500
+                    $data['datetime'] = date('Y-m-d H:i:s', $line['uti']);
501 501
                     $data['hex'] = $line['hex']; // hex
502 502
                     $data['ident'] = $line['fli']; // ident
503 503
                     $data['altitude'] = $line['alt']; // altitude
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 	    )
533 533
 	) {
534 534
 	    date_default_timezone_set('CET');
535
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
536 536
 	    date_default_timezone_set('UTC');
537 537
 	    if ($buffer != '') $reset = 0;
538
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
-	    $buffer = explode('\n',$buffer);
538
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
539
+	    $buffer = explode('\n', $buffer);
540 540
 	    foreach ($buffer as $line) {
541 541
 		if ($line != '') {
542 542
 		    //echo "'".$line."'\n";
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		    $ais_data = $AIS->parse_line(trim($line));
545 545
 		    $data = array();
546 546
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
548 548
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549 549
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550 550
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557 557
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
558 558
 		    if (isset($ais_data['timestamp'])) {
559
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
559
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
560 560
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
561 561
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
562 562
 			    $add = true;
@@ -579,21 +579,21 @@  discard block
 block discarded – undo
579 579
 	    $w = $e = null;
580 580
 	    
581 581
 	    if (isset($arr[$id])) {
582
-		$nn = stream_select($arr,$w,$e,$timeout);
582
+		$nn = stream_select($arr, $w, $e, $timeout);
583 583
 		if ($nn > 0) {
584 584
 		    foreach ($httpfeeds as $feed) {
585
-			$buffer = stream_get_line($feed,2000,"\n");
585
+			$buffer = stream_get_line($feed, 2000, "\n");
586 586
 			if ($buffer === FALSE) {
587 587
 			    connect_all($globalSources);
588 588
 			}
589
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
590
-			$buffer = explode('\n',$buffer);
589
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
590
+			$buffer = explode('\n', $buffer);
591 591
 			foreach ($buffer as $line) {
592 592
 			    if ($line != '') {
593 593
 				$ais_data = $AIS->parse_line(trim($line));
594 594
 				$data = array();
595 595
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
596
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
596
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
597 597
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
598 598
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
599 599
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
606 606
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
607 607
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
608
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
608
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
609 609
 				if (isset($ais_data['timestamp'])) {
610
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
611 611
 				} else {
612 612
 				    $data['datetime'] = date('Y-m-d H:i:s');
613 613
 				}
@@ -639,10 +639,10 @@  discard block
 block discarded – undo
639 639
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
640 640
 	    )
641 641
 	) {
642
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
642
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
643 643
 	    if ($buffer != '') {
644 644
 		//echo $buffer;
645
-		$all_data = json_decode($buffer,true);
645
+		$all_data = json_decode($buffer, true);
646 646
 		//print_r($all_data);
647 647
 		if (isset($all_data[0]['DATA'])) {
648 648
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 			    $data['ident'] = $line['NAME'];
652 652
 			    $data['mmsi'] = $line['MMSI'];
653 653
 			    if (strlen($data['mmsi']) > 9) {
654
-				$data['mmsi'] = substr($data['mmsi'],-9);
654
+				$data['mmsi'] = substr($data['mmsi'], -9);
655 655
 			    }
656 656
 			    $data['speed'] = $line['SOG'];
657 657
 			    $data['heading'] = $line['COG'];
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
 			    //$data['type_id'] = $line['TYPE'];
662 662
 			    $data['imo'] = $line['IMO'];
663 663
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
665
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
664
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
665
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
666 666
 			    $data['format_source'] = 'myshiptracking';
667 667
 			    $data['id_source'] = $id_source;
668 668
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -679,16 +679,16 @@  discard block
 block discarded – undo
679 679
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
680 680
 	    )
681 681
 	) {
682
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
682
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
683 683
 	    if ($buffer != '') {
684
-		$all_data = json_decode($buffer,true);
684
+		$all_data = json_decode($buffer, true);
685 685
 		if (isset($all_data[0]['mmsi'])) {
686 686
 		    foreach ($all_data as $line) {
687 687
 			if ($line != '') {
688 688
 			    $data = array();
689 689
 			    $data['ident'] = $line['shipname'];
690 690
 			    $data['callsign'] = $line['callsign'];
691
-			    $data['mmsi'] = substr($line['mmsi'],-9);
691
+			    $data['mmsi'] = substr($line['mmsi'], -9);
692 692
 			    $data['speed'] = $line['sog'];
693 693
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
694 694
 			    $data['latitude'] = $line['latitude'];
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 	) {
716 716
 	    $buffer = $Common->getData($value['host']);
717 717
 	    if ($buffer != '') {
718
-		$all_data = json_decode($buffer,true);
718
+		$all_data = json_decode($buffer, true);
719 719
 		if (isset($all_data['features'][0]['id'])) {
720 720
 		    foreach ($all_data['features'] as $line) {
721 721
 			print_r($line);
722 722
 			$data = array();
723 723
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
724 724
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
725
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
725
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
726 726
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
727 727
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
728 728
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -749,31 +749,31 @@  discard block
 block discarded – undo
749 749
 	    )
750 750
 	) {
751 751
 	    if ($globalDebug) echo 'download...';
752
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
753 753
 	    if ($globalDebug) echo 'done !'."\n";
754 754
 	    // FIXME: Need more work
755 755
 	    if ($buffer != '') $reset = 0;
756
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757
-	    $buffer = explode('\n',$buffer);
756
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
757
+	    $buffer = explode('\n', $buffer);
758 758
 	    foreach ($buffer as $line) {
759 759
 		if ($line != '') {
760 760
 		    $data = array();
761 761
 		    //echo $line."\n";
762
-		    $data['mmsi'] = (int)substr($line,0,9);
763
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
764
-		    $data['status_id'] = substr($line,21,2);
765
-		    $data['type_id'] = substr($line,24,3);
766
-		    $data['latitude'] = substr($line,29,9);
767
-		    $data['longitude'] = substr($line,41,9);
768
-		    $data['speed'] = round(substr($line,51,5));
762
+		    $data['mmsi'] = (int) substr($line, 0, 9);
763
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
764
+		    $data['status_id'] = substr($line, 21, 2);
765
+		    $data['type_id'] = substr($line, 24, 3);
766
+		    $data['latitude'] = substr($line, 29, 9);
767
+		    $data['longitude'] = substr($line, 41, 9);
768
+		    $data['speed'] = round(substr($line, 51, 5));
769 769
 		    //$data['course'] = substr($line,57,5);
770
-		    $data['heading'] = round(substr($line,63,3));
770
+		    $data['heading'] = round(substr($line, 63, 3));
771 771
 		    //$data['draft'] = substr($line,67,4);
772 772
 		    //$data['length'] = substr($line,72,3);
773 773
 		    //$data['beam'] = substr($line,76,2);
774
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
774
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
775 775
 		    //$data['callsign'] = trim(substr($line,100,7);
776
-		    $data['arrival_code'] = substr($line,108,20);
776
+		    $data['arrival_code'] = substr($line, 108, 20);
777 777
 		    //$data['etaDate'] = substr($line,129,5);
778 778
 		    //$data['etaTime'] = substr($line,135,5);
779 779
 		    $data['format_source'] = 'shipplotter';
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 	    )
793 793
 	) {
794 794
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
795
-		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
795
+		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true);
796 796
 		//echo $authsailaway;
797 797
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
798 798
 		if (isset($setcookie[1][0])) {
@@ -801,19 +801,19 @@  discard block
 block discarded – undo
801 801
 	    }
802 802
 
803 803
 	    if ($globalDebug) echo '! Download... ';
804
-	    for ($i =0; $i <= 1; $i++) {
804
+	    for ($i = 0; $i <= 1; $i++) {
805 805
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
806 806
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
807 807
 	    if ($globalDebug) echo 'done'."\n";
808 808
 	    if ($buffer != '') {
809
-		$all_data = json_decode($buffer,true);
809
+		$all_data = json_decode($buffer, true);
810 810
 		if (isset($all_data['missions'])) {
811 811
 			foreach ($all_data['missions'] as $mission) {
812 812
 				$mission_user = $mission['usrname'];
813
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
814
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
813
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
814
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
815 815
 					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
816
-						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
816
+						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
817 817
 						sleep(30);
818 818
 					} else $racebuffer = '';
819 819
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
@@ -822,19 +822,19 @@  discard block
 block discarded – undo
822 822
 					$racebuffer = '';
823 823
 				}
824 824
 				if ($racebuffer != '') {
825
-					$race_data = json_decode($racebuffer,true);
825
+					$race_data = json_decode($racebuffer, true);
826 826
 					//print_r($race_data);
827 827
 					unset($racebuffer);
828 828
 					if (isset($race_data['mission'])) {
829 829
 					    $datar = array();
830 830
 					    $datar['id'] = $mission['misnr'];
831 831
 					    $datar['desc'] = $race_data['mission']['misdescr'];
832
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
833
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
832
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
833
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
834 834
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
835 835
 					    $markers = array();
836 836
 					    foreach ($race_data['mission']['course'] as $course) {
837
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
837
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
838 838
 					    }
839 839
 					    $datar['markers'] = json_encode($markers);
840 840
 					    //print_r($datar);
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 					}
843 843
 				}
844 844
 				if ($bufferm != '') {
845
-					$mission_data = json_decode($bufferm,true);
845
+					$mission_data = json_decode($bufferm, true);
846 846
 					unset($bufferm);
847 847
 					if (isset($mission_data['leaderboard'][0]['results'])) {
848 848
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
856 856
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
857 857
 								$data['datetime'] = date('Y-m-d H:i:s');
858
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
858
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
859 859
 								$data['last_update'] = date('Y-m-d H:i:s');
860 860
 								$data['status'] = $sail['status'];
861 861
 								$data['type'] = $sail['btptype'];
@@ -866,16 +866,16 @@  discard block
 block discarded – undo
866 866
 									$data['longitude'] = $pos['longitude'];
867 867
 								}
868 868
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
869
-									$resultdescr = explode(',',$sail['resultdescr']);
869
+									$resultdescr = explode(',', $sail['resultdescr']);
870 870
 									if (count($resultdescr) > 2) {
871
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
872
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
871
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
872
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
873 873
 										if (isset($resultdescr[3])) {
874
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
874
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
875 875
 										}
876 876
 									}
877 877
 								}
878
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
878
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
879 879
 								$data['captain_id'] = $sail['usrnr'];
880 880
 								$data['captain_name'] = $sail['usrname'];
881 881
 								$data['race_id'] = $sail['misnr'];
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 	    if ($globalDebug) echo '! Download... ';
931 931
 	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key']);
932 932
 	    if ($buffer != '') {
933
-		$data = json_decode($buffer,true);
933
+		$data = json_decode($buffer, true);
934 934
 		//print_r($race_data);
935 935
 		if (isset($data['boats'])) {
936 936
 		    foreach ($data['boats'] as $sail) {
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 			$data['longitude'] = $sail['ubtlon'];
943 943
 			$data['type_id'] = 36;
944 944
 			$data['heading'] = $sail['ubtheading'];
945
-			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
945
+			$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
946 946
 			$data['captain_name'] = $sail['usrname'];
947 947
 			$data['format_source'] = 'sailaway';
948 948
 			$data['id_source'] = $id_source;
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 	) {
972 972
 	    //$buffer = $Common->getData($hosts[$id]);
973 973
 	    $buffer = $Common->getData($value['host']);
974
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
975
-	    $buffer = explode('\n',$buffer);
974
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
975
+	    $buffer = explode('\n', $buffer);
976 976
 	    $reset = 0;
977 977
 	    foreach ($buffer as $line) {
978 978
     		if ($line != '') {
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
984 984
 			$data['pilot_id'] = $line[1];
985 985
 			$data['pilot_name'] = $line[2];
986
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
986
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
987 987
 			$data['ident'] = $line[0]; // ident
988 988
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
989 989
 			$data['speed'] = $line[8]; // speed
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
1000 1000
 			//if (isset($line[37])) $data['last_update'] = $line[37];
1001 1001
 		        $data['departure_airport_icao'] = $line[11];
1002
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
1002
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
1003 1003
 		        $data['arrival_airport_icao'] = $line[13];
1004 1004
 			$data['frequency'] = $line[4];
1005 1005
 			$data['type'] = $line[18];
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
     			$data['id_source'] = $id_source;
1009 1009
 	    		//$data['arrival_airport_time'] = ;
1010 1010
 	    		if ($line[9] != '') {
1011
-	    		    $aircraft_data = explode('/',$line[9]);
1011
+	    		    $aircraft_data = explode('/', $line[9]);
1012 1012
 	    		    if (isset($aircraft_data[1])) {
1013 1013
 	    			$data['aircraft_icao'] = $aircraft_data[1];
1014 1014
 	    		    }
@@ -1023,9 +1023,9 @@  discard block
 block discarded – undo
1023 1023
     			if ($line[3] === 'PILOT') $SI->add($data);
1024 1024
 			elseif ($line[3] === 'ATC') {
1025 1025
 				//print_r($data);
1026
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1027
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
1028
-				$typec = substr($data['ident'],-3);
1026
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1027
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1028
+				$typec = substr($data['ident'], -3);
1029 1029
 				if ($typec === 'APP') $data['type'] = 'Approach';
1030 1030
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
1031 1031
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -1037,8 +1037,8 @@  discard block
 block discarded – undo
1037 1037
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
1038 1038
 				if (!isset($data['source_name'])) $data['source_name'] = '';
1039 1039
 				if (isset($ATC)) {
1040
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($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']);
1041
-					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']);
1040
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($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']);
1041
+					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']);
1042 1042
 				}
1043 1043
 			}
1044 1044
     			unset($data);
@@ -1054,24 +1054,24 @@  discard block
 block discarded – undo
1054 1054
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1055 1055
     	    )
1056 1056
     	) {
1057
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1057
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1058 1058
 	    if ($buffer != '') {
1059 1059
 		$all_data = simplexml_load_string($buffer);
1060
-		foreach($all_data->children() as $childdata) {
1060
+		foreach ($all_data->children() as $childdata) {
1061 1061
 			$data = array();
1062 1062
 			$line = $childdata;
1063 1063
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1064
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1065
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1066
-			$data['latitude'] = (float)$line['pktLatitude'];
1067
-			$data['longitude'] = (float)$line['pktLongitude'];
1068
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1069
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1070
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1064
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1065
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1066
+			$data['latitude'] = (float) $line['pktLatitude'];
1067
+			$data['longitude'] = (float) $line['pktLongitude'];
1068
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1069
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1070
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1071 1071
 			$data['altitude_relative'] = 'AMSL';
1072
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1072
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1073 1073
 			$data['aircraft_icao'] = 'PARAGLIDER';
1074
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1074
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1075 1075
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1076 1076
 			$data['format_source'] = $value['format'];
1077 1077
 			$SI->add($data);
@@ -1079,22 +1079,22 @@  discard block
 block discarded – undo
1079 1079
 		}
1080 1080
 	    }
1081 1081
 	    $Source->deleteOldLocationByType('gs');
1082
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1082
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1083 1083
 	    if ($buffer != '') {
1084 1084
 		$all_data = simplexml_load_string($buffer);
1085
-		foreach($all_data->children() as $childdata) {
1085
+		foreach ($all_data->children() as $childdata) {
1086 1086
 			$data = array();
1087 1087
 			$line = $childdata;
1088
-			$data['id'] = (int)$line['gsID'];
1089
-			$data['latitude'] = (float)$line['gsLatitude'];
1090
-			$data['longitude'] = (float)$line['gsLongitude'];
1091
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1088
+			$data['id'] = (int) $line['gsID'];
1089
+			$data['latitude'] = (float) $line['gsLatitude'];
1090
+			$data['longitude'] = (float) $line['gsLongitude'];
1091
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1092 1092
 			$data['altitude_relative'] = 'AMSL';
1093
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1093
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1094 1094
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1095
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1095
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1096 1096
 			} else {
1097
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1097
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1098 1098
 			}
1099 1099
 			unset($data);
1100 1100
 		}
@@ -1112,9 +1112,9 @@  discard block
 block discarded – undo
1112 1112
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1113 1113
 	    )
1114 1114
 	) {
1115
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1115
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1116 1116
 	    if ($buffer != '') {
1117
-	        $all_data = json_decode($buffer,true);
1117
+	        $all_data = json_decode($buffer, true);
1118 1118
 		if (isset($all_data['acList'])) {
1119 1119
 		    $reset = 0;
1120 1120
 		    foreach ($all_data['acList'] as $line) {
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1131 1131
 			$data['emergency'] = ''; // emergency
1132 1132
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1133
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1133
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1134 1134
 			else $data['datetime'] = date('Y-m-d H:i:s');
1135 1135
 			//$data['datetime'] = date('Y-m-d H:i:s');
1136 1136
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1156 1156
 			$data['squawk'] = $line['squawk']; // squawk
1157 1157
 			$data['emergency'] = ''; // emergency
1158
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1158
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1159 1159
 			else $data['datetime'] = date('Y-m-d H:i:s');
1160 1160
 			$data['format_source'] = 'aircraftlistjson';
1161 1161
 			$data['id_source'] = $id_source;
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
     	    )
1177 1177
     	) {
1178 1178
 	    $buffer = $Common->getData($value['host']);
1179
-	    $all_data = json_decode($buffer,true);
1179
+	    $all_data = json_decode($buffer, true);
1180 1180
 	    if (isset($all_data['planes'])) {
1181 1181
 		$reset = 0;
1182 1182
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1193,12 +1193,12 @@  discard block
 block discarded – undo
1193 1193
 		    $data['emergency'] = ''; // emergency
1194 1194
 		    $data['registration'] = $line[2];
1195 1195
 		    $data['aircraft_icao'] = $line[0];
1196
-		    $deparr = explode('-',$line[1]);
1196
+		    $deparr = explode('-', $line[1]);
1197 1197
 		    if (count($deparr) === 2) {
1198 1198
 			$data['departure_airport_icao'] = $deparr[0];
1199 1199
 			$data['arrival_airport_icao'] = $deparr[1];
1200 1200
 		    }
1201
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1201
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1202 1202
 	    	    $data['format_source'] = 'planeupdatefaa';
1203 1203
     		    $data['id_source'] = $id_source;
1204 1204
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 	    )
1217 1217
 	) {
1218 1218
 	    $buffer = $Common->getData($value['host']);
1219
-	    $all_data = json_decode($buffer,true);
1219
+	    $all_data = json_decode($buffer, true);
1220 1220
 	    if (isset($all_data['states'])) {
1221 1221
 		$reset = 0;
1222 1222
 		foreach ($all_data['states'] as $key => $line) {
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 		    //$data['emergency'] = ''; // emergency
1234 1234
 		    //$data['registration'] = $line[2];
1235 1235
 		    //$data['aircraft_icao'] = $line[0];
1236
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1236
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1237 1237
 		    $data['format_source'] = 'opensky';
1238 1238
 		    $data['id_source'] = $id_source;
1239 1239
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1250,8 +1250,8 @@  discard block
 block discarded – undo
1250 1250
 	    )
1251 1251
 	) {
1252 1252
 	    $buffer = $Common->getData($value['host']);
1253
-	    $all_data = json_decode($buffer,true);
1254
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1253
+	    $all_data = json_decode($buffer, true);
1254
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1255 1255
 		$reset = 0;
1256 1256
 		foreach ($all_data['aircraft'] as $key => $line) {
1257 1257
 		    $data = array();
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
 	    )
1290 1290
 	) {
1291 1291
 	    $buffer = $Common->getData($value['host']);
1292
-	    $all_data = json_decode($buffer,true);
1292
+	    $all_data = json_decode($buffer, true);
1293 1293
 	    if (isset($all_data['aircraft'])) {
1294 1294
 		$reset = 0;
1295 1295
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1306,7 +1306,7 @@  discard block
 block discarded – undo
1306 1306
 		    //$data['emergency'] = ''; // emergency
1307 1307
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1308 1308
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1309
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1309
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1310 1310
 		    $data['format_source'] = 'planefinderclient';
1311 1311
 		    $data['id_source'] = $id_source;
1312 1312
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 	) {
1326 1326
 	    //$buffer = $Common->getData($hosts[$id]);
1327 1327
 	    $buffer = $Common->getData($value['host']);
1328
-	    $all_data = json_decode($buffer,true);
1328
+	    $all_data = json_decode($buffer, true);
1329 1329
 	    if (!empty($all_data)) $reset = 0;
1330 1330
 	    foreach ($all_data as $key => $line) {
1331 1331
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1363,11 +1363,11 @@  discard block
 block discarded – undo
1363 1363
 	    )
1364 1364
 	) {
1365 1365
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1366
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1366
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1367 1367
 	    //echo $buffer;
1368
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1369
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1370
-	    $all_data = json_decode($buffer,true);
1368
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1369
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1370
+	    $all_data = json_decode($buffer, true);
1371 1371
 	    if (json_last_error() != JSON_ERROR_NONE) {
1372 1372
 		die(json_last_error_msg());
1373 1373
 	    }
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 			//$data['departure_airport_iata'] = $line[11];
1391 1391
 			//$data['arrival_airport_iata'] = $line[12];
1392 1392
 	    		//$data['emergency'] = ''; // emergency
1393
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1393
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1394 1394
 	    		$data['format_source'] = 'radarvirtueljson';
1395 1395
     			$data['id_source'] = $id_source;
1396 1396
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1411,14 +1411,14 @@  discard block
 block discarded – undo
1411 1411
 	) {
1412 1412
 	    //$buffer = $Common->getData($hosts[$id]);
1413 1413
 	    $buffer = $Common->getData($value['host'].'?'.time());
1414
-	    $all_data = json_decode(utf8_encode($buffer),true);
1414
+	    $all_data = json_decode(utf8_encode($buffer), true);
1415 1415
 	    
1416 1416
 	    if (isset($all_data['pireps'])) {
1417 1417
 		$reset = 0;
1418 1418
 	        foreach ($all_data['pireps'] as $line) {
1419 1419
 		    $data = array();
1420 1420
 		    $data['id'] = $line['id'];
1421
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1421
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1422 1422
 		    $data['ident'] = $line['callsign']; // ident
1423 1423
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1424 1424
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1448,9 +1448,9 @@  discard block
 block discarded – undo
1448 1448
 			$SI->add($data);
1449 1449
 		    //    print_r($data);
1450 1450
     		    } elseif ($line['icon'] === 'ct') {
1451
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1452
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1453
-			$typec = substr($data['ident'],-3);
1451
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1452
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1453
+			$typec = substr($data['ident'], -3);
1454 1454
 			$data['type'] = '';
1455 1455
 			if ($typec === 'APP') $data['type'] = 'Approach';
1456 1456
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1461,7 +1461,7 @@  discard block
 block discarded – undo
1461 1461
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1462 1462
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1463 1463
 			else $data['type'] = 'Observer';
1464
-			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']);
1464
+			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']);
1465 1465
 		    }
1466 1466
 		    unset($data);
1467 1467
 		}
@@ -1478,14 +1478,14 @@  discard block
 block discarded – undo
1478 1478
 	    //$buffer = $Common->getData($hosts[$id]);
1479 1479
 	    if ($globalDebug) echo 'Get Data...'."\n";
1480 1480
 	    $buffer = $Common->getData($value['host']);
1481
-	    $all_data = json_decode($buffer,true);
1481
+	    $all_data = json_decode($buffer, true);
1482 1482
 	    if ($buffer != '' && is_array($all_data)) {
1483 1483
 		$reset = 0;
1484 1484
 		foreach ($all_data as $line) {
1485 1485
 	    	    $data = array();
1486 1486
 	    	    //$data['id'] = $line['id']; // id not usable
1487 1487
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1488
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1488
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1489 1489
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1490 1490
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1491 1491
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
 	    	    //$data['datetime'] = $line['lastupdate'];
1501 1501
 	    	    //$data['last_update'] = $line['lastupdate'];
1502 1502
 	    	    if (isset($value['timezone'])) {
1503
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1503
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1504 1504
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1505 1505
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1506 1506
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1516,14 +1516,14 @@  discard block
 block discarded – undo
1516 1516
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1517 1517
 		    if (isset($line['aircraftname'])) {
1518 1518
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1519
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1520
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1519
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1520
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1521 1521
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1522 1522
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1523 1523
 	    		else {
1524
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1525
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1526
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1524
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1525
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1526
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1527 1527
 	    		}
1528 1528
 	    	    }
1529 1529
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
 	    //$buffer = $Common->getData($hosts[$id]);
1549 1549
 	    if ($globalDebug) echo 'Get Data...'."\n";
1550 1550
 	    $buffer = $Common->getData($value['host']);
1551
-	    $all_data = json_decode($buffer,true);
1551
+	    $all_data = json_decode($buffer, true);
1552 1552
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1553 1553
 		$reset = 0;
1554 1554
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1560 1560
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1561 1561
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1562
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1562
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1563 1563
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1564 1564
 	    	    $data['altitude'] = $line['altitude']; // altitude
1565 1565
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
 	    	    //$data['squawk'] = ''; // squawk
1571 1571
 	    	    //$data['emergency'] = ''; // emergency
1572 1572
 	    	    if (isset($value['timezone'])) {
1573
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1573
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1574 1574
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1575 1575
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1576 1576
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1606,14 +1606,14 @@  discard block
 block discarded – undo
1606 1606
 	    //$buffer = $Common->getData($hosts[$id]);
1607 1607
 	    if ($globalDebug) echo 'Get Data...'."\n";
1608 1608
 	    $buffer = $Common->getData($value['host']);
1609
-	    $all_data = json_decode($buffer,true);
1609
+	    $all_data = json_decode($buffer, true);
1610 1610
 	    if ($buffer != '' && is_array($all_data)) {
1611 1611
 		$reset = 0;
1612 1612
 		foreach ($all_data as $line) {
1613 1613
 	    	    $data = array();
1614 1614
 	    	    //$data['id'] = $line['id']; // id not usable
1615 1615
 	    	    $data['id'] = trim($line['flight_id']);
1616
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1616
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1617 1617
 	    	    $data['pilot_name'] = $line['pilot_name'];
1618 1618
 	    	    $data['pilot_id'] = $line['pilot_id'];
1619 1619
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1657,24 +1657,24 @@  discard block
 block discarded – undo
1657 1657
 	    //$buffer = $Common->getData($hosts[$id]);
1658 1658
 	    if ($globalDebug) echo 'Get Data...'."\n";
1659 1659
 	    $buffer = $Common->getData($value['host']);
1660
-	    $all_data = json_decode($buffer,true);
1660
+	    $all_data = json_decode($buffer, true);
1661 1661
 	    if ($buffer != '') {
1662 1662
 		$Source->deleteLocationBySource('blitzortung');
1663
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1664
-		$buffer = explode('\n',$buffer);
1663
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1664
+		$buffer = explode('\n', $buffer);
1665 1665
 		foreach ($buffer as $buffer_line) {
1666
-		    $line = json_decode($buffer_line,true);
1666
+		    $line = json_decode($buffer_line, true);
1667 1667
 		    if (isset($line['time'])) {
1668 1668
 			$data = array();
1669 1669
 			$data['altitude'] = $line['alt']; // altitude
1670 1670
 			$data['latitude'] = $line['lat']; // lat
1671 1671
 			$data['longitude'] = $line['lon']; // long
1672
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1672
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1673 1673
 			$data['id_source'] = $id_source;
1674 1674
 			$data['format_source'] = 'blitzortung';
1675 1675
 			$SI->add($data);
1676 1676
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1677
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1677
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1678 1678
 			unset($data);
1679 1679
 		    }
1680 1680
 		}
@@ -1686,15 +1686,15 @@  discard block
 block discarded – undo
1686 1686
         $arr = $httpfeeds;
1687 1687
         $w = $e = null;
1688 1688
         if (isset($arr[$id])) {
1689
-            $nn = stream_select($arr,$w,$e,$timeout);
1689
+            $nn = stream_select($arr, $w, $e, $timeout);
1690 1690
             if ($nn > 0) {
1691 1691
                 foreach ($httpfeeds as $feed) {
1692
-                    $buffer = stream_get_line($feed,2000,"\n");
1692
+                    $buffer = stream_get_line($feed, 2000, "\n");
1693 1693
                     if ($buffer === FALSE) {
1694 1694
                         connect_all($globalSources);
1695 1695
                     }
1696
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1697
-                    $buffer = explode('\n',$buffer);
1696
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1697
+                    $buffer = explode('\n', $buffer);
1698 1698
                     foreach ($buffer as $line) {
1699 1699
                         if ($line != '') {
1700 1700
                             $line = json_decode($line, true);
@@ -1734,11 +1734,11 @@  discard block
 block discarded – undo
1734 1734
 		    //$value = $formats[$nb];
1735 1735
 		    $format = $globalSources[$nb]['format'];
1736 1736
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1737
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1737
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1738 1738
 		    } elseif ($format === 'vrstcp') {
1739 1739
 			$buffer = @socket_read($r, 6000);
1740 1740
 		    } else {
1741
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1741
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1742 1742
 		    }
1743 1743
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1744 1744
 		    //echo $buffer."\n";
@@ -1748,8 +1748,8 @@  discard block
 block discarded – undo
1748 1748
 		    //$SI::del();
1749 1749
 		    if ($buffer !== FALSE) {
1750 1750
 			if ($format === 'vrstcp') {
1751
-			    $buffer = explode('},{',$buffer);
1752
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1751
+			    $buffer = explode('},{', $buffer);
1752
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1753 1753
 		    }
1754 1754
 		    // SBS format is CSV format
1755 1755
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1776,7 +1776,7 @@  discard block
 block discarded – undo
1776 1776
 			    $ais_data = $AIS->parse_line(trim($buffer));
1777 1777
 			    $data = array();
1778 1778
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1779
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1779
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1780 1780
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1781 1781
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1782 1782
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1787,13 +1787,13 @@  discard block
 block discarded – undo
1787 1787
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1788 1788
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1789 1789
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1790
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1790
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1791 1791
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1792 1792
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1793 1793
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1794 1794
 
1795 1795
 			    if (isset($ais_data['timestamp'])) {
1796
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1796
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1797 1797
 			    } else {
1798 1798
 				$data['datetime'] = date('Y-m-d H:i:s');
1799 1799
 			    }
@@ -1804,10 +1804,10 @@  discard block
 block discarded – undo
1804 1804
                         } elseif ($format === 'flightgearsp') {
1805 1805
                     	    //echo $buffer."\n";
1806 1806
                     	    if (strlen($buffer) > 5) {
1807
-				$line = explode(',',$buffer);
1807
+				$line = explode(',', $buffer);
1808 1808
 				$data = array();
1809 1809
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1810
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1810
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1811 1811
 				$data['ident'] = $line[6];
1812 1812
 				$data['aircraft_name'] = $line[7];
1813 1813
 				$data['longitude'] = $line[1];
@@ -1824,25 +1824,25 @@  discard block
 block discarded – undo
1824 1824
                         } elseif ($format === 'acars') {
1825 1825
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1826 1826
 			    $ACARS->add(trim($buffer));
1827
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1827
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1828 1828
 			    $ACARS->deleteLiveAcarsData();
1829 1829
 			} elseif ($format === 'acarsjsonudp') {
1830 1830
 			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1831 1831
                             $line = json_decode(trim($buffer), true);
1832 1832
                             if (!empty($line)) {
1833
-				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1833
+				$line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line);
1834 1834
                                 $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1835 1835
                                 $ACARS->deleteLiveAcarsData();
1836 1836
                             }
1837
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1837
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1838 1838
 			} elseif ($format === 'flightgearmp') {
1839
-			    if (substr($buffer,0,1) != '#') {
1839
+			    if (substr($buffer, 0, 1) != '#') {
1840 1840
 				$data = array();
1841 1841
 				//echo $buffer."\n";
1842
-				$line = explode(' ',$buffer);
1842
+				$line = explode(' ', $buffer);
1843 1843
 				if (count($line) === 11) {
1844
-				    $userserver = explode('@',$line[0]);
1845
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1844
+				    $userserver = explode('@', $line[0]);
1845
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1846 1846
 				    $data['ident'] = $userserver[0];
1847 1847
 				    $data['registration'] = $userserver[0];
1848 1848
 				    $data['latitude'] = $line[4];
@@ -1850,8 +1850,8 @@  discard block
 block discarded – undo
1850 1850
 				    $data['altitude'] = $line[6];
1851 1851
 				    $data['datetime'] = date('Y-m-d H:i:s');
1852 1852
 				    $aircraft_type = $line[10];
1853
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1854
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1853
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1854
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1855 1855
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1856 1856
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1857 1857
 				}
@@ -1860,8 +1860,8 @@  discard block
 block discarded – undo
1860 1860
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1861 1861
 			    die;
1862 1862
 			} elseif ($format === 'vrstcp') {
1863
-			    foreach($buffer as $all_data) {
1864
-				$line = json_decode('{'.$all_data.'}',true);
1863
+			    foreach ($buffer as $all_data) {
1864
+				$line = json_decode('{'.$all_data.'}', true);
1865 1865
 				$data = array();
1866 1866
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1867 1867
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1887,16 +1887,16 @@  discard block
 block discarded – undo
1887 1887
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1888 1888
 				unset($data);
1889 1889
 			    }
1890
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1890
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1891 1891
 			    $line = explode("\t", $buffer);
1892
-			    for($k = 0; $k < count($line); $k=$k+2) {
1892
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1893 1893
 				$key = $line[$k];
1894
-			        $lined[$key] = $line[$k+1];
1894
+			        $lined[$key] = $line[$k + 1];
1895 1895
 			    }
1896 1896
     			    if (count($lined) > 3) {
1897 1897
     				$data['hex'] = $lined['hexid'];
1898 1898
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1899
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1899
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1900 1900
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1901 1901
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1902 1902
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1915,23 +1915,23 @@  discard block
 block discarded – undo
1915 1915
     			    } else $error = true;
1916 1916
 			} elseif ($format === 'aprs' && $use_aprs) {
1917 1917
 			    if ($aprs_connect === 0) {
1918
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1918
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1919 1919
 				$aprs_connect = 1;
1920 1920
 			    }
1921 1921
 			    
1922
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1922
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1923 1923
 				$aprs_last_tx = time();
1924 1924
 				$data_aprs = "# Keep alive";
1925
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1925
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1926 1926
 			    }
1927 1927
 			    
1928 1928
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1929 1929
 			    //echo 'APRS data : '.$buffer."\n";
1930
-			    $buffer = str_replace('APRS <- ','',$buffer);
1931
-			    $buffer = str_replace('APRS -> ','',$buffer);
1930
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1931
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1932 1932
 			    //echo $buffer."\n";
1933 1933
 			    date_default_timezone_set('UTC');
1934
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1934
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1935 1935
 				$line = $APRS->parse($buffer);
1936 1936
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1937 1937
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1946,7 +1946,7 @@  discard block
 block discarded – undo
1946 1946
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1947 1947
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1948 1948
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1949
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1949
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1950 1950
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1951 1951
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1952 1952
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -2034,29 +2034,29 @@  discard block
 block discarded – undo
2034 2034
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2035 2035
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
2036 2036
 					$Source->deleteOldLocationByType('gs');
2037
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
2038
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2037
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
2038
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
2039 2039
 					} else {
2040
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
2040
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
2041 2041
 					}
2042 2042
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2043 2043
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2044 2044
 					if ($globalDebug) echo '# Weather Station added'."\n";
2045 2045
 					$Source->deleteOldLocationByType('wx');
2046 2046
 					$weather_data = json_encode($line);
2047
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
2048
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2047
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
2048
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2049 2049
 					} else {
2050
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2050
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2051 2051
 					}
2052 2052
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2053 2053
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2054 2054
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2055 2055
 					$Source->deleteOldLocationByType('lightning');
2056
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2057
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2056
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
2057
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2058 2058
 					} else {
2059
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2059
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2060 2060
 					}
2061 2061
 				    } elseif ($globalDebug) {
2062 2062
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2065,7 +2065,7 @@  discard block
 block discarded – undo
2065 2065
 				    unset($data);
2066 2066
 				}
2067 2067
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2068
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2068
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2069 2069
 				}
2070 2070
 				/*
2071 2071
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) {
@@ -2074,7 +2074,7 @@  discard block
 block discarded – undo
2074 2074
 				*/
2075 2075
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2076 2076
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2077
-				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2077
+				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2078 2078
 					$Source->deleteOldLocationByType('lightning');
2079 2079
 					$Source->deleteOldLocationByType('wx');
2080 2080
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2161,7 +2161,7 @@  discard block
 block discarded – undo
2161 2161
 				connect_all($sourceee);
2162 2162
 				$sourceee = array();
2163 2163
 				//connect_all($globalSources);
2164
-				$tt[$format]=0;
2164
+				$tt[$format] = 0;
2165 2165
 				break;
2166 2166
 			    } 
2167 2167
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2171,14 +2171,14 @@  discard block
 block discarded – undo
2171 2171
 	    } else {
2172 2172
 		$error = socket_strerror(socket_last_error());
2173 2173
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2174
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2174
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2175 2175
 			if (isset($globalDebug)) echo "Restarting...\n";
2176 2176
 			// Restart the script if possible
2177 2177
 			if (is_array($sockets)) {
2178 2178
 			    if ($globalDebug) echo "Shutdown all sockets...";
2179 2179
 			    
2180 2180
 			    foreach ($sockets as $sock) {
2181
-				@socket_shutdown($sock,2);
2181
+				@socket_shutdown($sock, 2);
2182 2182
 				@socket_close($sock);
2183 2183
 			    }
2184 2184
 			    
Please login to merge, or discard this patch.
Braces   +1242 added lines, -418 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
26 28
 
27 29
 if ($globalInstalled === FALSE) {
28 30
     echo "This script MUST be run after install script. Use your web browser to run install/index.php";
@@ -68,66 +70,107 @@  discard block
 block discarded – undo
68 70
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 71
 if (isset($options['s'])) {
70 72
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
73
-} elseif (isset($options['source'])) {
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['s']);
77
+    }
78
+    } elseif (isset($options['source'])) {
74 79
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
77
-}
80
+    if (isset($options['format'])) {
81
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
82
+    } else {
83
+    	$globalSources[] = array('host' => $options['source']);
84
+    }
85
+    }
78 86
 if (isset($options['aprsserverhost'])) {
79 87
 	$globalServerAPRS = TRUE;
80 88
 	$globalServerAPRShost = $options['aprsserverhost'];
81 89
 }
82
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
83
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
84
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
85
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
90
+if (isset($options['aprsserverport'])) {
91
+	$globalServerAPRSport = $options['aprsserverport'];
92
+}
93
+if (isset($options['aprsserverssid'])) {
94
+	$globalServerAPRSssid = $options['aprsserverssid'];
95
+}
96
+if (isset($options['aprsserverpass'])) {
97
+	$globalServerAPRSpass = $options['aprsserverpass'];
98
+}
99
+if (isset($options['noaprsserver'])) {
100
+	$globalServerAPRS = FALSE;
101
+}
86 102
 if (isset($options['enable-aircraft'])) {
87
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
103
+	if ($globalDebug) {
104
+		echo 'Enable Aircraft mode'."\n";
105
+	}
88 106
 	$globalAircraft = TRUE; 
89 107
 }
90 108
 if (isset($options['disable-aircraft'])) {
91
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
109
+	if ($globalDebug) {
110
+		echo 'Disable Aircraft mode'."\n";
111
+	}
92 112
 	$globalAircraft = FALSE;
93 113
 }
94 114
 if (isset($options['enable-tracker'])) {
95
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
115
+	if ($globalDebug) {
116
+		echo 'Enable Tracker mode'."\n";
117
+	}
96 118
 	$globalTracker = TRUE; 
97 119
 }
98 120
 if (isset($options['disable-tracker'])) {
99
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
121
+	if ($globalDebug) {
122
+		echo 'Disable Tracker mode'."\n";
123
+	}
100 124
 	$globalTracker = FALSE;
101 125
 }
102 126
 if (isset($options['enable-marine'])) {
103
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
127
+	if ($globalDebug) {
128
+		echo 'Enable Marine mode'."\n";
129
+	}
104 130
 	$globalMarine = TRUE;
105 131
 }
106 132
 if (isset($options['disable-marine'])) {
107
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
133
+	if ($globalDebug) {
134
+		echo 'Disable Marine mode'."\n";
135
+	}
108 136
 	$globalMarine = FALSE;
109 137
 }
110
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
111
-if (isset($options['server'])) $globalServer = TRUE;
112
-if (isset($options['idsource'])) $id_source = $options['idsource'];
113
-else $id_source = 1;
138
+if (isset($options['nodaemon'])) {
139
+	$globalDaemon = FALSE;
140
+}
141
+if (isset($options['server'])) {
142
+	$globalServer = TRUE;
143
+}
144
+if (isset($options['idsource'])) {
145
+	$id_source = $options['idsource'];
146
+} else {
147
+	$id_source = 1;
148
+}
114 149
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
150
+    if ($globalDebug) {
151
+    	echo "Using Server Mode\n";
152
+    }
116 153
     $SI=new SpotterServer();
117 154
 /*
118 155
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 156
     $SI = new adsb2aprs();
120 157
     $SI->connect();
121 158
 */
122
-} else $SI=new SpotterImport($Connection->db);
159
+} else {
160
+	$SI=new SpotterImport($Connection->db);
161
+}
123 162
 
124
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
163
+if (isset($globalTracker) && $globalTracker) {
164
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
165
+}
125 166
 if (isset($globalMarine) && $globalMarine) {
126 167
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
127 168
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 169
 }
129 170
 
130
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
171
+if (isset($globalTracker) && $globalTracker) {
172
+	$TI = new TrackerImport($Connection->db);
173
+}
131 174
 if (isset($globalMarine) && $globalMarine) {
132 175
     $AIS = new AIS();
133 176
     $MI = new MarineImport($Connection->db);
@@ -152,7 +195,9 @@  discard block
 block discarded – undo
152 195
 }
153 196
 
154 197
 // let's try and connect
155
-if ($globalDebug) echo "Connecting...\n";
198
+if ($globalDebug) {
199
+	echo "Connecting...\n";
200
+}
156 201
 $use_aprs = false;
157 202
 $aprs_full = false;
158 203
 $reset = 0;
@@ -161,7 +206,9 @@  discard block
 block discarded – undo
161 206
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162 207
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163 208
     $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
209
+    if ($globalDebug) {
210
+    	echo 'Connect to all...'."\n";
211
+    }
165 212
     foreach ($hosts as $id => $value) {
166 213
 	$host = $value['host'];
167 214
 	$udp = false;
@@ -172,32 +219,44 @@  discard block
 block discarded – undo
172 219
         	//$formats[$id] = 'deltadbtxt';
173 220
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 221
         	//$last_exec['deltadbtxt'] = 0;
175
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to deltadb source (".$host.")...\n";
224
+        	}
176 225
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
177 226
         	//$formats[$id] = 'vatsimtxt';
178 227
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 228
         	//$last_exec['vatsimtxt'] = 0;
180
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
229
+        	if ($globalDebug) {
230
+        		echo "Connect to vatsim source (".$host.")...\n";
231
+        	}
181 232
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
182 233
         	//$formats[$id] = 'aircraftlistjson';
183 234
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 235
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
236
+        	if ($globalDebug) {
237
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
238
+        	}
186 239
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
187 240
         	//$formats[$id] = 'aircraftjson';
188 241
         	$globalSources[$id]['format'] = 'aircraftjson';
189 242
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
243
+        	if ($globalDebug) {
244
+        		echo "Connect to aircraft.json source (".$host.")...\n";
245
+        	}
191 246
     	    } else if (preg_match('/aircraft$/i',$host)) {
192 247
         	//$formats[$id] = 'planefinderclient';
193 248
         	$globalSources[$id]['format'] = 'planefinderclient';
194 249
         	//$last_exec['aircraftlistjson'] = 0;
195
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
250
+        	if ($globalDebug) {
251
+        		echo "Connect to planefinderclient source (".$host.")...\n";
252
+        	}
196 253
     	    } else if (preg_match('/opensky/i',$host)) {
197 254
         	//$formats[$id] = 'aircraftlistjson';
198 255
         	$globalSources[$id]['format'] = 'opensky';
199 256
         	//$last_exec['aircraftlistjson'] = 0;
200
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
257
+        	if ($globalDebug) {
258
+        		echo "Connect to opensky source (".$host.")...\n";
259
+        	}
201 260
     	    /*
202 261
     	    // Disabled for now, site change source format
203 262
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -214,7 +273,9 @@  discard block
 block discarded – undo
214 273
         	//$formats[$id] = 'planeupdatefaa';
215 274
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 275
         	//$last_exec['planeupdatefaa'] = 0;
217
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
276
+        	if ($globalDebug) {
277
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
278
+        	}
218 279
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219 280
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 281
         	    exit(0);
@@ -223,37 +284,53 @@  discard block
 block discarded – undo
223 284
         	//$formats[$id] = 'phpvmacars';
224 285
         	$globalSources[$id]['format'] = 'phpvmacars';
225 286
         	//$last_exec['phpvmacars'] = 0;
226
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
287
+        	if ($globalDebug) {
288
+        		echo "Connect to phpvmacars source (".$host.")...\n";
289
+        	}
227 290
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228 291
         	//$formats[$id] = 'phpvmacars';
229 292
         	$globalSources[$id]['format'] = 'vaos';
230 293
         	//$last_exec['phpvmacars'] = 0;
231
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
294
+        	if ($globalDebug) {
295
+        		echo "Connect to vaos source (".$host.")...\n";
296
+        	}
232 297
             } else if (preg_match('/VAM-json.php$/i',$host)) {
233 298
         	//$formats[$id] = 'phpvmacars';
234 299
         	$globalSources[$id]['format'] = 'vam';
235
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
300
+        	if ($globalDebug) {
301
+        		echo "Connect to Vam source (".$host.")...\n";
302
+        	}
236 303
             } else if (preg_match('/whazzup/i',$host)) {
237 304
         	//$formats[$id] = 'whazzup';
238 305
         	$globalSources[$id]['format'] = 'whazzup';
239 306
         	//$last_exec['whazzup'] = 0;
240
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
307
+        	if ($globalDebug) {
308
+        		echo "Connect to whazzup source (".$host.")...\n";
309
+        	}
241 310
             } else if (preg_match('/blitzortung/i',$host)) {
242 311
         	$globalSources[$id]['format'] = 'blitzortung';
243
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
312
+        	if ($globalDebug) {
313
+        		echo "Connect to blitzortung source (".$host.")...\n";
314
+        	}
244 315
             } else if (preg_match('/airwhere/i',$host)) {
245 316
         	$globalSources[$id]['format'] = 'airwhere';
246
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
317
+        	if ($globalDebug) {
318
+        		echo "Connect to airwhere source (".$host.")...\n";
319
+        	}
247 320
             } else if (preg_match('/recentpireps/i',$host)) {
248 321
         	//$formats[$id] = 'pirepsjson';
249 322
         	$globalSources[$id]['format'] = 'pirepsjson';
250 323
         	//$last_exec['pirepsjson'] = 0;
251
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
324
+        	if ($globalDebug) {
325
+        		echo "Connect to pirepsjson source (".$host.")...\n";
326
+        	}
252 327
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253 328
         	//$formats[$id] = 'fr24json';
254 329
         	$globalSources[$id]['format'] = 'fr24json';
255 330
         	//$last_exec['fr24json'] = 0;
256
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
331
+        	if ($globalDebug) {
332
+        		echo "Connect to fr24 source (".$host.")...\n";
333
+        	}
257 334
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258 335
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 336
         	    exit(0);
@@ -262,7 +339,9 @@  discard block
 block discarded – undo
262 339
         	//$formats[$id] = 'fr24json';
263 340
         	$globalSources[$id]['format'] = 'myshiptracking';
264 341
         	//$last_exec['fr24json'] = 0;
265
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
342
+        	if ($globalDebug) {
343
+        		echo "Connect to myshiptracking source (".$host.")...\n";
344
+        	}
266 345
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267 346
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268 347
         	    exit(0);
@@ -271,18 +350,28 @@  discard block
 block discarded – undo
271 350
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 351
         	//$formats[$id] = 'tsv';
273 352
         	$globalSources[$id]['format'] = 'tsv';
274
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
353
+        	if ($globalDebug) {
354
+        		echo "Connect to tsv source (".$host.")...\n";
355
+        	}
275 356
             }
276 357
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 358
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278 359
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
279 360
     		    if ($idf !== false) {
280 361
     			$httpfeeds[$id] = $idf;
281
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
-    		elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
285
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
362
+        		if ($globalDebug) {
363
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
364
+        		}
365
+    		    } elseif ($globalDebug) {
366
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
367
+    		    }
368
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
369
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
370
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') {
371
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n";
372
+    		} elseif ($globalDebug) {
373
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
374
+    		}
286 375
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
287 376
 	    $hostport = explode(':',$host);
288 377
 	    if (isset($hostport[1])) {
@@ -323,20 +412,29 @@  discard block
 block discarded – undo
323 412
         		//$formats[$id] = 'beast';
324 413
         		$globalSources[$id]['format'] = 'beast';
325 414
 		    //} else $formats[$id] = 'sbs';
326
-		    } else $globalSources[$id]['format'] = 'sbs';
415
+		    } else {
416
+		    	$globalSources[$id]['format'] = 'sbs';
417
+		    }
327 418
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
328 419
 		}
329
-		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
-		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
420
+		if ($globalDebug && $udp) {
421
+			echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
422
+		} elseif ($globalDebug) {
423
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
424
+		}
331 425
             } else {
332
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
426
+		if ($globalDebug) {
427
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
428
+		}
333 429
 		sleep(10);
334 430
 		connect_all($hosts);
335 431
     	    }
336 432
         }
337 433
     }
338 434
 }
339
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
435
+if (!isset($globalMinFetch)) {
436
+	$globalMinFetch = 15;
437
+}
340 438
 
341 439
 // Initialize all
342 440
 $status = array();
@@ -345,13 +443,19 @@  discard block
 block discarded – undo
345 443
 $formats = array();
346 444
 $last_exec = array();
347 445
 $time = time();
348
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
349
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
350
-else $timeout = 20;
446
+if (isset($globalSourcesTimeout)) {
447
+	$timeout = $globalSourcesTimeOut;
448
+} else if (isset($globalSBS1TimeOut)) {
449
+	$timeout = $globalSBS1TimeOut;
450
+} else {
451
+	$timeout = 20;
452
+}
351 453
 $errno = '';
352 454
 $errstr='';
353 455
 
354
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
456
+if (!isset($globalDaemon)) {
457
+	$globalDaemon = TRUE;
458
+}
355 459
 /* Initiate connections to all the hosts simultaneously */
356 460
 //connect_all($hosts);
357 461
 //connect_all($globalSources);
@@ -380,7 +484,9 @@  discard block
 block discarded – undo
380 484
     if (isset($source['format']) && $source['format'] == 'aprs') {
381 485
 	$aprs_connect = 0;
382 486
 	$use_aprs = true;
383
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
487
+	if (isset($source['port']) && $source['port'] == '10152') {
488
+		$aprs_full = true;
489
+	}
384 490
 	break;
385 491
     }
386 492
 }
@@ -391,25 +497,46 @@  discard block
 block discarded – undo
391 497
 	$aprs_connect = 0;
392 498
 	$aprs_keep = 120;
393 499
 	$aprs_last_tx = time();
394
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
395
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
396
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
397
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
398
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
399
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
400
-	if ($aprs_full) $aprs_filter = '';
401
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
402
-	else $aprs_pass = '-1';
500
+	if (isset($globalAPRSversion)) {
501
+		$aprs_version = $globalAPRSversion;
502
+	} else {
503
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
504
+	}
505
+	if (isset($globalAPRSssid)) {
506
+		$aprs_ssid = $globalAPRSssid;
507
+	} else {
508
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
509
+	}
510
+	if (isset($globalAPRSfilter)) {
511
+		$aprs_filter = $globalAPRSfilter;
512
+	} else {
513
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
514
+	}
515
+	if ($aprs_full) {
516
+		$aprs_filter = '';
517
+	}
518
+	if (isset($globalAPRSpass)) {
519
+		$aprs_pass = $globalAPRSpass;
520
+	} else {
521
+		$aprs_pass = '-1';
522
+	}
403 523
 
404
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
405
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
406
-}
524
+	if ($aprs_filter != '') {
525
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
526
+	} else {
527
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
528
+	}
529
+	}
407 530
 
408 531
 // connected - lets do some work
409 532
 //if ($globalDebug) echo "Connected!\n";
410 533
 sleep(1);
411
-if ($globalDebug) echo "SCAN MODE \n\n";
412
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
534
+if ($globalDebug) {
535
+	echo "SCAN MODE \n\n";
536
+}
537
+if (!isset($globalCronEnd)) {
538
+	$globalCronEnd = 60;
539
+}
413 540
 $endtime = time()+$globalCronEnd;
414 541
 $i = 1;
415 542
 $tt = array();
@@ -423,22 +550,32 @@  discard block
 block discarded – undo
423 550
 
424 551
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
425 552
 while ($i > 0) {
426
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
553
+    if (function_exists('pcntl_fork')) {
554
+    	pcntl_signal_dispatch();
555
+    }
427 556
 
428
-    if (!$globalDaemon) $i = $endtime-time();
557
+    if (!$globalDaemon) {
558
+    	$i = $endtime-time();
559
+    }
429 560
     // Delete old ATC
430 561
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
431
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
562
+	if ($globalDebug) {
563
+		echo 'Delete old ATC...'."\n";
564
+	}
432 565
         $ATC->deleteOldATC();
433 566
     }
434 567
     
435 568
     if (count($last_exec) == count($globalSources)) {
436 569
 	$max = $globalMinFetch;
437 570
 	foreach ($last_exec as $last) {
438
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
571
+	    if ((time() - $last['last']) < $max) {
572
+	    	$max = time() - $last['last'];
573
+	    }
439 574
 	}
440 575
 	if ($max < $globalMinFetch) {
441
-	    if ($globalDebug) echo 'Sleeping...'."\n";
576
+	    if ($globalDebug) {
577
+	    	echo 'Sleeping...'."\n";
578
+	    }
442 579
 	    sleep($globalMinFetch-$max+2);
443 580
 	}
444 581
     }
@@ -448,7 +585,9 @@  discard block
 block discarded – undo
448 585
     foreach ($globalSources as $id => $value) {
449 586
 	date_default_timezone_set('UTC');
450 587
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
451
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
588
+	if (!isset($last_exec[$id]['last'])) {
589
+		$last_exec[$id]['last'] = 0;
590
+	}
452 591
 	if ($value['format'] === 'deltadbtxt' && 
453 592
 	    (
454 593
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -457,7 +596,9 @@  discard block
 block discarded – undo
457 596
 	) {
458 597
         //$buffer = $Common->getData($hosts[$id]);
459 598
         $buffer = $Common->getData($value['host']);
460
-        if ($buffer != '') $reset = 0;
599
+        if ($buffer != '') {
600
+        	$reset = 0;
601
+        }
461 602
         $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
462 603
         $buffer = explode('\n', $buffer);
463 604
         foreach ($buffer as $line) {
@@ -466,20 +607,41 @@  discard block
 block discarded – undo
466 607
                 $data = array();
467 608
                 $data['hex'] = $line[1]; // hex
468 609
                 $data['ident'] = $line[2]; // ident
469
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
470
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
471
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
472
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
473
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
610
+                if (isset($line[3])) {
611
+                	$data['altitude'] = $line[3];
612
+                }
613
+                // altitude
614
+                if (isset($line[4])) {
615
+                	$data['speed'] = $line[4];
616
+                }
617
+                // speed
618
+                if (isset($line[5])) {
619
+                	$data['heading'] = $line[5];
620
+                }
621
+                // heading
622
+                if (isset($line[6])) {
623
+                	$data['latitude'] = $line[6];
624
+                }
625
+                // lat
626
+                if (isset($line[7])) {
627
+                	$data['longitude'] = $line[7];
628
+                }
629
+                // long
474 630
                 $data['verticalrate'] = ''; // vertical rate
475 631
                 //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
476 632
                 $data['emergency'] = ''; // emergency
477 633
                 $data['datetime'] = date('Y-m-d H:i:s');
478 634
                 $data['format_source'] = 'deltadbtxt';
479 635
                 $data['id_source'] = $id_source;
480
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
481
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
636
+                if (isset($value['name']) && $value['name'] != '') {
637
+                	$data['source_name'] = $value['name'];
638
+                }
639
+                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
640
+                	$data['noarchive'] = true;
641
+                }
642
+                if (isset($value['sourcestats'])) {
643
+                	$data['sourcestats'] = $value['sourcestats'];
644
+                }
483 645
                 $SI->add($data);
484 646
                 unset($data);
485 647
             }
@@ -514,11 +676,20 @@  discard block
 block discarded – undo
514 676
                     $data['format_source'] = 'radarcapejson';
515 677
                     $data['id_source'] = $id_source;
516 678
                     if (isset($value['name']) && $value['name'] != '') {
517
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
518
-                        else $data['source_name'] = $value['name'];
519
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
520
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
521
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
679
+                        if (isset($line['src']) && !$line['src'] == 'M') {
680
+                        	$data['source_name'] = $value['name'].'_MLAT';
681
+                        } else {
682
+                        	$data['source_name'] = $value['name'];
683
+                        }
684
+                    } elseif (isset($line['src']) && $line['src'] == 'M') {
685
+                    	$data['source_name'] = 'MLAT';
686
+                    }
687
+                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
688
+                    	$data['noarchive'] = true;
689
+                    }
690
+                    if (isset($value['sourcestats'])) {
691
+                    	$data['sourcestats'] = $value['sourcestats'];
692
+                    }
522 693
 
523 694
                     $SI->add($data);
524 695
                     unset($data);
@@ -534,7 +705,9 @@  discard block
 block discarded – undo
534 705
 	    date_default_timezone_set('CET');
535 706
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
536 707
 	    date_default_timezone_set('UTC');
537
-	    if ($buffer != '') $reset = 0;
708
+	    if ($buffer != '') {
709
+	    	$reset = 0;
710
+	    }
538 711
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539 712
 	    $buffer = explode('\n',$buffer);
540 713
 	    foreach ($buffer as $line) {
@@ -543,18 +716,42 @@  discard block
 block discarded – undo
543 716
 		    $add = false;
544 717
 		    $ais_data = $AIS->parse_line(trim($line));
545 718
 		    $data = array();
546
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
547
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
548
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
549
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
550
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
551
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
552
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
553
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
554
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
555
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
556
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
557
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
719
+		    if (isset($ais_data['ident'])) {
720
+		    	$data['ident'] = $ais_data['ident'];
721
+		    }
722
+		    if (isset($ais_data['mmsi'])) {
723
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
724
+		    }
725
+		    if (isset($ais_data['speed'])) {
726
+		    	$data['speed'] = $ais_data['speed'];
727
+		    }
728
+		    if (isset($ais_data['heading'])) {
729
+		    	$data['heading'] = $ais_data['heading'];
730
+		    }
731
+		    if (isset($ais_data['latitude'])) {
732
+		    	$data['latitude'] = $ais_data['latitude'];
733
+		    }
734
+		    if (isset($ais_data['longitude'])) {
735
+		    	$data['longitude'] = $ais_data['longitude'];
736
+		    }
737
+		    if (isset($ais_data['status'])) {
738
+		    	$data['status'] = $ais_data['status'];
739
+		    }
740
+		    if (isset($ais_data['statusid'])) {
741
+		    	$data['status_id'] = $ais_data['statusid'];
742
+		    }
743
+		    if (isset($ais_data['type'])) {
744
+		    	$data['type'] = $ais_data['type'];
745
+		    }
746
+		    if (isset($ais_data['typeid'])) {
747
+		    	$data['type_id'] = $ais_data['typeid'];
748
+		    }
749
+		    if (isset($ais_data['imo'])) {
750
+		    	$data['imo'] = $ais_data['imo'];
751
+		    }
752
+		    if (isset($ais_data['callsign'])) {
753
+		    	$data['callsign'] = $ais_data['callsign'];
754
+		    }
558 755
 		    if (isset($ais_data['timestamp'])) {
559 756
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
560 757
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -568,8 +765,12 @@  discard block
 block discarded – undo
568 765
 		    $data['format_source'] = 'aisnmeatxt';
569 766
     		    $data['id_source'] = $id_source;
570 767
 		    //print_r($data);
571
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
572
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
768
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
769
+		    	$data['noarchive'] = true;
770
+		    }
771
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
772
+		    	$MI->add($data);
773
+		    }
573 774
 		    unset($data);
574 775
 		}
575 776
     	    }
@@ -592,20 +793,48 @@  discard block
 block discarded – undo
592 793
 			    if ($line != '') {
593 794
 				$ais_data = $AIS->parse_line(trim($line));
594 795
 				$data = array();
595
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
596
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
597
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
598
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
599
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
600
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
601
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
602
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
603
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
604
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
605
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
606
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
607
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
608
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
796
+				if (isset($ais_data['ident'])) {
797
+					$data['ident'] = $ais_data['ident'];
798
+				}
799
+				if (isset($ais_data['mmsi'])) {
800
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
801
+				}
802
+				if (isset($ais_data['speed'])) {
803
+					$data['speed'] = $ais_data['speed'];
804
+				}
805
+				if (isset($ais_data['heading'])) {
806
+					$data['heading'] = $ais_data['heading'];
807
+				}
808
+				if (isset($ais_data['latitude'])) {
809
+					$data['latitude'] = $ais_data['latitude'];
810
+				}
811
+				if (isset($ais_data['longitude'])) {
812
+					$data['longitude'] = $ais_data['longitude'];
813
+				}
814
+				if (isset($ais_data['status'])) {
815
+					$data['status'] = $ais_data['status'];
816
+				}
817
+				if (isset($ais_data['statusid'])) {
818
+					$data['status_id'] = $ais_data['statusid'];
819
+				}
820
+				if (isset($ais_data['type'])) {
821
+					$data['type'] = $ais_data['type'];
822
+				}
823
+				if (isset($ais_data['typeid'])) {
824
+					$data['type_id'] = $ais_data['typeid'];
825
+				}
826
+				if (isset($ais_data['imo'])) {
827
+					$data['imo'] = $ais_data['imo'];
828
+				}
829
+				if (isset($ais_data['callsign'])) {
830
+					$data['callsign'] = $ais_data['callsign'];
831
+				}
832
+				if (isset($ais_data['destination'])) {
833
+					$data['arrival_code'] = $ais_data['destination'];
834
+				}
835
+				if (isset($ais_data['eta_ts'])) {
836
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
837
+				}
609 838
 				if (isset($ais_data['timestamp'])) {
610 839
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
611 840
 				} else {
@@ -613,18 +842,27 @@  discard block
 block discarded – undo
613 842
 				}
614 843
 				$data['format_source'] = 'aisnmeahttp';
615 844
 				$data['id_source'] = $id_source;
616
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
617
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
845
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
846
+					$data['noarchive'] = true;
847
+				}
848
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
849
+					$MI->add($data);
850
+				}
618 851
 				unset($data);
619 852
 			    }
620 853
 			}
621 854
 		    }
622 855
 		} else {
623 856
 		    $format = $value['format'];
624
-		    if (isset($tt[$format])) $tt[$format]++;
625
-		    else $tt[$format] = 0;
857
+		    if (isset($tt[$format])) {
858
+		    	$tt[$format]++;
859
+		    } else {
860
+		    	$tt[$format] = 0;
861
+		    }
626 862
 		    if ($tt[$format] > 30) {
627
-			if ($globalDebug) echo 'Reconnect...'."\n";
863
+			if ($globalDebug) {
864
+				echo 'Reconnect...'."\n";
865
+			}
628 866
 			sleep(2);
629 867
 			//$sourceeen[] = $value;
630 868
 			//connect_all($sourceeen);
@@ -660,12 +898,18 @@  discard block
 block discarded – undo
660 898
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
661 899
 			    //$data['type_id'] = $line['TYPE'];
662 900
 			    $data['imo'] = $line['IMO'];
663
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
664
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
901
+			    if ($line['DEST'] != '') {
902
+			    	$data['arrival_code'] = $line['DEST'];
903
+			    }
904
+			    if ($line['ARV'] != '') {
905
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
906
+			    }
665 907
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
666 908
 			    $data['format_source'] = 'myshiptracking';
667 909
 			    $data['id_source'] = $id_source;
668
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
910
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
911
+			    	$data['noarchive'] = true;
912
+			    }
669 913
 			    $MI->add($data);
670 914
 			    unset($data);
671 915
 			}
@@ -690,7 +934,9 @@  discard block
 block discarded – undo
690 934
 			    $data['callsign'] = $line['callsign'];
691 935
 			    $data['mmsi'] = substr($line['mmsi'],-9);
692 936
 			    $data['speed'] = $line['sog'];
693
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
937
+			    if ($line['heading'] != '511') {
938
+			    	$data['heading'] = $line['heading'];
939
+			    }
694 940
 			    $data['latitude'] = $line['latitude'];
695 941
 			    $data['longitude'] = $line['longitude'];
696 942
 			    $data['type_id'] = $line['shiptype'];
@@ -698,7 +944,9 @@  discard block
 block discarded – undo
698 944
 			    $data['datetime'] = $line['time'];
699 945
 			    $data['format_source'] = 'boatbeaconapp';
700 946
 			    $data['id_source'] = $id_source;
701
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
947
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
948
+			    	$data['noarchive'] = true;
949
+			    }
702 950
 			    $MI->add($data);
703 951
 			    unset($data);
704 952
 			}
@@ -720,22 +968,44 @@  discard block
 block discarded – undo
720 968
 		    foreach ($all_data['features'] as $line) {
721 969
 			print_r($line);
722 970
 			$data = array();
723
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
724
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
725
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
726
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
727
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
728
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
971
+			if (isset($line['properties']['name'])) {
972
+				$data['ident'] = $line['properties']['name'];
973
+			}
974
+			if (isset($line['properties']['callsign'])) {
975
+				$data['callsign'] = $line['properties']['callsign'];
976
+			}
977
+			if (isset($line['properties']['mmsi'])) {
978
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
979
+			}
980
+			if (isset($line['properties']['imo'])) {
981
+				$data['imo'] = $line['properties']['imo'];
982
+			}
983
+			if (isset($line['properties']['speed'])) {
984
+				$data['speed'] = $line['properties']['speed'];
985
+			}
986
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
987
+				$data['heading'] = $line['properties']['heading'];
988
+			}
729 989
 			$data['latitude'] = $line['geometry']['coordinates'][1];
730 990
 			$data['longitude'] = $line['geometry']['coordinates'][0];
731
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
732
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
733
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
991
+			if (isset($line['properties']['vesselType'])) {
992
+				$data['type'] = $line['properties']['vesselType'];
993
+			}
994
+			if (isset($line['properties']['destination'])) {
995
+				$data['arrival_code'] = $line['properties']['destination'];
996
+			}
997
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
998
+				$data['arrival_date'] = $line['properties']['eta'];
999
+			}
734 1000
 			$data['format_source'] = 'boatnerd';
735 1001
 			$data['id_source'] = $id_source;
736 1002
 			$data['datetime'] = date('Y-m-d H:i:s');
737
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
738
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
1003
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1004
+				$data['noarchive'] = true;
1005
+			}
1006
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
1007
+				$MI->add($data);
1008
+			}
739 1009
 			unset($data);
740 1010
 		    }
741 1011
 		}
@@ -748,11 +1018,17 @@  discard block
 block discarded – undo
748 1018
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
749 1019
 	    )
750 1020
 	) {
751
-	    if ($globalDebug) echo 'download...';
1021
+	    if ($globalDebug) {
1022
+	    	echo 'download...';
1023
+	    }
752 1024
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
753
-	    if ($globalDebug) echo 'done !'."\n";
1025
+	    if ($globalDebug) {
1026
+	    	echo 'done !'."\n";
1027
+	    }
754 1028
 	    // FIXME: Need more work
755
-	    if ($buffer != '') $reset = 0;
1029
+	    if ($buffer != '') {
1030
+	    	$reset = 0;
1031
+	    }
756 1032
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
757 1033
 	    $buffer = explode('\n',$buffer);
758 1034
 	    foreach ($buffer as $line) {
@@ -778,7 +1054,9 @@  discard block
 block discarded – undo
778 1054
 		    //$data['etaTime'] = substr($line,135,5);
779 1055
 		    $data['format_source'] = 'shipplotter';
780 1056
     		    $data['id_source'] = $id_source;
781
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1057
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1058
+		    	$data['noarchive'] = true;
1059
+		    }
782 1060
 		    //print_r($data);
783 1061
 		    //echo 'Add...'."\n";
784 1062
 		    $MI->add($data);
@@ -800,11 +1078,17 @@  discard block
 block discarded – undo
800 1078
 		}
801 1079
 	    }
802 1080
 
803
-	    if ($globalDebug) echo '! Download... ';
1081
+	    if ($globalDebug) {
1082
+	    	echo '! Download... ';
1083
+	    }
804 1084
 	    for ($i =0; $i <= 1; $i++) {
805
-		if ($globalDebug) echo 'Racetype: '.$i.' ';
1085
+		if ($globalDebug) {
1086
+			echo 'Racetype: '.$i.' ';
1087
+		}
806 1088
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
807
-	    if ($globalDebug) echo 'done'."\n";
1089
+	    if ($globalDebug) {
1090
+	    	echo 'done'."\n";
1091
+	    }
808 1092
 	    if ($buffer != '') {
809 1093
 		$all_data = json_decode($buffer,true);
810 1094
 		if (isset($all_data['missions'])) {
@@ -815,7 +1099,9 @@  discard block
 block discarded – undo
815 1099
 					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
816 1100
 						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
817 1101
 						sleep(30);
818
-					} else $racebuffer = '';
1102
+					} else {
1103
+						$racebuffer = '';
1104
+					}
819 1105
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
820 1106
 				} else {
821 1107
 					$bufferm = '';
@@ -879,7 +1165,9 @@  discard block
 block discarded – undo
879 1165
 								$data['captain_id'] = $sail['usrnr'];
880 1166
 								$data['captain_name'] = $sail['usrname'];
881 1167
 								$data['race_id'] = $sail['misnr'];
882
-								if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank'];
1168
+								if ($sail['rank'] != 'DNF') {
1169
+									$data['race_rank'] = $sail['rank'];
1170
+								}
883 1171
 								$data['race_time'] = $sail['racetime'];
884 1172
 								if ($mission_user != '') {
885 1173
 									$data['race_name'] = $mission_name.' ('.$mission_user.')';
@@ -889,7 +1177,9 @@  discard block
 block discarded – undo
889 1177
 								//$data['callsign'] = trim(substr($line,100,7);
890 1178
 								$data['format_source'] = 'sailawayfull';
891 1179
 								$data['id_source'] = $id_source;
892
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1180
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1181
+									$data['noarchive'] = true;
1182
+								}
893 1183
 								//print_r($data);
894 1184
 								//if ($data['race_id'] == '48') print_r($data);
895 1185
 								//echo 'Add...'."\n";
@@ -927,7 +1217,9 @@  discard block
 block discarded – undo
927 1217
 		echo 'Sailaway API key MUST be defined';
928 1218
 		exit(0);
929 1219
 	    }
930
-	    if ($globalDebug) echo '! Download... ';
1220
+	    if ($globalDebug) {
1221
+	    	echo '! Download... ';
1222
+	    }
931 1223
 	    $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?key='.$globalSailaway['key']);
932 1224
 	    if ($buffer != '') {
933 1225
 		$data = json_decode($buffer,true);
@@ -946,7 +1238,9 @@  discard block
 block discarded – undo
946 1238
 			$data['captain_name'] = $sail['usrname'];
947 1239
 			$data['format_source'] = 'sailaway';
948 1240
 			$data['id_source'] = $id_source;
949
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1241
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1242
+				$data['noarchive'] = true;
1243
+			}
950 1244
 			$MI->add($data);
951 1245
 			unset($data);
952 1246
 		    }
@@ -979,16 +1273,28 @@  discard block
 block discarded – undo
979 1273
     		    $line = explode(':', $line);
980 1274
     		    if (count($line) > 30 && $line[0] != 'callsign') {
981 1275
 			$data = array();
982
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
983
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1276
+			if (isset($line[37]) && $line[37] != '') {
1277
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1278
+			} else {
1279
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1280
+			}
984 1281
 			$data['pilot_id'] = $line[1];
985 1282
 			$data['pilot_name'] = $line[2];
986 1283
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
987 1284
 			$data['ident'] = $line[0]; // ident
988
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1285
+			if ($line[7] != '' && $line[7] != 0) {
1286
+				$data['altitude'] = $line[7];
1287
+			}
1288
+			// altitude
989 1289
 			$data['speed'] = $line[8]; // speed
990
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
991
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1290
+			if (isset($line[45])) {
1291
+				$data['heading'] = $line[45];
1292
+			}
1293
+			// heading
1294
+			elseif (isset($line[38])) {
1295
+				$data['heading'] = $line[38];
1296
+			}
1297
+			// heading
992 1298
 			$data['latitude'] = $line[5]; // lat
993 1299
 	        	$data['longitude'] = $line[6]; // long
994 1300
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -1004,7 +1310,9 @@  discard block
 block discarded – undo
1004 1310
 			$data['frequency'] = $line[4];
1005 1311
 			$data['type'] = $line[18];
1006 1312
 			$data['range'] = $line[19];
1007
-			if (isset($line[35])) $data['info'] = $line[35];
1313
+			if (isset($line[35])) {
1314
+				$data['info'] = $line[35];
1315
+			}
1008 1316
     			$data['id_source'] = $id_source;
1009 1317
 	    		//$data['arrival_airport_time'] = ;
1010 1318
 	    		if ($line[9] != '') {
@@ -1018,27 +1326,47 @@  discard block
 block discarded – undo
1018 1326
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
1019 1327
 	    		*/
1020 1328
 	    		$data['format_source'] = $value['format'];
1021
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1022
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1023
-    			if ($line[3] === 'PILOT') $SI->add($data);
1024
-			elseif ($line[3] === 'ATC') {
1329
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1330
+				$data['noarchive'] = true;
1331
+			}
1332
+			if (isset($value['name']) && $value['name'] != '') {
1333
+				$data['source_name'] = $value['name'];
1334
+			}
1335
+    			if ($line[3] === 'PILOT') {
1336
+    				$SI->add($data);
1337
+    			} elseif ($line[3] === 'ATC') {
1025 1338
 				//print_r($data);
1026 1339
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1027 1340
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
1028 1341
 				$typec = substr($data['ident'],-3);
1029
-				if ($typec === 'APP') $data['type'] = 'Approach';
1030
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
1031
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
1032
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
1033
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1034
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
1035
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1036
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1037
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
1038
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1342
+				if ($typec === 'APP') {
1343
+					$data['type'] = 'Approach';
1344
+				} elseif ($typec === 'TWR') {
1345
+					$data['type'] = 'Tower';
1346
+				} elseif ($typec === 'OBS') {
1347
+					$data['type'] = 'Observer';
1348
+				} elseif ($typec === 'GND') {
1349
+					$data['type'] = 'Ground';
1350
+				} elseif ($typec === 'DEL') {
1351
+					$data['type'] = 'Delivery';
1352
+				} elseif ($typec === 'DEP') {
1353
+					$data['type'] = 'Departure';
1354
+				} elseif ($typec === 'FSS') {
1355
+					$data['type'] = 'Flight Service Station';
1356
+				} elseif ($typec === 'CTR') {
1357
+					$data['type'] = 'Control Radar or Centre';
1358
+				} elseif ($data['type'] === '') {
1359
+					$data['type'] = 'Observer';
1360
+				}
1361
+				if (!isset($data['source_name'])) {
1362
+					$data['source_name'] = '';
1363
+				}
1039 1364
 				if (isset($ATC)) {
1040
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($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']);
1041
-					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']);
1365
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1366
+						echo $ATC->update($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']);
1367
+					} else {
1368
+						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']);
1369
+					}
1042 1370
 				}
1043 1371
 			}
1044 1372
     			unset($data);
@@ -1065,14 +1393,20 @@  discard block
 block discarded – undo
1065 1393
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1066 1394
 			$data['latitude'] = (float)$line['pktLatitude'];
1067 1395
 			$data['longitude'] = (float)$line['pktLongitude'];
1068
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1069
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1396
+			if ((float)$line['pktTrack'] != 0) {
1397
+				$data['heading'] = (float)$line['pktTrack'];
1398
+			}
1399
+			if ((int)$line['pktSpeed'] != 0) {
1400
+				$data['speed'] = (int)$line['pktSpeed'];
1401
+			}
1070 1402
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1071 1403
 			$data['altitude_relative'] = 'AMSL';
1072 1404
 			$data['pilot_id'] = (int)$line['pktPilotID'];
1073 1405
 			$data['aircraft_icao'] = 'PARAGLIDER';
1074 1406
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1075
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1407
+			if (isset($pilot_data[4])) {
1408
+				$data['pilot_name'] = $pilot_data[4];
1409
+			}
1076 1410
 			$data['format_source'] = $value['format'];
1077 1411
 			$SI->add($data);
1078 1412
 			unset($data);
@@ -1120,25 +1454,59 @@  discard block
 block discarded – undo
1120 1454
 		    foreach ($all_data['acList'] as $line) {
1121 1455
 			$data = array();
1122 1456
 			$data['hex'] = $line['Icao']; // hex
1123
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1124
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1125
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1126
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1127
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1128
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1457
+			if (isset($line['Call'])) {
1458
+				$data['ident'] = $line['Call'];
1459
+			}
1460
+			// ident
1461
+			if (isset($line['Alt'])) {
1462
+				$data['altitude'] = $line['Alt'];
1463
+			}
1464
+			// altitude
1465
+			if (isset($line['Spd'])) {
1466
+				$data['speed'] = $line['Spd'];
1467
+			}
1468
+			// speed
1469
+			if (isset($line['Trak'])) {
1470
+				$data['heading'] = $line['Trak'];
1471
+			}
1472
+			// heading
1473
+			if (isset($line['Lat'])) {
1474
+				$data['latitude'] = $line['Lat'];
1475
+			}
1476
+			// lat
1477
+			if (isset($line['Long'])) {
1478
+				$data['longitude'] = $line['Long'];
1479
+			}
1480
+			// long
1129 1481
 			//$data['verticalrate'] = $line['']; // verticale rate
1130
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1482
+			if (isset($line['Sqk'])) {
1483
+				$data['squawk'] = $line['Sqk'];
1484
+			}
1485
+			// squawk
1131 1486
 			$data['emergency'] = ''; // emergency
1132
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1133
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1134
-			else $data['datetime'] = date('Y-m-d H:i:s');
1487
+			if (isset($line['Reg'])) {
1488
+				$data['registration'] = $line['Reg'];
1489
+			}
1490
+			if (isset($line['PosTime'])) {
1491
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1492
+			} else {
1493
+				$data['datetime'] = date('Y-m-d H:i:s');
1494
+			}
1135 1495
 			//$data['datetime'] = date('Y-m-d H:i:s');
1136
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1496
+			if (isset($line['Type'])) {
1497
+				$data['aircraft_icao'] = $line['Type'];
1498
+			}
1137 1499
 			$data['format_source'] = 'aircraftlistjson';
1138 1500
 			$data['id_source'] = $id_source;
1139
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1140
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1141
-			if (isset($data['latitude'])) $SI->add($data);
1501
+			if (isset($value['name']) && $value['name'] != '') {
1502
+				$data['source_name'] = $value['name'];
1503
+			}
1504
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1505
+				$data['noarchive'] = true;
1506
+			}
1507
+			if (isset($data['latitude'])) {
1508
+				$SI->add($data);
1509
+			}
1142 1510
 			unset($data);
1143 1511
 		    }
1144 1512
 		} elseif (is_array($all_data)) {
@@ -1155,17 +1523,26 @@  discard block
 block discarded – undo
1155 1523
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1156 1524
 			$data['squawk'] = $line['squawk']; // squawk
1157 1525
 			$data['emergency'] = ''; // emergency
1158
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1159
-			else $data['datetime'] = date('Y-m-d H:i:s');
1526
+			if (isset($line['PosTime'])) {
1527
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1528
+			} else {
1529
+				$data['datetime'] = date('Y-m-d H:i:s');
1530
+			}
1160 1531
 			$data['format_source'] = 'aircraftlistjson';
1161 1532
 			$data['id_source'] = $id_source;
1162
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1163
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1533
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1534
+				$data['noarchive'] = true;
1535
+			}
1536
+			if (isset($value['name']) && $value['name'] != '') {
1537
+				$data['source_name'] = $value['name'];
1538
+			}
1164 1539
 			$SI->add($data);
1165 1540
 			unset($data);
1166 1541
 		    }
1167 1542
 		}
1168
-	    } elseif ($globalDebug) echo 'No data'."\n";
1543
+	    } elseif ($globalDebug) {
1544
+	    	echo 'No data'."\n";
1545
+	    }
1169 1546
     	    //$last_exec['aircraftlistjson'] = time();
1170 1547
     	    $last_exec[$id]['last'] = time();
1171 1548
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1201,8 +1578,12 @@  discard block
 block discarded – undo
1201 1578
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1202 1579
 	    	    $data['format_source'] = 'planeupdatefaa';
1203 1580
     		    $data['id_source'] = $id_source;
1204
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1205
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1581
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1582
+		    	$data['noarchive'] = true;
1583
+		    }
1584
+		    if (isset($value['name']) && $value['name'] != '') {
1585
+		    	$data['source_name'] = $value['name'];
1586
+		    }
1206 1587
 		    $SI->add($data);
1207 1588
 		    unset($data);
1208 1589
 		}
@@ -1236,7 +1617,9 @@  discard block
 block discarded – undo
1236 1617
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1237 1618
 		    $data['format_source'] = 'opensky';
1238 1619
 		    $data['id_source'] = $id_source;
1239
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1620
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1621
+		    	$data['noarchive'] = true;
1622
+		    }
1240 1623
 		    $SI->add($data);
1241 1624
 		    unset($data);
1242 1625
 		}
@@ -1256,15 +1639,42 @@  discard block
 block discarded – undo
1256 1639
 		foreach ($all_data['aircraft'] as $key => $line) {
1257 1640
 		    $data = array();
1258 1641
 		    // add support for ground vehicule with ~ in front of hex
1259
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1260
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1261
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1262
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1263
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1264
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1265
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1266
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1267
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1642
+		    if (isset($line['hex'])) {
1643
+		    	$data['hex'] = $line['hex'];
1644
+		    }
1645
+		    // hex
1646
+		    if (isset($line['flight'])) {
1647
+		    	$data['ident'] = trim($line['flight']);
1648
+		    }
1649
+		    // ident
1650
+		    if (isset($line['altitude'])) {
1651
+		    	$data['altitude'] = $line['altitude'];
1652
+		    }
1653
+		    // altitude
1654
+		    if (isset($line['speed'])) {
1655
+		    	$data['speed'] = $line['speed'];
1656
+		    }
1657
+		    // speed
1658
+		    if (isset($line['track'])) {
1659
+		    	$data['heading'] = $line['track'];
1660
+		    }
1661
+		    // heading
1662
+		    if (isset($line['lat'])) {
1663
+		    	$data['latitude'] = $line['lat'];
1664
+		    }
1665
+		    // lat
1666
+		    if (isset($line['lon'])) {
1667
+		    	$data['longitude'] = $line['lon'];
1668
+		    }
1669
+		    // long
1670
+		    if (isset($line['vert_rate'])) {
1671
+		    	$data['verticalrate'] = $line['vert_rate'];
1672
+		    }
1673
+		    // verticale rate
1674
+		    if (isset($line['squawk'])) {
1675
+		    	$data['squawk'] = $line['squawk'];
1676
+		    }
1677
+		    // squawk
1268 1678
 		    //$data['emergency'] = ''; // emergency
1269 1679
 		    //$data['registration'] = $line[2];
1270 1680
 		    //$data['aircraft_icao'] = $line[0];
@@ -1272,10 +1682,17 @@  discard block
 block discarded – undo
1272 1682
 		    $data['format_source'] = 'aircraftjson';
1273 1683
 		    $data['id_source'] = $id_source;
1274 1684
 		    if (isset($value['name']) && $value['name'] != '') {
1275
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1276
-			    else $data['source_name'] = $value['name'];
1277
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1278
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1685
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1686
+			    	$data['source_name'] = $value['name'].'_MLAT';
1687
+			    } else {
1688
+			    	$data['source_name'] = $value['name'];
1689
+			    }
1690
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1691
+		    	$data['source_name'] = 'MLAT';
1692
+		    }
1693
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1694
+		    	$data['noarchive'] = true;
1695
+		    }
1279 1696
 		    $SI->add($data);
1280 1697
 		    unset($data);
1281 1698
 		}
@@ -1295,22 +1712,54 @@  discard block
 block discarded – undo
1295 1712
 		foreach ($all_data['aircraft'] as $key => $line) {
1296 1713
 		    $data = array();
1297 1714
 		    $data['hex'] = $key; // hex
1298
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1299
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1300
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1301
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1302
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1303
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1304
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1305
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1715
+		    if (isset($line['callsign'])) {
1716
+		    	$data['ident'] = trim($line['callsign']);
1717
+		    }
1718
+		    // ident
1719
+		    if (isset($line['altitude'])) {
1720
+		    	$data['altitude'] = $line['altitude'];
1721
+		    }
1722
+		    // altitude
1723
+		    if (isset($line['speed'])) {
1724
+		    	$data['speed'] = $line['speed'];
1725
+		    }
1726
+		    // speed
1727
+		    if (isset($line['heading'])) {
1728
+		    	$data['heading'] = $line['heading'];
1729
+		    }
1730
+		    // heading
1731
+		    if (isset($line['lat'])) {
1732
+		    	$data['latitude'] = $line['lat'];
1733
+		    }
1734
+		    // lat
1735
+		    if (isset($line['lon'])) {
1736
+		    	$data['longitude'] = $line['lon'];
1737
+		    }
1738
+		    // long
1739
+		    if (isset($line['vert_rate'])) {
1740
+		    	$data['verticalrate'] = $line['vert_rate'];
1741
+		    }
1742
+		    // verticale rate
1743
+		    if (isset($line['squawk'])) {
1744
+		    	$data['squawk'] = $line['squawk'];
1745
+		    }
1746
+		    // squawk
1306 1747
 		    //$data['emergency'] = ''; // emergency
1307
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1308
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1748
+		    if (isset($line['reg'])) {
1749
+		    	$data['registration'] = $line['reg'];
1750
+		    }
1751
+		    if (isset($line['type'])) {
1752
+		    	$data['aircraft_icao'] = $line['type'];
1753
+		    }
1309 1754
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1310 1755
 		    $data['format_source'] = 'planefinderclient';
1311 1756
 		    $data['id_source'] = $id_source;
1312
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1313
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1757
+		    if (isset($value['name']) && $value['name'] != '') {
1758
+		    	$data['source_name'] = $value['name'];
1759
+		    }
1760
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1761
+		    	$data['noarchive'] = true;
1762
+		    }
1314 1763
 		    $SI->add($data);
1315 1764
 		    unset($data);
1316 1765
 		}
@@ -1326,7 +1775,9 @@  discard block
 block discarded – undo
1326 1775
 	    //$buffer = $Common->getData($hosts[$id]);
1327 1776
 	    $buffer = $Common->getData($value['host']);
1328 1777
 	    $all_data = json_decode($buffer,true);
1329
-	    if (!empty($all_data)) $reset = 0;
1778
+	    if (!empty($all_data)) {
1779
+	    	$reset = 0;
1780
+	    }
1330 1781
 	    foreach ($all_data as $key => $line) {
1331 1782
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1332 1783
 		    $data = array();
@@ -1347,8 +1798,12 @@  discard block
 block discarded – undo
1347 1798
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1348 1799
 	    	    $data['format_source'] = 'fr24json';
1349 1800
     		    $data['id_source'] = $id_source;
1350
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1351
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1801
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1802
+		    	$data['noarchive'] = true;
1803
+		    }
1804
+		    if (isset($value['name']) && $value['name'] != '') {
1805
+		    	$data['source_name'] = $value['name'];
1806
+		    }
1352 1807
 		    $SI->add($data);
1353 1808
 		    unset($data);
1354 1809
 		}
@@ -1377,24 +1832,42 @@  discard block
 block discarded – undo
1377 1832
 		    if (isset($line['inf'])) {
1378 1833
 			$data = array();
1379 1834
 			$data['hex'] = $line['inf']['ia'];
1380
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1835
+			if (isset($line['inf']['cs'])) {
1836
+				$data['ident'] = $line['inf']['cs'];
1837
+			}
1838
+			//$line[13]
1381 1839
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1382
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1383
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1840
+	    		if (isset($line['inf']['gs'])) {
1841
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1842
+	    		}
1843
+	    		// speed
1844
+	    		if (isset($line['inf']['tr'])) {
1845
+	    			$data['heading'] = $line['inf']['tr'];
1846
+	    		}
1847
+	    		// heading
1384 1848
 	    		$data['latitude'] = $line['pt'][0]; // lat
1385 1849
 	    		$data['longitude'] = $line['pt'][1]; // long
1386 1850
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1387
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1851
+	    		if (isset($line['inf']['sq'])) {
1852
+	    			$data['squawk'] = $line['inf']['sq'];
1853
+	    		}
1854
+	    		// squawk
1388 1855
 	    		//$data['aircraft_icao'] = $line[8];
1389
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1856
+	    		if (isset($line['inf']['rc'])) {
1857
+	    			$data['registration'] = $line['inf']['rc'];
1858
+	    		}
1390 1859
 			//$data['departure_airport_iata'] = $line[11];
1391 1860
 			//$data['arrival_airport_iata'] = $line[12];
1392 1861
 	    		//$data['emergency'] = ''; // emergency
1393 1862
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1394 1863
 	    		$data['format_source'] = 'radarvirtueljson';
1395 1864
     			$data['id_source'] = $id_source;
1396
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1397
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1865
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1866
+				$data['noarchive'] = true;
1867
+			}
1868
+			if (isset($value['name']) && $value['name'] != '') {
1869
+				$data['source_name'] = $value['name'];
1870
+			}
1398 1871
 			$SI->add($data);
1399 1872
 			unset($data);
1400 1873
 		    }
@@ -1420,30 +1893,65 @@  discard block
 block discarded – undo
1420 1893
 		    $data['id'] = $line['id'];
1421 1894
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1422 1895
 		    $data['ident'] = $line['callsign']; // ident
1423
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1424
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1425
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1426
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1427
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1428
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1896
+		    if (isset($line['pilotid'])) {
1897
+		    	$data['pilot_id'] = $line['pilotid'];
1898
+		    }
1899
+		    // pilot id
1900
+		    if (isset($line['name'])) {
1901
+		    	$data['pilot_name'] = $line['name'];
1902
+		    }
1903
+		    // pilot name
1904
+		    if (isset($line['alt'])) {
1905
+		    	$data['altitude'] = $line['alt'];
1906
+		    }
1907
+		    // altitude
1908
+		    if (isset($line['gs'])) {
1909
+		    	$data['speed'] = $line['gs'];
1910
+		    }
1911
+		    // speed
1912
+		    if (isset($line['heading'])) {
1913
+		    	$data['heading'] = $line['heading'];
1914
+		    }
1915
+		    // heading
1916
+		    if (isset($line['route'])) {
1917
+		    	$data['waypoints'] = $line['route'];
1918
+		    }
1919
+		    // route
1429 1920
 		    $data['latitude'] = $line['lat']; // lat
1430 1921
 		    $data['longitude'] = $line['lon']; // long
1431 1922
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1432 1923
 		    //$data['squawk'] = $line['squawk']; // squawk
1433 1924
 		    //$data['emergency'] = ''; // emergency
1434
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1435
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1436
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1925
+		    if (isset($line['depicao'])) {
1926
+		    	$data['departure_airport_icao'] = $line['depicao'];
1927
+		    }
1928
+		    if (isset($line['deptime'])) {
1929
+		    	$data['departure_airport_time'] = $line['deptime'];
1930
+		    }
1931
+		    if (isset($line['arricao'])) {
1932
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1933
+		    }
1437 1934
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1438
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1439
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1440
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1441
-		    else $data['info'] = '';
1935
+		    if (isset($line['aircraft'])) {
1936
+		    	$data['aircraft_icao'] = $line['aircraft'];
1937
+		    }
1938
+		    if (isset($line['transponder'])) {
1939
+		    	$data['squawk'] = $line['transponder'];
1940
+		    }
1941
+		    if (isset($line['atis'])) {
1942
+		    	$data['info'] = $line['atis'];
1943
+		    } else {
1944
+		    	$data['info'] = '';
1945
+		    }
1442 1946
 		    $data['format_source'] = 'pireps';
1443 1947
     		    $data['id_source'] = $id_source;
1444 1948
 		    $data['datetime'] = date('Y-m-d H:i:s');
1445
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1446
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1949
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1950
+		    	$data['noarchive'] = true;
1951
+		    }
1952
+		    if (isset($value['name']) && $value['name'] != '') {
1953
+		    	$data['source_name'] = $value['name'];
1954
+		    }
1447 1955
 		    if ($line['icon'] === 'plane') {
1448 1956
 			$SI->add($data);
1449 1957
 		    //    print_r($data);
@@ -1452,16 +1960,28 @@  discard block
 block discarded – undo
1452 1960
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1453 1961
 			$typec = substr($data['ident'],-3);
1454 1962
 			$data['type'] = '';
1455
-			if ($typec === 'APP') $data['type'] = 'Approach';
1456
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1457
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1458
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1459
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1460
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1461
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1462
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1463
-			else $data['type'] = 'Observer';
1464
-			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']);
1963
+			if ($typec === 'APP') {
1964
+				$data['type'] = 'Approach';
1965
+			} elseif ($typec === 'TWR') {
1966
+				$data['type'] = 'Tower';
1967
+			} elseif ($typec === 'OBS') {
1968
+				$data['type'] = 'Observer';
1969
+			} elseif ($typec === 'GND') {
1970
+				$data['type'] = 'Ground';
1971
+			} elseif ($typec === 'DEL') {
1972
+				$data['type'] = 'Delivery';
1973
+			} elseif ($typec === 'DEP') {
1974
+				$data['type'] = 'Departure';
1975
+			} elseif ($typec === 'FSS') {
1976
+				$data['type'] = 'Flight Service Station';
1977
+			} elseif ($typec === 'CTR') {
1978
+				$data['type'] = 'Control Radar or Centre';
1979
+			} else {
1980
+				$data['type'] = 'Observer';
1981
+			}
1982
+			if (isset($ATC)) {
1983
+				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']);
1984
+			}
1465 1985
 		    }
1466 1986
 		    unset($data);
1467 1987
 		}
@@ -1476,7 +1996,9 @@  discard block
 block discarded – undo
1476 1996
 	    )
1477 1997
 	) {
1478 1998
 	    //$buffer = $Common->getData($hosts[$id]);
1479
-	    if ($globalDebug) echo 'Get Data...'."\n";
1999
+	    if ($globalDebug) {
2000
+	    	echo 'Get Data...'."\n";
2001
+	    }
1480 2002
 	    $buffer = $Common->getData($value['host']);
1481 2003
 	    $all_data = json_decode($buffer,true);
1482 2004
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1484,10 +2006,16 @@  discard block
 block discarded – undo
1484 2006
 		foreach ($all_data as $line) {
1485 2007
 	    	    $data = array();
1486 2008
 	    	    //$data['id'] = $line['id']; // id not usable
1487
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
2009
+	    	    if (isset($line['pilotid'])) {
2010
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
2011
+	    	    }
1488 2012
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1489
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1490
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
2013
+	    	    if (isset($line['pilotname'])) {
2014
+	    	    	$data['pilot_name'] = $line['pilotname'];
2015
+	    	    }
2016
+	    	    if (isset($line['pilotid'])) {
2017
+	    	    	$data['pilot_id'] = $line['pilotid'];
2018
+	    	    }
1491 2019
 	    	    $data['ident'] = $line['flightnum']; // ident
1492 2020
 	    	    $data['altitude'] = $line['alt']; // altitude
1493 2021
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1503,7 +2031,9 @@  discard block
 block discarded – undo
1503 2031
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1504 2032
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1505 2033
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1506
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2034
+	    	    } else {
2035
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2036
+	    	    }
1507 2037
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1508 2038
 	    	    $data['departure_airport_time'] = $line['deptime'];
1509 2039
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1511,29 +2041,47 @@  discard block
 block discarded – undo
1511 2041
     		    if (isset($line['registration'])) {
1512 2042
     			$data['registration'] = $line['registration'];
1513 2043
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1514
-    		    } else $data['registration'] = $line['aircraft'];
1515
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1516
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2044
+    		    } else {
2045
+    		    	$data['registration'] = $line['aircraft'];
2046
+    		    }
2047
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2048
+		    	$data['noarchive'] = true;
2049
+		    }
2050
+		    if (isset($line['route'])) {
2051
+		    	$data['waypoints'] = $line['route'];
2052
+		    }
2053
+		    // route
1517 2054
 		    if (isset($line['aircraftname'])) {
1518 2055
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1519 2056
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1520 2057
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1521
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1522
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1523
-	    		else {
2058
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
2059
+	    			$data['aircraft_icao'] = $aircraft_data[0];
2060
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
2061
+	    			$data['aircraft_icao'] = $aircraft_data[1];
2062
+	    		} else {
1524 2063
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1525
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1526
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2064
+	    		    if (isset($aircraft_data[1])) {
2065
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
2066
+	    		    } else {
2067
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2068
+	    		    }
1527 2069
 	    		}
1528 2070
 	    	    }
1529
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
2071
+    		    if (isset($line['route'])) {
2072
+    		    	$data['waypoints'] = $line['route'];
2073
+    		    }
1530 2074
     		    $data['id_source'] = $id_source;
1531 2075
 	    	    $data['format_source'] = 'phpvmacars';
1532
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2076
+		    if (isset($value['name']) && $value['name'] != '') {
2077
+		    	$data['source_name'] = $value['name'];
2078
+		    }
1533 2079
 		    $SI->add($data);
1534 2080
 		    unset($data);
1535 2081
 		}
1536
-		if ($globalDebug) echo 'No more data...'."\n";
2082
+		if ($globalDebug) {
2083
+			echo 'No more data...'."\n";
2084
+		}
1537 2085
 		unset($buffer);
1538 2086
 		unset($all_data);
1539 2087
 	    }
@@ -1546,7 +2094,9 @@  discard block
 block discarded – undo
1546 2094
 	    )
1547 2095
 	) {
1548 2096
 	    //$buffer = $Common->getData($hosts[$id]);
1549
-	    if ($globalDebug) echo 'Get Data...'."\n";
2097
+	    if ($globalDebug) {
2098
+	    	echo 'Get Data...'."\n";
2099
+	    }
1550 2100
 	    $buffer = $Common->getData($value['host']);
1551 2101
 	    $all_data = json_decode($buffer,true);
1552 2102
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1557,10 +2107,16 @@  discard block
 block discarded – undo
1557 2107
 	    	    //$data['id'] = $line['id']; // id not usable
1558 2108
 	    	    $data['id'] = $line['id'];
1559 2109
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1560
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1561
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
2110
+	    	    if (isset($line['user']['username'])) {
2111
+	    	    	$data['pilot_name'] = $line['user']['username'];
2112
+	    	    }
2113
+	    	    if (isset($line['user_id'])) {
2114
+	    	    	$data['pilot_id'] = $line['user_id'];
2115
+	    	    }
1562 2116
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1563
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2117
+	    	    if (is_numeric($data['ident'])) {
2118
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2119
+	    	    }
1564 2120
 	    	    $data['altitude'] = $line['altitude']; // altitude
1565 2121
 	    	    $data['speed'] = $line['groundspeed']; // speed
1566 2122
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1573,7 +2129,9 @@  discard block
 block discarded – undo
1573 2129
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1574 2130
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1575 2131
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1576
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2132
+	    	    } else {
2133
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2134
+	    	    }
1577 2135
 	    	    
1578 2136
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1579 2137
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1581,17 +2139,26 @@  discard block
 block discarded – undo
1581 2139
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1582 2140
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1583 2141
 
1584
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1585
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2142
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2143
+		    	$data['noarchive'] = true;
2144
+		    }
2145
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2146
+		    	$data['waypoints'] = $line['bid']['route'];
2147
+		    }
2148
+		    // route
1586 2149
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1587 2150
 
1588 2151
     		    $data['id_source'] = $id_source;
1589 2152
 	    	    $data['format_source'] = 'vaos';
1590
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2153
+		    if (isset($value['name']) && $value['name'] != '') {
2154
+		    	$data['source_name'] = $value['name'];
2155
+		    }
1591 2156
 		    $SI->add($data);
1592 2157
 		    unset($data);
1593 2158
 		}
1594
-		if ($globalDebug) echo 'No more data...'."\n";
2159
+		if ($globalDebug) {
2160
+			echo 'No more data...'."\n";
2161
+		}
1595 2162
 		unset($buffer);
1596 2163
 		unset($all_data);
1597 2164
 	    }
@@ -1604,7 +2171,9 @@  discard block
 block discarded – undo
1604 2171
 	    )
1605 2172
 	) {
1606 2173
 	    //$buffer = $Common->getData($hosts[$id]);
1607
-	    if ($globalDebug) echo 'Get Data...'."\n";
2174
+	    if ($globalDebug) {
2175
+	    	echo 'Get Data...'."\n";
2176
+	    }
1608 2177
 	    $buffer = $Common->getData($value['host']);
1609 2178
 	    $all_data = json_decode($buffer,true);
1610 2179
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1633,16 +2202,25 @@  discard block
 block discarded – undo
1633 2202
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1634 2203
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1635 2204
     		    //$data['registration'] = $line['aircraft'];
1636
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2205
+		    if (isset($line['route'])) {
2206
+		    	$data['waypoints'] = $line['route'];
2207
+		    }
2208
+		    // route
1637 2209
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1638 2210
     		    $data['id_source'] = $id_source;
1639 2211
 	    	    $data['format_source'] = 'vam';
1640
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1641
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2212
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2213
+		    	$data['noarchive'] = true;
2214
+		    }
2215
+		    if (isset($value['name']) && $value['name'] != '') {
2216
+		    	$data['source_name'] = $value['name'];
2217
+		    }
1642 2218
 		    $SI->add($data);
1643 2219
 		    unset($data);
1644 2220
 		}
1645
-		if ($globalDebug) echo 'No more data...'."\n";
2221
+		if ($globalDebug) {
2222
+			echo 'No more data...'."\n";
2223
+		}
1646 2224
 		unset($buffer);
1647 2225
 		unset($all_data);
1648 2226
 	    }
@@ -1655,7 +2233,9 @@  discard block
 block discarded – undo
1655 2233
 	    )
1656 2234
 	) {
1657 2235
 	    //$buffer = $Common->getData($hosts[$id]);
1658
-	    if ($globalDebug) echo 'Get Data...'."\n";
2236
+	    if ($globalDebug) {
2237
+	    	echo 'Get Data...'."\n";
2238
+	    }
1659 2239
 	    $buffer = $Common->getData($value['host']);
1660 2240
 	    $all_data = json_decode($buffer,true);
1661 2241
 	    if ($buffer != '') {
@@ -1673,12 +2253,16 @@  discard block
 block discarded – undo
1673 2253
 			$data['id_source'] = $id_source;
1674 2254
 			$data['format_source'] = 'blitzortung';
1675 2255
 			$SI->add($data);
1676
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2256
+			if ($globalDebug) {
2257
+				echo '☈ Lightning added'."\n";
2258
+			}
1677 2259
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1678 2260
 			unset($data);
1679 2261
 		    }
1680 2262
 		}
1681
-		if ($globalDebug) echo 'No more data...'."\n";
2263
+		if ($globalDebug) {
2264
+			echo 'No more data...'."\n";
2265
+		}
1682 2266
 		unset($buffer);
1683 2267
 	    }
1684 2268
 	    $last_exec[$id]['last'] = time();
@@ -1707,10 +2291,15 @@  discard block
 block discarded – undo
1707 2291
                 }
1708 2292
             } else {
1709 2293
                 $format = $value['format'];
1710
-                if (isset($tt[$format])) $tt[$format]++;
1711
-                else $tt[$format] = 0;
2294
+                if (isset($tt[$format])) {
2295
+                	$tt[$format]++;
2296
+                } else {
2297
+                	$tt[$format] = 0;
2298
+                }
1712 2299
                 if ($tt[$format] > 30) {
1713
-                    if ($globalDebug) echo 'Reconnect...'."\n";
2300
+                    if ($globalDebug) {
2301
+                    	echo 'Reconnect...'."\n";
2302
+                    }
1714 2303
                     sleep(2);
1715 2304
                     //$sourceeen[] = $value;
1716 2305
                     //connect_all($sourceeen);
@@ -1727,7 +2316,9 @@  discard block
 block discarded – undo
1727 2316
 	    $write = NULL;
1728 2317
 	    $e = NULL;
1729 2318
 	    $n = socket_select($read, $write, $e, $timeout);
1730
-	    if ($e != NULL) var_dump($e);
2319
+	    if ($e != NULL) {
2320
+	    	var_dump($e);
2321
+	    }
1731 2322
 	    if ($n > 0) {
1732 2323
 		$reset = 0;
1733 2324
 		foreach ($read as $nb => $r) {
@@ -1749,13 +2340,17 @@  discard block
 block discarded – undo
1749 2340
 		    if ($buffer !== FALSE) {
1750 2341
 			if ($format === 'vrstcp') {
1751 2342
 			    $buffer = explode('},{',$buffer);
1752
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2343
+			} else {
2344
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2345
+			}
1753 2346
 		    }
1754 2347
 		    // SBS format is CSV format
1755 2348
 		    if ($buffer !== FALSE && $buffer !== '') {
1756 2349
 			$tt[$format] = 0;
1757 2350
 			if ($format === 'acarssbs3') {
1758
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2351
+			    if ($globalDebug) {
2352
+			    	echo 'ACARS : '.$buffer."\n";
2353
+			    }
1759 2354
 			    $ACARS->add(trim($buffer));
1760 2355
 			    $ACARS->deleteLiveAcarsData();
1761 2356
 			} elseif ($format === 'raw') {
@@ -1765,9 +2360,15 @@  discard block
 block discarded – undo
1765 2360
 				//if (!empty($data)) print_r($data);
1766 2361
 				$data['datetime'] = date('Y-m-d H:i:s');
1767 2362
 				$data['format_source'] = 'raw';
1768
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1769
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1770
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2363
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2364
+					$data['source_name'] = $globalSources[$nb]['name'];
2365
+				}
2366
+				if (isset($globalSources[$nb]['sourcestats'])) {
2367
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2368
+				}
2369
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2370
+					$data['noarchive'] = true;
2371
+				}
1771 2372
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1772 2373
 				$SI->add($data);
1773 2374
 				unset($data);
@@ -1775,22 +2376,54 @@  discard block
 block discarded – undo
1775 2376
 			} elseif ($format === 'ais') {
1776 2377
 			    $ais_data = $AIS->parse_line(trim($buffer));
1777 2378
 			    $data = array();
1778
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1779
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1780
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1781
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1782
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1783
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1784
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1785
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1786
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1787
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1788
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1789
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1790
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1791
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1792
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1793
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2379
+			    if (isset($ais_data['ident'])) {
2380
+			    	$data['ident'] = $ais_data['ident'];
2381
+			    }
2382
+			    if (isset($ais_data['mmsi'])) {
2383
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2384
+			    }
2385
+			    if (isset($ais_data['speed'])) {
2386
+			    	$data['speed'] = $ais_data['speed'];
2387
+			    }
2388
+			    if (isset($ais_data['heading'])) {
2389
+			    	$data['heading'] = $ais_data['heading'];
2390
+			    }
2391
+			    if (isset($ais_data['latitude'])) {
2392
+			    	$data['latitude'] = $ais_data['latitude'];
2393
+			    }
2394
+			    if (isset($ais_data['longitude'])) {
2395
+			    	$data['longitude'] = $ais_data['longitude'];
2396
+			    }
2397
+			    if (isset($ais_data['status'])) {
2398
+			    	$data['status'] = $ais_data['status'];
2399
+			    }
2400
+			    if (isset($ais_data['statusid'])) {
2401
+			    	$data['status_id'] = $ais_data['statusid'];
2402
+			    }
2403
+			    if (isset($ais_data['type'])) {
2404
+			    	$data['type'] = $ais_data['type'];
2405
+			    }
2406
+			    if (isset($ais_data['imo'])) {
2407
+			    	$data['imo'] = $ais_data['imo'];
2408
+			    }
2409
+			    if (isset($ais_data['callsign'])) {
2410
+			    	$data['callsign'] = $ais_data['callsign'];
2411
+			    }
2412
+			    if (isset($ais_data['destination'])) {
2413
+			    	$data['arrival_code'] = $ais_data['destination'];
2414
+			    }
2415
+			    if (isset($ais_data['eta_ts'])) {
2416
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2417
+			    }
2418
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2419
+			    	$data['noarchive'] = true;
2420
+			    }
2421
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2422
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2423
+			    }
2424
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2425
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2426
+			    }
1794 2427
 
1795 2428
 			    if (isset($ais_data['timestamp'])) {
1796 2429
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1799,7 +2432,9 @@  discard block
 block discarded – undo
1799 2432
 			    }
1800 2433
 			    $data['format_source'] = 'aisnmea';
1801 2434
     			    $data['id_source'] = $id_source;
1802
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2435
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2436
+			    	$MI->add($data);
2437
+			    }
1803 2438
 			    unset($data);
1804 2439
                         } elseif ($format === 'flightgearsp') {
1805 2440
                     	    //echo $buffer."\n";
@@ -1817,17 +2452,25 @@  discard block
 block discarded – undo
1817 2452
 				$data['speed'] = round($line[5]*1.94384);
1818 2453
 				$data['datetime'] = date('Y-m-d H:i:s');
1819 2454
 				$data['format_source'] = 'flightgearsp';
1820
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1821
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2455
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2456
+					$data['noarchive'] = true;
2457
+				}
2458
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2459
+					$SI->add($data);
2460
+				}
1822 2461
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1823 2462
 			    }
1824 2463
                         } elseif ($format === 'acars') {
1825
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2464
+                    	    if ($globalDebug) {
2465
+                    	    	echo 'ACARS : '.$buffer."\n";
2466
+                    	    }
1826 2467
 			    $ACARS->add(trim($buffer));
1827 2468
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1828 2469
 			    $ACARS->deleteLiveAcarsData();
1829 2470
 			} elseif ($format === 'acarsjsonudp') {
1830
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2471
+			    if ($globalDebug) {
2472
+			    	echo 'ACARS : '.$buffer."\n";
2473
+			    }
1831 2474
                             $line = json_decode(trim($buffer), true);
1832 2475
                             if (!empty($line)) {
1833 2476
 				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
@@ -1852,8 +2495,12 @@  discard block
 block discarded – undo
1852 2495
 				    $aircraft_type = $line[10];
1853 2496
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1854 2497
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1855
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1856
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2498
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2499
+				    	$data['noarchive'] = true;
2500
+				    }
2501
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2502
+				    	$SI->add($data);
2503
+				    }
1857 2504
 				}
1858 2505
 			    }
1859 2506
 			} elseif ($format === 'beast') {
@@ -1863,28 +2510,62 @@  discard block
 block discarded – undo
1863 2510
 			    foreach($buffer as $all_data) {
1864 2511
 				$line = json_decode('{'.$all_data.'}',true);
1865 2512
 				$data = array();
1866
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1867
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1868
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1869
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1870
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1871
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1872
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2513
+				if (isset($line['Icao'])) {
2514
+					$data['hex'] = $line['Icao'];
2515
+				}
2516
+				// hex
2517
+				if (isset($line['Call'])) {
2518
+					$data['ident'] = $line['Call'];
2519
+				}
2520
+				// ident
2521
+				if (isset($line['Alt'])) {
2522
+					$data['altitude'] = $line['Alt'];
2523
+				}
2524
+				// altitude
2525
+				if (isset($line['Spd'])) {
2526
+					$data['speed'] = $line['Spd'];
2527
+				}
2528
+				// speed
2529
+				if (isset($line['Trak'])) {
2530
+					$data['heading'] = $line['Trak'];
2531
+				}
2532
+				// heading
2533
+				if (isset($line['Lat'])) {
2534
+					$data['latitude'] = $line['Lat'];
2535
+				}
2536
+				// lat
2537
+				if (isset($line['Long'])) {
2538
+					$data['longitude'] = $line['Long'];
2539
+				}
2540
+				// long
1873 2541
 				//$data['verticalrate'] = $line['']; // verticale rate
1874
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2542
+				if (isset($line['Sqk'])) {
2543
+					$data['squawk'] = $line['Sqk'];
2544
+				}
2545
+				// squawk
1875 2546
 				$data['emergency'] = ''; // emergency
1876
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2547
+				if (isset($line['Reg'])) {
2548
+					$data['registration'] = $line['Reg'];
2549
+				}
1877 2550
 				/*
1878 2551
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1879 2552
 				else $data['datetime'] = date('Y-m-d H:i:s');
1880 2553
 				*/
1881 2554
 				$data['datetime'] = date('Y-m-d H:i:s');
1882
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2555
+				if (isset($line['Type'])) {
2556
+					$data['aircraft_icao'] = $line['Type'];
2557
+				}
1883 2558
 		    		$data['format_source'] = 'vrstcp';
1884 2559
 				$data['id_source'] = $id_source;
1885
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1886
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1887
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2560
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2561
+					$data['noarchive'] = true;
2562
+				}
2563
+				if (isset($value['name']) && $value['name'] != '') {
2564
+					$data['source_name'] = $value['name'];
2565
+				}
2566
+				if (isset($data['latitude']) && isset($data['hex'])) {
2567
+					$SI->add($data);
2568
+				}
1888 2569
 				unset($data);
1889 2570
 			    }
1890 2571
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1897,22 +2578,46 @@  discard block
 block discarded – undo
1897 2578
     				$data['hex'] = $lined['hexid'];
1898 2579
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1899 2580
     				$data['datetime'] = date('Y-m-d H:i:s');;
1900
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1901
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1902
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1903
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1904
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1905
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1906
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2581
+    				if (isset($lined['ident'])) {
2582
+    					$data['ident'] = $lined['ident'];
2583
+    				}
2584
+    				if (isset($lined['lat'])) {
2585
+    					$data['latitude'] = $lined['lat'];
2586
+    				}
2587
+    				if (isset($lined['lon'])) {
2588
+    					$data['longitude'] = $lined['lon'];
2589
+    				}
2590
+    				if (isset($lined['speed'])) {
2591
+    					$data['speed'] = $lined['speed'];
2592
+    				}
2593
+    				if (isset($lined['squawk'])) {
2594
+    					$data['squawk'] = $lined['squawk'];
2595
+    				}
2596
+    				if (isset($lined['alt'])) {
2597
+    					$data['altitude'] = $lined['alt'];
2598
+    				}
2599
+    				if (isset($lined['heading'])) {
2600
+    					$data['heading'] = $lined['heading'];
2601
+    				}
1907 2602
     				$data['id_source'] = $id_source;
1908 2603
     				$data['format_source'] = 'tsv';
1909
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1910
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1911
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1912
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2604
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2605
+    					$data['source_name'] = $globalSources[$nb]['name'];
2606
+    				}
2607
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2608
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2609
+    				}
2610
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2611
+					$data['noarchive'] = true;
2612
+				}
2613
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2614
+    					$SI->add($data);
2615
+    				}
1913 2616
     				unset($lined);
1914 2617
     				unset($data);
1915
-    			    } else $error = true;
2618
+    			    } else {
2619
+    			    	$error = true;
2620
+    			    }
1916 2621
 			} elseif ($format === 'aprs' && $use_aprs) {
1917 2622
 			    if ($aprs_connect === 0) {
1918 2623
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1938,47 +2643,96 @@  discard block
 block discarded – undo
1938 2643
 				    $aprs_last_tx = time();
1939 2644
 				    $data = array();
1940 2645
 				    //print_r($line);
1941
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1942
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1943
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1944
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1945
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1946
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1947
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1948
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1949
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1950
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2646
+				    if (isset($line['address'])) {
2647
+				    	$data['hex'] = $line['address'];
2648
+				    }
2649
+				    if (isset($line['mmsi'])) {
2650
+				    	$data['mmsi'] = $line['mmsi'];
2651
+				    }
2652
+				    if (isset($line['imo'])) {
2653
+				    	$data['imo'] = $line['imo'];
2654
+				    }
2655
+				    if (isset($line['squawk'])) {
2656
+				    	$data['squawk'] = $line['squawk'];
2657
+				    }
2658
+				    if (isset($line['arrival_code'])) {
2659
+				    	$data['arrival_code'] = $line['arrival_code'];
2660
+				    }
2661
+				    if (isset($line['arrival_date'])) {
2662
+				    	$data['arrival_date'] = $line['arrival_date'];
2663
+				    }
2664
+				    if (isset($line['typeid'])) {
2665
+				    	$data['type_id'] = $line['typeid'];
2666
+				    }
2667
+				    if (isset($line['statusid'])) {
2668
+				    	$data['status_id'] = $line['statusid'];
2669
+				    }
2670
+				    if (isset($line['timestamp'])) {
2671
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2672
+				    } else {
2673
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2674
+				    }
1951 2675
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1952
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2676
+				    if (isset($line['ident'])) {
2677
+				    	$data['ident'] = $line['ident'];
2678
+				    }
1953 2679
 				    $data['latitude'] = $line['latitude'];
1954 2680
 				    $data['longitude'] = $line['longitude'];
1955 2681
 				    //$data['verticalrate'] = $line[16];
1956
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2682
+				    if (isset($line['speed'])) {
2683
+				    	$data['speed'] = $line['speed'];
2684
+				    }
1957 2685
 				    //else $data['speed'] = 0;
1958
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1959
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1960
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2686
+				    if (isset($line['altitude'])) {
2687
+				    	$data['altitude'] = $line['altitude'];
2688
+				    }
2689
+				    if (isset($line['comment'])) {
2690
+				    	$data['comment'] = $line['comment'];
2691
+				    }
2692
+				    if (isset($line['symbol'])) {
2693
+				    	$data['type'] = $line['symbol'];
2694
+				    }
1961 2695
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1962 2696
 				    
1963
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2697
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2698
+				    	$data['heading'] = $line['heading'];
2699
+				    }
1964 2700
 				    //else echo 'No heading...'."\n";
1965 2701
 				    //else $data['heading'] = 0;
1966
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2702
+				    if (isset($line['stealth'])) {
2703
+				    	$data['aircraft_type'] = $line['stealth'];
2704
+				    }
1967 2705
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1968
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1969
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1970
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1971
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2706
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2707
+				    	$data['noarchive'] = true;
2708
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2709
+				    	$data['noarchive'] = false;
2710
+				    }
2711
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2712
+				    	$data['noarchive'] = true;
2713
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2714
+				    	$data['noarchive'] = false;
2715
+				    }
1972 2716
     				    $data['id_source'] = $id_source;
1973
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1974
-				    else $data['format_source'] = 'aprs';
2717
+    				    if (isset($line['format_source'])) {
2718
+    				    	$data['format_source'] = $line['format_source'];
2719
+    				    } else {
2720
+				    	$data['format_source'] = 'aprs';
2721
+				    }
1975 2722
 				    $data['source_name'] = $line['source'];
1976
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1977
-				    else $data['source_type'] = 'flarm';
1978
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2723
+				    if (isset($line['source_type'])) {
2724
+				    	$data['source_type'] = $line['source_type'];
2725
+				    } else {
2726
+				    	$data['source_type'] = 'flarm';
2727
+				    }
2728
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2729
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2730
+    				    }
1979 2731
 				    $currentdate = date('Y-m-d H:i:s');
1980 2732
 				    $aprsdate = strtotime($data['datetime']);
1981
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2733
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2734
+				    	$data['altitude_relative'] = 'AMSL';
2735
+				    }
1982 2736
 				    // Accept data if time <= system time + 20s
1983 2737
 				    //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'])))) {
1984 2738
 				    if (
@@ -1990,7 +2744,9 @@  discard block
 block discarded – undo
1990 2744
 					$send = $SI->add($data);
1991 2745
 				    } elseif ($data['source_type'] === 'ais') {
1992 2746
 					$data['type'] = '';
1993
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2747
+					if (isset($globalMarine) && $globalMarine) {
2748
+						$send = $MI->add($data);
2749
+					}
1994 2750
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1995 2751
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1996 2752
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1998,8 +2754,12 @@  discard block
 block discarded – undo
1998 2754
 					    $line['symbol'] === 'Glider' || 
1999 2755
 					    $line['symbol'] === 'No. Plane' || 
2000 2756
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
2001
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
2002
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2757
+					    if ($line['symbol'] === 'Ballon') {
2758
+					    	$data['aircraft_icao'] = 'BALL';
2759
+					    }
2760
+					    if ($line['symbol'] === 'Glider') {
2761
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2762
+					    }
2003 2763
 					    $send = $SI->add($data);
2004 2764
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
2005 2765
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -2030,9 +2790,13 @@  discard block
 block discarded – undo
2030 2790
 				    //} 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') {
2031 2791
 				//    } 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') {
2032 2792
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
2033
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2793
+					if (isset($globalTracker) && $globalTracker) {
2794
+						$send = $TI->add($data);
2795
+					}
2034 2796
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
2035
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2797
+					if (!isset($data['altitude'])) {
2798
+						$data['altitude'] = 0;
2799
+					}
2036 2800
 					$Source->deleteOldLocationByType('gs');
2037 2801
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
2038 2802
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -2041,7 +2805,9 @@  discard block
 block discarded – undo
2041 2805
 					}
2042 2806
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
2043 2807
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2044
-					if ($globalDebug) echo '# Weather Station added'."\n";
2808
+					if ($globalDebug) {
2809
+						echo '# Weather Station added'."\n";
2810
+					}
2045 2811
 					$Source->deleteOldLocationByType('wx');
2046 2812
 					$weather_data = json_encode($line);
2047 2813
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -2051,7 +2817,9 @@  discard block
 block discarded – undo
2051 2817
 					}
2052 2818
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2053 2819
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2054
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2820
+					if ($globalDebug) {
2821
+						echo '☈ Lightning added'."\n";
2822
+					}
2055 2823
 					$Source->deleteOldLocationByType('lightning');
2056 2824
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2057 2825
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -2063,8 +2831,7 @@  discard block
 block discarded – undo
2063 2831
 				    	print_r($line);
2064 2832
 				    }
2065 2833
 				    unset($data);
2066
-				}
2067
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2834
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2068 2835
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2069 2836
 				}
2070 2837
 				/*
@@ -2073,7 +2840,9 @@  discard block
 block discarded – undo
2073 2840
 				}
2074 2841
 				*/
2075 2842
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2076
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2843
+				elseif ($line === true && $globalDebug) {
2844
+					echo '!! Failed : '.$buffer."!!\n";
2845
+				}
2077 2846
 				if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2078 2847
 					$Source->deleteOldLocationByType('lightning');
2079 2848
 					$Source->deleteOldLocationByType('wx');
@@ -2110,27 +2879,47 @@  discard block
 block discarded – undo
2110 2879
     				$data['ground'] = $line[21];
2111 2880
     				$data['emergency'] = $line[19];
2112 2881
     				$data['format_source'] = 'sbs';
2113
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2114
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2115
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2116
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2882
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2883
+					$data['source_name'] = $globalSources[$nb]['name'];
2884
+				} elseif ($line[0] == 'MLAT') {
2885
+					$data['source_name'] = 'MLAT';
2886
+				}
2887
+				if (isset($globalSources[$nb]['sourcestats'])) {
2888
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2889
+				}
2890
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2891
+					$data['noarchive'] = true;
2892
+				}
2117 2893
     				$data['id_source'] = $id_source;
2118
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2119
-    				else $error = true;
2894
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2895
+    					$send = $SI->add($data);
2896
+    				} else {
2897
+    					$error = true;
2898
+    				}
2120 2899
     				unset($data);
2121
-    			    } else $error = true;
2900
+    			    } else {
2901
+    			    	$error = true;
2902
+    			    }
2122 2903
 			    if ($error) {
2123 2904
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2124
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2905
+					if ($globalDebug) {
2906
+						echo "Not a message. Ignoring... \n";
2907
+					}
2125 2908
 				} else {
2126
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2909
+					if ($globalDebug) {
2910
+						echo "Wrong line format. Ignoring... \n";
2911
+					}
2127 2912
 					if ($globalDebug) {
2128 2913
 						echo $buffer;
2129 2914
 						//print_r($line);
2130 2915
 					}
2131 2916
 					//socket_close($r);
2132
-					if ($globalDebug) echo "Reconnect after an error...\n";
2133
-					if ($format === 'aprs') $aprs_connect = 0;
2917
+					if ($globalDebug) {
2918
+						echo "Reconnect after an error...\n";
2919
+					}
2920
+					if ($format === 'aprs') {
2921
+						$aprs_connect = 0;
2922
+					}
2134 2923
 					$sourceer[$nb] = $globalSources[$nb];
2135 2924
 					connect_all($sourceer);
2136 2925
 					$sourceer = array();
@@ -2138,10 +2927,14 @@  discard block
 block discarded – undo
2138 2927
 			    }
2139 2928
 			}
2140 2929
 			// Sleep for xxx microseconds
2141
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2930
+			if (isset($globalSBSSleep)) {
2931
+				usleep($globalSBSSleep);
2932
+			}
2142 2933
 		    } else {
2143 2934
 			if ($format === 'flightgearmp') {
2144
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2935
+			    	if ($globalDebug) {
2936
+			    		echo "Reconnect FlightGear MP...";
2937
+			    	}
2145 2938
 				//@socket_close($r);
2146 2939
 				sleep($globalMinFetch);
2147 2940
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2150,10 +2943,15 @@  discard block
 block discarded – undo
2150 2943
 				break;
2151 2944
 				
2152 2945
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2153
-			    if (isset($tt[$format])) $tt[$format]++;
2154
-			    else $tt[$format] = 0;
2946
+			    if (isset($tt[$format])) {
2947
+			    	$tt[$format]++;
2948
+			    } else {
2949
+			    	$tt[$format] = 0;
2950
+			    }
2155 2951
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2156
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2952
+				if ($globalDebug) {
2953
+					echo "ERROR : Reconnect ".$format."...";
2954
+				}
2157 2955
 				//@socket_close($r);
2158 2956
 				sleep(2);
2159 2957
 				$aprs_connect = 0;
@@ -2171,11 +2969,17 @@  discard block
 block discarded – undo
2171 2969
 	    } else {
2172 2970
 		$error = socket_strerror(socket_last_error());
2173 2971
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2174
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2175
-			if (isset($globalDebug)) echo "Restarting...\n";
2972
+			if ($globalDebug) {
2973
+				echo "ERROR : socket_select give this error ".$error . "\n";
2974
+			}
2975
+			if (isset($globalDebug)) {
2976
+				echo "Restarting...\n";
2977
+			}
2176 2978
 			// Restart the script if possible
2177 2979
 			if (is_array($sockets)) {
2178
-			    if ($globalDebug) echo "Shutdown all sockets...";
2980
+			    if ($globalDebug) {
2981
+			    	echo "Shutdown all sockets...";
2982
+			    }
2179 2983
 			    
2180 2984
 			    foreach ($sockets as $sock) {
2181 2985
 				@socket_shutdown($sock,2);
@@ -2183,25 +2987,45 @@  discard block
 block discarded – undo
2183 2987
 			    }
2184 2988
 			    
2185 2989
 			}
2186
-			if ($globalDebug) echo "Waiting...";
2990
+			if ($globalDebug) {
2991
+				echo "Waiting...";
2992
+			}
2187 2993
 			sleep(2);
2188 2994
 			$time = time();
2189 2995
 			//connect_all($hosts);
2190 2996
 			$aprs_connect = 0;
2191
-			if ($reset%5 === 0) sleep(20);
2192
-			if ($reset%10 === 0) sleep(100);
2193
-			if ($reset%20 === 0) sleep(200);
2194
-			if ($reset > 100) exit('Too many attempts...');
2195
-			if ($globalDebug) echo "Restart all connections...";
2997
+			if ($reset%5 === 0) {
2998
+				sleep(20);
2999
+			}
3000
+			if ($reset%10 === 0) {
3001
+				sleep(100);
3002
+			}
3003
+			if ($reset%20 === 0) {
3004
+				sleep(200);
3005
+			}
3006
+			if ($reset > 100) {
3007
+				exit('Too many attempts...');
3008
+			}
3009
+			if ($globalDebug) {
3010
+				echo "Restart all connections...";
3011
+			}
2196 3012
 			connect_all($globalSources);
2197 3013
 		}
2198 3014
 	    }
2199 3015
 	}
2200 3016
 	if ($globalDaemon === false) {
2201
-	    if ($globalDebug) echo 'Check all...'."\n";
2202
-	    if (isset($SI)) $SI->checkAll();
2203
-	    if (isset($TI)) $TI->checkAll();
2204
-	    if (isset($MI)) $MI->checkAll();
3017
+	    if ($globalDebug) {
3018
+	    	echo 'Check all...'."\n";
3019
+	    }
3020
+	    if (isset($SI)) {
3021
+	    	$SI->checkAll();
3022
+	    }
3023
+	    if (isset($TI)) {
3024
+	    	$TI->checkAll();
3025
+	    }
3026
+	    if (isset($MI)) {
3027
+	    	$MI->checkAll();
3028
+	    }
2205 3029
 	}
2206 3030
     }
2207 3031
 }
Please login to merge, or discard this patch.
install/index.php 2 patches
Spacing   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 require_once(dirname(__FILE__).'/class.create_db.php');
24 24
 require_once(dirname(__FILE__).'/class.update_schema.php');
25 25
 require_once(dirname(__FILE__).'/class.settings.php');
26
-$title="Install";
26
+$title = "Install";
27 27
 require(dirname(__FILE__).'/../require/settings.php');
28 28
 require_once(dirname(__FILE__).'/../require/class.Common.php');
29 29
 require(dirname(__FILE__).'/header.php');
30 30
 
31 31
 if (!isset($_SESSION['install']) && !isset($_SESSION['identified'])) {
32
-	$password = filter_input(INPUT_POST,'password',FILTER_SANITIZE_STRING);
32
+	$password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
33 33
 	if ($password == '') {
34 34
 		if ($globalInstalled === TRUE && (!isset($globalInstallPassword) || $globalInstallPassword == '')) {
35 35
 			print '<div class="alert alert-danger">You need to change $globalInstalled in settings.php to FALSE if you want to access setup again.</div>';
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	if (!file_exists(dirname(__FILE__).'/../.htaccess')) {
111 111
 		$error[] = dirname(__FILE__).'/../.htaccess'." doesn't exist. The provided .htaccess must exist if you use Apache.";
112 112
 	}
113
-	if(function_exists('apache_get_modules') ){
114
-		if(!in_array('mod_rewrite',apache_get_modules())) {
113
+	if (function_exists('apache_get_modules')) {
114
+		if (!in_array('mod_rewrite', apache_get_modules())) {
115 115
 			$error[] = "mod_rewrite is not available.";
116 116
 		}
117 117
 	/*
@@ -130,22 +130,22 @@  discard block
 block discarded – undo
130 130
 		$alllng = $Language->listLocaleDir();
131 131
 		if (count($alllng) != count($availablelng)) {
132 132
 			$notavailable = array();
133
-			foreach($alllng as $lng) {
133
+			foreach ($alllng as $lng) {
134 134
 				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
135 135
 			}
136
-			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
136
+			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ', $notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
137 137
 		}
138 138
 	}
139 139
 	print '<div class="alert alert-info">If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some tables can fail.</div>';
140 140
 	if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
141 141
 		if (function_exists('get_headers')) {
142 142
 			//$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
143
-			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'live/geojson?test',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
144
-			if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
143
+			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/', 'install'), 'live/geojson?test', str_replace('index.php', '', $_SERVER["REQUEST_URI"])));
144
+			if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
145 145
 				print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
146 146
 			} else {
147
-				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
148
-				if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
147
+				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/', 'install'), 'search', str_replace('index.php', '', $_SERVER["REQUEST_URI"])));
148
+				if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
149 149
 					print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
150 150
 				}
151 151
 			}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 				    if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
234 234
 					if (isset($_SERVER['REQUEST_URI'])) {
235 235
 						$URL = $_SERVER['REQUEST_URI'];
236
-						$globalURL = str_replace('/install','',str_replace('/install/','',str_replace('/install/index.php','',$URL)));
236
+						$globalURL = str_replace('/install', '', str_replace('/install/', '', str_replace('/install/index.php', '', $URL)));
237 237
 					}
238 238
 				    }
239 239
 				?>
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 ?>
584 584
 							<tr>
585 585
 								<?php
586
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
586
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
587 587
 								?>
588 588
 								<td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td>
589 589
 								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
590 590
 								<?php
591 591
 								    } else {
592
-									$hostport = explode(':',$source['host']);
592
+									$hostport = explode(':', $source['host']);
593 593
 									if (isset($hostport[1])) {
594 594
 										$host = $hostport[0];
595 595
 										$port = $hostport[1];
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 									<select name="timezones[]">
645 645
 								<?php
646 646
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
647
-									foreach($timezonelist as $timezones){
647
+									foreach ($timezonelist as $timezones) {
648 648
 										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
649 649
 											print '<option selected>'.$timezones.'</option>';
650 650
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 									<select name="timezones[]" id="timezones">
705 705
 								<?php
706 706
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
707
-									foreach($timezonelist as $timezones){
707
+									foreach ($timezonelist as $timezones) {
708 708
 										if ($timezones == 'UTC') {
709 709
 											print '<option selected>'.$timezones.'</option>';
710 710
 										} else print '<option>'.$timezones.'</option>';
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 			<br />
1185 1185
 			<p>
1186 1186
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1187
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1187
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
1188 1188
 			</p>
1189 1189
 			<br />
1190 1190
 			<p>
@@ -1267,17 +1267,17 @@  discard block
 block discarded – undo
1267 1267
 $error = '';
1268 1268
 
1269 1269
 if (isset($_POST['dbtype'])) {
1270
-	$installpass = filter_input(INPUT_POST,'installpass',FILTER_SANITIZE_STRING);
1271
-	$settings = array_merge($settings,array('globalInstallPassword' => $installpass));
1270
+	$installpass = filter_input(INPUT_POST, 'installpass', FILTER_SANITIZE_STRING);
1271
+	$settings = array_merge($settings, array('globalInstallPassword' => $installpass));
1272 1272
 
1273
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
1274
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
1275
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
1276
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
1277
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
1278
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
1279
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1280
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1273
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
1274
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
1275
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
1276
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
1277
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
1278
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
1279
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
1280
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
1281 1281
 
1282 1282
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1283 1283
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -1297,60 +1297,60 @@  discard block
 block discarded – undo
1297 1297
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1298 1298
 	*/
1299 1299
 	
1300
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1300
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
1301 1301
 
1302
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
1303
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
1304
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
1305
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
1306
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
1302
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
1303
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
1304
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
1305
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
1306
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
1307 1307
 
1308
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
1309
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
1310
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
1311
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
1312
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
1313
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
1314
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
1315
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
1316
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
1317
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
1308
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
1309
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
1310
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
1311
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
1312
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
1313
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
1314
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
1315
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
1316
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
1317
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
1318 1318
 	
1319
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
1320
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
1321
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
1322
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
1323
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
1324
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
1319
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
1320
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
1321
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
1322
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
1323
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
1324
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
1325 1325
 
1326
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
1327
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
1326
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
1327
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
1328 1328
 
1329
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
1330
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
1331
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
1329
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
1330
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
1331
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
1332 1332
 
1333
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
1333
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
1334 1334
 	if ($acars == 'acars') {
1335
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
1335
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
1336 1336
 	} else {
1337
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
1337
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
1338 1338
 	}
1339
-	$updatecheck = filter_input(INPUT_POST,'updatecheck',FILTER_SANITIZE_STRING);
1339
+	$updatecheck = filter_input(INPUT_POST, 'updatecheck', FILTER_SANITIZE_STRING);
1340 1340
 	if ($updatecheck == 'updatecheck') {
1341
-		$settings = array_merge($settings,array('globalDisableUpdateCheck' => 'TRUE'));
1341
+		$settings = array_merge($settings, array('globalDisableUpdateCheck' => 'TRUE'));
1342 1342
 	} else {
1343
-		$settings = array_merge($settings,array('globalDisableUpdateCheck' => 'FALSE'));
1343
+		$settings = array_merge($settings, array('globalDisableUpdateCheck' => 'FALSE'));
1344 1344
 	}
1345 1345
 
1346
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1347
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1348
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1346
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
1347
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
1348
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
1349 1349
 	
1350
-	$sailawayemail = filter_input(INPUT_POST,'sailawayemail',FILTER_SANITIZE_STRING);
1351
-	$sailawaypass = filter_input(INPUT_POST,'sailawaypassword',FILTER_SANITIZE_STRING);
1352
-	$sailawaykey = filter_input(INPUT_POST,'sailawaykey',FILTER_SANITIZE_STRING);
1353
-	$settings = array_merge($settings,array('globalSailaway' => array('email' => $sailawayemail,'password' => $sailawaypass,'key' => $sailawaykey)));
1350
+	$sailawayemail = filter_input(INPUT_POST, 'sailawayemail', FILTER_SANITIZE_STRING);
1351
+	$sailawaypass = filter_input(INPUT_POST, 'sailawaypassword', FILTER_SANITIZE_STRING);
1352
+	$sailawaykey = filter_input(INPUT_POST, 'sailawaykey', FILTER_SANITIZE_STRING);
1353
+	$settings = array_merge($settings, array('globalSailaway' => array('email' => $sailawayemail, 'password' => $sailawaypass, 'key' => $sailawaykey)));
1354 1354
 	
1355 1355
 	$source_name = $_POST['source_name'];
1356 1356
 	$source_latitude = $_POST['source_latitude'];
@@ -1364,8 +1364,8 @@  discard block
 block discarded – undo
1364 1364
 	
1365 1365
 	$sources = array();
1366 1366
 	foreach ($source_name as $keys => $name) {
1367
-	    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]);
1368
-	    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]);
1367
+	    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]);
1368
+	    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]);
1369 1369
 	}
1370 1370
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1371 1371
 
@@ -1374,16 +1374,16 @@  discard block
 block discarded – undo
1374 1374
 	$newstype = $_POST['newstype'];
1375 1375
 	
1376 1376
 	$newsfeeds = array();
1377
-	foreach($newsurl as $newskey => $url) {
1377
+	foreach ($newsurl as $newskey => $url) {
1378 1378
 	    if ($url != '') {
1379 1379
 		$type = $newstype[$newskey];
1380 1380
 		$lng = $newslng[$newskey];
1381 1381
 		if (isset($newsfeeds[$type][$lng])) {
1382
-		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1382
+		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng], array($url));
1383 1383
 		} else $newsfeeds[$type][$lng] = array($url);
1384 1384
 	    }
1385 1385
 	}
1386
-	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1386
+	$settings = array_merge($settings, array('globalNewsFeeds' => $newsfeeds));
1387 1387
 
1388 1388
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1389 1389
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1394,28 +1394,28 @@  discard block
 block discarded – undo
1394 1394
 	$sbsurl = $_POST['sbsurl'];
1395 1395
 	*/
1396 1396
 
1397
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1398
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1399
-	$globalvm = filter_input(INPUT_POST,'globalvm',FILTER_SANITIZE_STRING);
1400
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1401
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1402
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1403
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1404
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1405
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1397
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1398
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1399
+	$globalvm = filter_input(INPUT_POST, 'globalvm', FILTER_SANITIZE_STRING);
1400
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1401
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1402
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1403
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1404
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1405
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1406 1406
 
1407
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1408
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1409
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1410
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1411
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1412
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1413
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1414
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1415
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1416
-	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1417
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1418
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1407
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
1408
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
1409
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
1410
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
1411
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
1412
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
1413
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
1414
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
1415
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
1416
+	$globalsatellite = filter_input(INPUT_POST, 'globalsatellite', FILTER_SANITIZE_STRING);
1417
+	if ($globalsatellite == 'satellite') $settings = array_merge($settings, array('globalSatellite' => 'TRUE'));
1418
+	else $settings = array_merge($settings, array('globalSatellite' => 'FALSE'));
1419 1419
 
1420 1420
 /*	
1421 1421
 	$globalSBS1Hosts = array();
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 	}
1432 1432
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1433 1433
 */
1434
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1434
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1435 1435
 	$host = $_POST['host'];
1436 1436
 	$port = $_POST['port'];
1437 1437
 	$name = $_POST['name'];
@@ -1448,115 +1448,115 @@  discard block
 block discarded – undo
1448 1448
 		else $cov = 'FALSE';
1449 1449
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1450 1450
 		else $arch = 'FALSE';
1451
-		if (strpos($format[$key],'_callback')) {
1452
-			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1451
+		if (strpos($format[$key], '_callback')) {
1452
+			$gSources[] = array('host' => $h, 'pass' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'TRUE');
1453 1453
 		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1454
-			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1454
+			$gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'FALSE');
1455 1455
 		}
1456 1456
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1457 1457
 	}
1458
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1458
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1459 1459
 
1460 1460
 /*
1461 1461
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1462 1462
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1463 1463
 */
1464
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1465
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1466
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1464
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1465
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1466
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1467 1467
 
1468
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1469
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1468
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1469
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1470 1470
 
1471
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1472
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1471
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1472
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1473 1473
 
1474
-	$map3dtile = filter_input(INPUT_POST,'map3dtileset',FILTER_SANITIZE_STRING);
1475
-	$settings = array_merge($settings,array('globalMap3DTiles' => $map3dtile));
1474
+	$map3dtile = filter_input(INPUT_POST, 'map3dtileset', FILTER_SANITIZE_STRING);
1475
+	$settings = array_merge($settings, array('globalMap3DTiles' => $map3dtile));
1476 1476
 
1477
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1478
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1479
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1480
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1477
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1478
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1479
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1480
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1481 1481
 
1482
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1483
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1484
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1482
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1483
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1484
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1485 1485
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1486
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1487
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1486
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1487
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1488 1488
 
1489
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1490
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1491
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1492
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1493
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1494
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1495
-	$minfetch = filter_input(INPUT_POST,'minfetch',FILTER_SANITIZE_NUMBER_INT);
1496
-	$settings = array_merge($settings,array('globalMinFetch' => $minfetch));
1497
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1498
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1489
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1490
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1491
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1492
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1493
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1494
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1495
+	$minfetch = filter_input(INPUT_POST, 'minfetch', FILTER_SANITIZE_NUMBER_INT);
1496
+	$settings = array_merge($settings, array('globalMinFetch' => $minfetch));
1497
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1498
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1499 1499
 
1500
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1501
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1500
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1501
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1502 1502
 
1503
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1504
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1503
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1504
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1505 1505
 	
1506
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1506
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1507 1507
 	if ($archiveyear == "archiveyear") {
1508
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1508
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1509 1509
 	} else {
1510
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1510
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1511 1511
 	}
1512
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1513
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1514
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1515
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1512
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1513
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1514
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1515
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1516 1516
 
1517
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1518
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1519
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1520
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1517
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1518
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1519
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1520
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1521 1521
 
1522
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1523
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1524
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1522
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1523
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1524
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1525 1525
 
1526 1526
 	// Create in settings.php keys not yet configurable if not already here
1527 1527
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1528
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1528
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1529 1529
 
1530
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1530
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1531 1531
 	if ($resetyearstats == 'resetyearstats') {
1532
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1532
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1533 1533
 	} else {
1534
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1534
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1535 1535
 	}
1536 1536
 
1537
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1537
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1538 1538
 	if ($archive == 'archive') {
1539
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1539
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1540 1540
 	} else {
1541
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1541
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1542 1542
 	}
1543
-	$archiveresults = filter_input(INPUT_POST,'archiveresults',FILTER_SANITIZE_STRING);
1543
+	$archiveresults = filter_input(INPUT_POST, 'archiveresults', FILTER_SANITIZE_STRING);
1544 1544
 	if ($archiveresults == 'archiveresults') {
1545
-		$settings = array_merge($settings,array('globalArchiveResults' => 'TRUE'));
1545
+		$settings = array_merge($settings, array('globalArchiveResults' => 'TRUE'));
1546 1546
 	} else {
1547
-		$settings = array_merge($settings,array('globalArchiveResults' => 'FALSE'));
1547
+		$settings = array_merge($settings, array('globalArchiveResults' => 'FALSE'));
1548 1548
 	}
1549
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1549
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1550 1550
 	if ($daemon == 'daemon') {
1551
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1551
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1552 1552
 	} else {
1553
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1553
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1554 1554
 	}
1555
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1555
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1556 1556
 	if ($schedules == 'schedules') {
1557
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1557
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1558 1558
 	} else {
1559
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1559
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1560 1560
 	}
1561 1561
 
1562 1562
 /*
@@ -1567,311 +1567,311 @@  discard block
 block discarded – undo
1567 1567
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1568 1568
 	}
1569 1569
 */
1570
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1571
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1572
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1573
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1574
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1570
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1571
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1572
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1573
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1574
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1575 1575
 	$va = false;
1576 1576
 	if ($globalivao == 'ivao') {
1577
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1577
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1578 1578
 		$va = true;
1579
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1579
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1580 1580
 	if ($globalvatsim == 'vatsim') {
1581
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1581
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1582 1582
 		$va = true;
1583
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1583
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1584 1584
 	if ($globalphpvms == 'phpvms') {
1585
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1585
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1586 1586
 		$va = true;
1587
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1587
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1588 1588
 	if ($globalvam == 'vam') {
1589
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1589
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1590 1590
 		$va = true;
1591
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1591
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1592 1592
 	if ($va) {
1593
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1594
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1593
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1594
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1595 1595
 	if ($globalva == 'va' || $va) {
1596
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1597
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1596
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1597
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1598 1598
 	} else {
1599
-		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1600
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1601
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1599
+		$settings = array_merge($settings, array('globalVA' => 'FALSE'));
1600
+		if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1601
+		else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE'));
1602 1602
 	}
1603 1603
 	if ($globalvm == 'vm') {
1604
-		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
1604
+		$settings = array_merge($settings, array('globalVM' => 'TRUE'));
1605 1605
 	} else {
1606
-		$settings = array_merge($settings,array('globalVM' => 'FALSE'));
1606
+		$settings = array_merge($settings, array('globalVM' => 'FALSE'));
1607 1607
 	}
1608 1608
 	
1609
-	$mapoffline = filter_input(INPUT_POST,'mapoffline',FILTER_SANITIZE_STRING);
1609
+	$mapoffline = filter_input(INPUT_POST, 'mapoffline', FILTER_SANITIZE_STRING);
1610 1610
 	if ($mapoffline == 'mapoffline') {
1611
-		$settings = array_merge($settings,array('globalMapOffline' => 'TRUE'));
1611
+		$settings = array_merge($settings, array('globalMapOffline' => 'TRUE'));
1612 1612
 	} else {
1613
-		$settings = array_merge($settings,array('globalMapOffline' => 'FALSE'));
1613
+		$settings = array_merge($settings, array('globalMapOffline' => 'FALSE'));
1614 1614
 	}
1615
-	$globaloffline = filter_input(INPUT_POST,'globaloffline',FILTER_SANITIZE_STRING);
1615
+	$globaloffline = filter_input(INPUT_POST, 'globaloffline', FILTER_SANITIZE_STRING);
1616 1616
 	if ($globaloffline == 'globaloffline') {
1617
-		$settings = array_merge($settings,array('globalOffline' => 'TRUE'));
1617
+		$settings = array_merge($settings, array('globalOffline' => 'TRUE'));
1618 1618
 	} else {
1619
-		$settings = array_merge($settings,array('globalOffline' => 'FALSE'));
1619
+		$settings = array_merge($settings, array('globalOffline' => 'FALSE'));
1620 1620
 	}
1621 1621
 
1622
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1622
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1623 1623
 	if ($notam == 'notam') {
1624
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1624
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1625 1625
 	} else {
1626
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1626
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1627 1627
 	}
1628
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1628
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1629 1629
 	if ($owner == 'owner') {
1630
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1630
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1631 1631
 	} else {
1632
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1632
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1633 1633
 	}
1634
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1634
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1635 1635
 	if ($map3d == 'map3d') {
1636
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1636
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1637 1637
 	} else {
1638
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1638
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1639 1639
 	}
1640
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1640
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1641 1641
 	if ($crash == 'crash') {
1642
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1642
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1643 1643
 	} else {
1644
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1644
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1645 1645
 	}
1646
-	$fires = filter_input(INPUT_POST,'fires',FILTER_SANITIZE_STRING);
1646
+	$fires = filter_input(INPUT_POST, 'fires', FILTER_SANITIZE_STRING);
1647 1647
 	if ($fires == 'fires') {
1648
-		$settings = array_merge($settings,array('globalMapFires' => 'TRUE'));
1648
+		$settings = array_merge($settings, array('globalMapFires' => 'TRUE'));
1649 1649
 	} else {
1650
-		$settings = array_merge($settings,array('globalMapFires' => 'FALSE'));
1650
+		$settings = array_merge($settings, array('globalMapFires' => 'FALSE'));
1651 1651
 	}
1652
-	$firessupport = filter_input(INPUT_POST,'firessupport',FILTER_SANITIZE_STRING);
1652
+	$firessupport = filter_input(INPUT_POST, 'firessupport', FILTER_SANITIZE_STRING);
1653 1653
 	if ($firessupport == 'firessupport') {
1654
-		$settings = array_merge($settings,array('globalFires' => 'TRUE'));
1654
+		$settings = array_merge($settings, array('globalFires' => 'TRUE'));
1655 1655
 	} else {
1656
-		$settings = array_merge($settings,array('globalFires' => 'FALSE'));
1656
+		$settings = array_merge($settings, array('globalFires' => 'FALSE'));
1657 1657
 	}
1658
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1658
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1659 1659
 	if ($mapsatellites == 'mapsatellites') {
1660
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1660
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1661 1661
 	} else {
1662
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1662
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1663 1663
 	}
1664
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1664
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1665 1665
 	if ($map3ddefault == 'map3ddefault') {
1666
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1666
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1667 1667
 	} else {
1668
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1668
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1669 1669
 	}
1670
-	$one3dmodel = filter_input(INPUT_POST,'one3dmodel',FILTER_SANITIZE_STRING);
1670
+	$one3dmodel = filter_input(INPUT_POST, 'one3dmodel', FILTER_SANITIZE_STRING);
1671 1671
 	if ($one3dmodel == 'one3dmodel') {
1672
-		$settings = array_merge($settings,array('globalMap3DOneModel' => 'TRUE'));
1672
+		$settings = array_merge($settings, array('globalMap3DOneModel' => 'TRUE'));
1673 1673
 	} else {
1674
-		$settings = array_merge($settings,array('globalMap3DOneModel' => 'FALSE'));
1674
+		$settings = array_merge($settings, array('globalMap3DOneModel' => 'FALSE'));
1675 1675
 	}
1676
-	$map3dliveries = filter_input(INPUT_POST,'map3dliveries',FILTER_SANITIZE_STRING);
1676
+	$map3dliveries = filter_input(INPUT_POST, 'map3dliveries', FILTER_SANITIZE_STRING);
1677 1677
 	if ($map3dliveries == 'map3dliveries') {
1678
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'TRUE'));
1678
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'TRUE'));
1679 1679
 	} else {
1680
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'FALSE'));
1680
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'FALSE'));
1681 1681
 	}
1682
-	$map3dshadows = filter_input(INPUT_POST,'map3dshadows',FILTER_SANITIZE_STRING);
1682
+	$map3dshadows = filter_input(INPUT_POST, 'map3dshadows', FILTER_SANITIZE_STRING);
1683 1683
 	if ($map3dshadows == 'map3dshadows') {
1684
-		$settings = array_merge($settings,array('globalMap3DShadows' => 'TRUE'));
1684
+		$settings = array_merge($settings, array('globalMap3DShadows' => 'TRUE'));
1685 1685
 	} else {
1686
-		$settings = array_merge($settings,array('globalMap3DShadows' => 'FALSE'));
1686
+		$settings = array_merge($settings, array('globalMap3DShadows' => 'FALSE'));
1687 1687
 	}
1688
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1688
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1689 1689
 	if ($translate == 'translate') {
1690
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1690
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1691 1691
 	} else {
1692
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1692
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1693 1693
 	}
1694
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1694
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1695 1695
 	if ($realairlines == 'realairlines') {
1696
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1696
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1697 1697
 	} else {
1698
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1698
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1699 1699
 	}
1700
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1700
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1701 1701
 	if ($estimation == 'estimation') {
1702
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1702
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1703 1703
 	} else {
1704
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1704
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1705 1705
 	}
1706
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1706
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1707 1707
 	if ($metar == 'metar') {
1708
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1708
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1709 1709
 	} else {
1710
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1710
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1711 1711
 	}
1712
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1712
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1713 1713
 	if ($metarcycle == 'metarcycle') {
1714
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1714
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1715 1715
 	} else {
1716
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1716
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1717 1717
 	}
1718
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1718
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1719 1719
 	if ($fork == 'fork') {
1720
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1720
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1721 1721
 	} else {
1722
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1722
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1723 1723
 	}
1724 1724
 
1725
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1725
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1726 1726
 	if ($colormap == 'colormap') {
1727
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1727
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1728 1728
 	} else {
1729
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1729
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1730 1730
 	}
1731 1731
 	
1732 1732
 	if (isset($_POST['aircrafticoncolor'])) {
1733
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1734
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1733
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1734
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1735 1735
 	}
1736 1736
 	if (isset($_POST['marineiconcolor'])) {
1737
-		$marineiconcolor = filter_input(INPUT_POST,'marineiconcolor',FILTER_SANITIZE_STRING);
1738
-		$settings = array_merge($settings,array('globalMarineIconColor' => substr($marineiconcolor,1)));
1737
+		$marineiconcolor = filter_input(INPUT_POST, 'marineiconcolor', FILTER_SANITIZE_STRING);
1738
+		$settings = array_merge($settings, array('globalMarineIconColor' => substr($marineiconcolor, 1)));
1739 1739
 	}
1740 1740
 	if (isset($_POST['trackericoncolor'])) {
1741
-		$trackericoncolor = filter_input(INPUT_POST,'trackericoncolor',FILTER_SANITIZE_STRING);
1742
-		$settings = array_merge($settings,array('globalTrackerIconColor' => substr($trackericoncolor,1)));
1741
+		$trackericoncolor = filter_input(INPUT_POST, 'trackericoncolor', FILTER_SANITIZE_STRING);
1742
+		$settings = array_merge($settings, array('globalTrackerIconColor' => substr($trackericoncolor, 1)));
1743 1743
 	}
1744 1744
 	if (isset($_POST['satelliteiconcolor'])) {
1745
-		$satelliteiconcolor = filter_input(INPUT_POST,'satelliteiconcolor',FILTER_SANITIZE_STRING);
1746
-		$settings = array_merge($settings,array('globalSatelliteIconColor' => substr($satelliteiconcolor,1)));
1745
+		$satelliteiconcolor = filter_input(INPUT_POST, 'satelliteiconcolor', FILTER_SANITIZE_STRING);
1746
+		$settings = array_merge($settings, array('globalSatelliteIconColor' => substr($satelliteiconcolor, 1)));
1747 1747
 	}
1748 1748
 
1749
-	$corsproxy = filter_input(INPUT_POST,'corsproxy',FILTER_SANITIZE_STRING);
1750
-	$settings = array_merge($settings,array('globalCORSproxy' => $corsproxy));
1749
+	$corsproxy = filter_input(INPUT_POST, 'corsproxy', FILTER_SANITIZE_STRING);
1750
+	$settings = array_merge($settings, array('globalCORSproxy' => $corsproxy));
1751 1751
 
1752
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1753
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1752
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1753
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1754 1754
 
1755
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1756
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1757
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1758
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1759
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1760
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1755
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1756
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1757
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1758
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1759
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1760
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1761 1761
 
1762
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1762
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1763 1763
 	if ($mappopup == 'mappopup') {
1764
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1764
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1765 1765
 	} else {
1766
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1766
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1767 1767
 	}
1768
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1768
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1769 1769
 	if ($airportpopup == 'airportpopup') {
1770
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1770
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1771 1771
 	} else {
1772
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1772
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1773 1773
 	}
1774
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1774
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1775 1775
 	if ($maphistory == 'maphistory') {
1776
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1776
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1777 1777
 	} else {
1778
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1778
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1779 1779
 	}
1780
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1780
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1781 1781
 	if ($maptooltip == 'maptooltip') {
1782
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1782
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1783 1783
 	} else {
1784
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1784
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1785 1785
 	}
1786
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1786
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1787 1787
 	if ($flightroute == 'flightroute') {
1788
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1788
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1789 1789
 	} else {
1790
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1790
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1791 1791
 	}
1792
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1792
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1793 1793
 	if ($flightremainingroute == 'flightremainingroute') {
1794
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1794
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1795 1795
 	} else {
1796
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1796
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1797 1797
 	}
1798
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1798
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1799 1799
 	if ($allflights == 'allflights') {
1800
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1800
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1801 1801
 	} else {
1802
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1802
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1803 1803
 	}
1804
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1804
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1805 1805
 	if ($bbox == 'bbox') {
1806
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1806
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1807 1807
 	} else {
1808
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1808
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1809 1809
 	}
1810
-	$singlemodel = filter_input(INPUT_POST,'singlemodel',FILTER_SANITIZE_STRING);
1810
+	$singlemodel = filter_input(INPUT_POST, 'singlemodel', FILTER_SANITIZE_STRING);
1811 1811
 	if ($singlemodel == 'singlemodel') {
1812
-		$settings = array_merge($settings,array('globalMap3DSelected' => 'TRUE'));
1812
+		$settings = array_merge($settings, array('globalMap3DSelected' => 'TRUE'));
1813 1813
 	} else {
1814
-		$settings = array_merge($settings,array('globalMap3DSelected' => 'FALSE'));
1814
+		$settings = array_merge($settings, array('globalMap3DSelected' => 'FALSE'));
1815 1815
 	}
1816
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1816
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1817 1817
 	if ($groundaltitude == 'groundaltitude') {
1818
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1818
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1819 1819
 	} else {
1820
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1820
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1821 1821
 	}
1822
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1822
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1823 1823
 	if ($waypoints == 'waypoints') {
1824
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1824
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1825 1825
 	} else {
1826
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1826
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1827 1827
 	}
1828
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1828
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1829 1829
 	if ($geoid == 'geoid') {
1830
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1830
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1831 1831
 	} else {
1832
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1832
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1833 1833
 	}
1834
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1835
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1834
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1835
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1836 1836
 
1837
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1837
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1838 1838
 	if ($noairlines == 'noairlines') {
1839
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1839
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1840 1840
 	} else {
1841
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1841
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1842 1842
 	}
1843 1843
 
1844
-	$tsk = filter_input(INPUT_POST,'tsk',FILTER_SANITIZE_STRING);
1844
+	$tsk = filter_input(INPUT_POST, 'tsk', FILTER_SANITIZE_STRING);
1845 1845
 	if ($tsk == 'tsk') {
1846
-		$settings = array_merge($settings,array('globalTSK' => 'TRUE'));
1846
+		$settings = array_merge($settings, array('globalTSK' => 'TRUE'));
1847 1847
 	} else {
1848
-		$settings = array_merge($settings,array('globalTSK' => 'FALSE'));
1848
+		$settings = array_merge($settings, array('globalTSK' => 'FALSE'));
1849 1849
 	}
1850
-	$mapmatching = filter_input(INPUT_POST,'mapmatching',FILTER_SANITIZE_STRING);
1850
+	$mapmatching = filter_input(INPUT_POST, 'mapmatching', FILTER_SANITIZE_STRING);
1851 1851
 	if ($mapmatching == 'mapmatching') {
1852
-		$settings = array_merge($settings,array('globalMapMatching' => 'TRUE'));
1852
+		$settings = array_merge($settings, array('globalMapMatching' => 'TRUE'));
1853 1853
 	} else {
1854
-		$settings = array_merge($settings,array('globalMapMatching' => 'FALSE'));
1854
+		$settings = array_merge($settings, array('globalMapMatching' => 'FALSE'));
1855 1855
 	}
1856
-	$mapmatchingsource = filter_input(INPUT_POST,'mapmatchingsource',FILTER_SANITIZE_STRING);
1857
-	$settings = array_merge($settings,array('globalMapMatchingSource' => $mapmatchingsource));
1858
-	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1859
-	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1856
+	$mapmatchingsource = filter_input(INPUT_POST, 'mapmatchingsource', FILTER_SANITIZE_STRING);
1857
+	$settings = array_merge($settings, array('globalMapMatchingSource' => $mapmatchingsource));
1858
+	$graphhopper = filter_input(INPUT_POST, 'graphhopper', FILTER_SANITIZE_STRING);
1859
+	$settings = array_merge($settings, array('globalGraphHopperKey' => $graphhopper));
1860 1860
 
1861
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1861
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1862 1862
 
1863 1863
 	// Set some defaults values...
1864 1864
 	if (!isset($globalAircraftImageSources)) {
1865
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1866
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1865
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1866
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1867 1867
 	}
1868 1868
 
1869 1869
 	if (!isset($globalSchedulesSources)) {
1870
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1871
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1870
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1871
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1872 1872
     	}
1873 1873
 
1874
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1874
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1875 1875
 
1876 1876
 	if ($error == '') settings::modify_settings($settings);
1877 1877
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
Braces   +659 added lines, -175 removed lines patch added patch discarded remove patch
@@ -4,12 +4,22 @@  discard block
 block discarded – undo
4 4
 if (isset($_SESSION['error'])) {
5 5
 	header('Content-Encoding: none;');
6 6
 	echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.';
7
-	if (isset($_SESSION['error'])) unset($_SESSION['error']);
8
-	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
9
-	if (isset($_SESSION['next'])) unset($_SESSION['next']);
10
-	if (isset($_SESSION['install'])) unset($_SESSION['install']);
11
-	if (isset($_SESSION['identitied'])) unset($_SESSION['identified']);
12
-}
7
+	if (isset($_SESSION['error'])) {
8
+		unset($_SESSION['error']);
9
+	}
10
+	if (isset($_SESSION['errorlst'])) {
11
+		unset($_SESSION['errorlst']);
12
+	}
13
+	if (isset($_SESSION['next'])) {
14
+		unset($_SESSION['next']);
15
+	}
16
+	if (isset($_SESSION['install'])) {
17
+		unset($_SESSION['install']);
18
+	}
19
+	if (isset($_SESSION['identitied'])) {
20
+		unset($_SESSION['identified']);
21
+	}
22
+	}
13 23
 /*
14 24
 if (isset($_SESSION['errorlst'])) {
15 25
 	header('Content-Encoding: none;');
@@ -131,7 +141,9 @@  discard block
 block discarded – undo
131 141
 		if (count($alllng) != count($availablelng)) {
132 142
 			$notavailable = array();
133 143
 			foreach($alllng as $lng) {
134
-				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
144
+				if (!isset($availablelng[$lng])) {
145
+					$notavailable[] = $lng;
146
+				}
135 147
 			}
136 148
 			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
137 149
 		}
@@ -170,7 +182,10 @@  discard block
 block discarded – undo
170 182
 			<legend>Install script configuration</legend>
171 183
 			<p>
172 184
 				<label for="installpass">Install password</label>
173
-				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" />
185
+				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) {
186
+	print $globalInstallPassword;
187
+}
188
+?>" />
174 189
 			</p>
175 190
 			<p class="help-block">Password needed to access this install script. If empty, to access this script,  you will need to change the $globalInstalled setting in require/settings.php to FALSE</p>
176 191
 		</fieldset>
@@ -200,31 +215,49 @@  discard block
 block discarded – undo
200 215
 			</div>
201 216
 			<p>
202 217
 				<label for="dbhost">Database hostname</label>
203
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
218
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
219
+	print $globalDBhost;
220
+}
221
+?>" />
204 222
 			</p>
205 223
 			<p>
206 224
 				<label for="dbport">Database port</label>
207
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
225
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
226
+	print $globalDBport;
227
+}
228
+?>" />
208 229
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
209 230
 			</p>
210 231
 			<p>
211 232
 				<label for="dbname">Database name</label>
212
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
233
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
234
+	print $globalDBname;
235
+}
236
+?>" />
213 237
 			</p>
214 238
 			<p>
215 239
 				<label for="dbuser">Database user</label>
216
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
240
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
241
+	print $globalDBuser;
242
+}
243
+?>" />
217 244
 			</p>
218 245
 			<p>
219 246
 				<label for="dbuserpass">Database user password</label>
220
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
247
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
248
+	print $globalDBpass;
249
+}
250
+?>" />
221 251
 			</p>
222 252
 		</fieldset>
223 253
 		<fieldset id="site">
224 254
 			<legend>Site configuration</legend>
225 255
 			<p>
226 256
 				<label for="sitename">Site name</label>
227
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
257
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
258
+	print $globalName;
259
+}
260
+?>" />
228 261
 			</p>
229 262
 			<p>
230 263
 				<label for="siteurl">Site directory</label>
@@ -237,18 +270,27 @@  discard block
 block discarded – undo
237 270
 					}
238 271
 				    }
239 272
 				?>
240
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
273
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
274
+	print $globalURL;
275
+}
276
+?>" />
241 277
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
242 278
 				<p class="help-block">Can be empty</p>
243 279
 			</p>
244 280
 			<p>
245 281
 				<label for="timezone">Timezone</label>
246
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
282
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
283
+	print $globalTimezone;
284
+}
285
+?>" />
247 286
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
248 287
 			</p>
249 288
 			<p>
250 289
 				<label for="language">Language</label>
251
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
290
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
291
+	print $globalLanguage;
292
+}
293
+?>" />
252 294
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
253 295
 			</p>
254 296
 		</fieldset>
@@ -268,11 +310,17 @@  discard block
 block discarded – undo
268 310
 			<div id="mapbox_data">
269 311
 				<p>
270 312
 					<label for="mapboxid">Mapbox id</label>
271
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
313
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
314
+	print $globalMapboxId;
315
+}
316
+?>" />
272 317
 				</p>
273 318
 				<p>
274 319
 					<label for="mapboxtoken">Mapbox token</label>
275
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
320
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
321
+	print $globalMapboxToken;
322
+}
323
+?>" />
276 324
 				</p>
277 325
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
278 326
 			</div>
@@ -280,7 +328,10 @@  discard block
 block discarded – undo
280 328
 			<div id="google_data">
281 329
 				<p>
282 330
 					<label for="googlekey">Google API key</label>
283
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
331
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
332
+	print $globalGoogleAPIKey;
333
+}
334
+?>" />
284 335
 					<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>
285 336
 				</p>
286 337
 			</div>
@@ -288,7 +339,10 @@  discard block
 block discarded – undo
288 339
 			<div id="bing_data">
289 340
 				<p>
290 341
 					<label for="bingkey">Bing Map key</label>
291
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
342
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
343
+	print $globalBingMapKey;
344
+}
345
+?>" />
292 346
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
293 347
 				</p>
294 348
 			</div>
@@ -296,7 +350,10 @@  discard block
 block discarded – undo
296 350
 			<div id="mapquest_data">
297 351
 				<p>
298 352
 					<label for="mapquestkey">MapQuest key</label>
299
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
353
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
354
+	print $globalMapQuestKey;
355
+}
356
+?>" />
300 357
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
301 358
 				</p>
302 359
 			</div>
@@ -304,11 +361,17 @@  discard block
 block discarded – undo
304 361
 			<div id="here_data">
305 362
 				<p>
306 363
 					<label for="hereappid">Here App_Id</label>
307
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
364
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
365
+	print $globalHereappId;
366
+}
367
+?>" />
308 368
 				</p>
309 369
 				<p>
310 370
 					<label for="hereappcode">Here App_Code</label>
311
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
371
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
372
+	print $globalHereappCode;
373
+}
374
+?>" />
312 375
 				</p>
313 376
 				<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>
314 377
 			</div>
@@ -316,7 +379,10 @@  discard block
 block discarded – undo
316 379
 			<div id="openweathermap_data">
317 380
 				<p>
318 381
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
319
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
382
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
383
+	print $globalOpenWeatherMapKey;
384
+}
385
+?>" />
320 386
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
321 387
 				</p>
322 388
 			</div>
@@ -345,42 +411,86 @@  discard block
 block discarded – undo
345 411
 			<legend>Coverage area</legend>
346 412
 			<p>
347 413
 				<label for="latitudemax">The maximum latitude (north)</label>
348
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
414
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
415
+	print $globalLatitudeMax;
416
+}
417
+?>" />
349 418
 			</p>
350 419
 			<p>
351 420
 				<label for="latitudemin">The minimum latitude (south)</label>
352
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
421
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
422
+	print $globalLatitudeMin;
423
+}
424
+?>" />
353 425
 			</p>
354 426
 			<p>
355 427
 				<label for="longitudemax">The maximum longitude (west)</label>
356
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
428
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
429
+	print $globalLongitudeMax;
430
+}
431
+?>" />
357 432
 			</p>
358 433
 			<p>
359 434
 				<label for="longitudemin">The minimum longitude (east)</label>
360
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
435
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
436
+	print $globalLongitudeMin;
437
+}
438
+?>" />
361 439
 			</p>
362 440
 			<p>
363 441
 				<label for="latitudecenter">The latitude center</label>
364
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
442
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
443
+	print $globalCenterLatitude;
444
+}
445
+?>" />
365 446
 			</p>
366 447
 			<p>
367 448
 				<label for="longitudecenter">The longitude center</label>
368
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
449
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
450
+	print $globalCenterLongitude;
451
+}
452
+?>" />
369 453
 			</p>
370 454
 			<p>
371 455
 				<label for="livezoom">Default Zoom on live map</label>
372
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
456
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
457
+	print $globalLiveZoom;
458
+} else {
459
+	print '9';
460
+}
461
+?>" />
373 462
 			</p>
374 463
 			<p>
375 464
 				<label for="squawk_country">Country for squawk usage</label>
376 465
 				<select name="squawk_country" id="squawk_country">
377
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
378
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
379
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
380
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
381
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
382
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
383
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
466
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
467
+	print ' selected ';
468
+}
469
+?>>UK</option>
470
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
471
+	print ' selected ';
472
+}
473
+?>>NZ</option>
474
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
475
+	print ' selected ';
476
+}
477
+?>>US</option>
478
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
479
+	print ' selected ';
480
+}
481
+?>>AU</option>
482
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
483
+	print ' selected ';
484
+}
485
+?>>NL</option>
486
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
487
+	print ' selected ';
488
+}
489
+?>>FR</option>
490
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
491
+	print ' selected ';
492
+}
493
+?>>TR</option>
384 494
 				</select>
385 495
 			</p>
386 496
 		</fieldset>
@@ -389,15 +499,24 @@  discard block
 block discarded – undo
389 499
 			<p><i>Only put in DB flights that are inside a circle</i></p>
390 500
 			<p>
391 501
 				<label for="latitude">Center latitude</label>
392
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
502
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
503
+	echo $globalDistanceIgnore['latitude'];
504
+}
505
+?>" />
393 506
 			</p>
394 507
 			<p>
395 508
 				<label for="longitude">Center longitude</label>
396
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
509
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
510
+	echo $globalDistanceIgnore['longitude'];
511
+}
512
+?>" />
397 513
 			</p>
398 514
 			<p>
399 515
 				<label for="Distance">Distance (in km)</label>
400
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
516
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
517
+	echo $globalDistanceIgnore['distance'];
518
+}
519
+?>" />
401 520
 			</p>
402 521
 		</fieldset>
403 522
 		<fieldset id="sourceloc">
@@ -523,28 +642,43 @@  discard block
 block discarded – undo
523 642
 			<div id="flightaware_data">
524 643
 				<p>
525 644
 					<label for="flightawareusername">FlightAware username</label>
526
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
645
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
646
+	print $globalFlightAwareUsername;
647
+}
648
+?>" />
527 649
 				</p>
528 650
 				<p>
529 651
 					<label for="flightawarepassword">FlightAware password/API key</label>
530
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
652
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
653
+	print $globalFlightAwarePassword;
654
+}
655
+?>" />
531 656
 				</p>
532 657
 			</div>
533 658
 -->
534 659
 			<div id="sailaway_data">
535 660
 				<p>
536 661
 					<label for="sailawayemail">Sailaway email</label>
537
-					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" />
662
+					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) {
663
+	print $globalSailaway['email'];
664
+}
665
+?>" />
538 666
 					<p class="help-block">Only needed for Sailaway full format</p>
539 667
 				</p>
540 668
 				<p>
541 669
 					<label for="sailawaypassword">Sailaway password</label>
542
-					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" />
670
+					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) {
671
+	print $globalSailaway['password'];
672
+}
673
+?>" />
543 674
 					<p class="help-block">Only needed for Sailaway full format</p>
544 675
 				</p>
545 676
 				<p>
546 677
 					<label for="sailawaykey">Sailaway API key</label>
547
-					<input type="text" name="sailawaykey" id="sailawaykey" value="<?php if (isset($globalSailaway['key'])) print $globalSailaway['key']; ?>" />
678
+					<input type="text" name="sailawaykey" id="sailawaykey" value="<?php if (isset($globalSailaway['key'])) {
679
+	print $globalSailaway['key'];
680
+}
681
+?>" />
548 682
 				</p>
549 683
 			</div>
550 684
 
@@ -586,7 +720,10 @@  discard block
 block discarded – undo
586 720
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
587 721
 								?>
588 722
 								<td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td>
589
-								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
723
+								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) {
724
+	print $source['port'];
725
+}
726
+?>" /></td>
590 727
 								<?php
591 728
 								    } else {
592 729
 									$hostport = explode(':',$source['host']);
@@ -605,41 +742,134 @@  discard block
 block discarded – undo
605 742
 								?>
606 743
 								<td>
607 744
 									<select name="format[]">
608
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
609
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
610
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
611
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
612
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
613
-										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option>
614
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
615
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
616
-                                        <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') print 'selected'; ?>>Radarcape json</option>
617
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
618
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
619
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
620
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
621
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
622
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
623
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
624
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
625
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
626
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
627
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
628
-										<option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec</option>
629
-										<option value="acarsjsonudp" <?php if (isset($source['format']) && $source['format'] == 'acarsjsonudp') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec over UDP</option>
630
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
631
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
632
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
633
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
634
-										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option>
635
-										<option value="sailawayfull" <?php if (isset($source['format']) && $source['format'] == 'sailawayfull') print 'selected'; ?>>Sailaway with missions, races,...</option>
745
+										<option value="auto" <?php if (!isset($source['format'])) {
746
+	print 'selected';
747
+}
748
+?>>Auto</option>
749
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
750
+	print 'selected';
751
+}
752
+?>>SBS</option>
753
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
754
+	print 'selected';
755
+}
756
+?>>TSV</option>
757
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
758
+	print 'selected';
759
+}
760
+?>>Raw</option>
761
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
762
+	print 'selected';
763
+}
764
+?>>Dump1090 aircraft.json</option>
765
+										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') {
766
+	print 'selected';
767
+}
768
+?>>Planefinder client</option>
769
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
770
+	print 'selected';
771
+}
772
+?>>APRS</option>
773
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
774
+	print 'selected';
775
+}
776
+?>>Radarcape deltadb.txt</option>
777
+                                        <option value="radarcapejson" <?php if (isset($source['format']) && $source['format'] == 'radarcapejson') {
778
+	print 'selected';
779
+}
780
+?>>Radarcape json</option>
781
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
782
+	print 'selected';
783
+}
784
+?>>Vatsim</option>
785
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
786
+	print 'selected';
787
+}
788
+?>>Virtual Radar Server AircraftList.json</option>
789
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
790
+	print 'selected';
791
+}
792
+?>>Virtual Radar Server TCP</option>
793
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
794
+	print 'selected';
795
+}
796
+?>>phpVMS</option>
797
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
798
+	print 'selected';
799
+}
800
+?>>Virtual Airline Operations System (VAOS)</option>
801
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
802
+	print 'selected';
803
+}
804
+?>>Virtual Airlines Manager</option>
805
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
806
+	print 'selected';
807
+}
808
+?>>IVAO</option>
809
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
810
+	print 'selected';
811
+}
812
+?>>FlightGear Multiplayer</option>
813
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
814
+	print 'selected';
815
+}
816
+?>>FlightGear Singleplayer</option>
817
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
818
+	print 'selected';
819
+}
820
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
821
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
822
+	print 'selected';
823
+}
824
+?>>ACARS SBS-3 over TCP</option>
825
+										<option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') {
826
+	print 'selected';
827
+}
828
+?>>ACARS from acarsdec json and vdlm2dec</option>
829
+										<option value="acarsjsonudp" <?php if (isset($source['format']) && $source['format'] == 'acarsjsonudp') {
830
+	print 'selected';
831
+}
832
+?>>ACARS from acarsdec json and vdlm2dec over UDP</option>
833
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
834
+	print 'selected';
835
+}
836
+?>>NMEA AIS over TCP</option>
837
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
838
+	print 'selected';
839
+}
840
+?>>AirWhere website</option>
841
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
842
+	print 'selected';
843
+}
844
+?>>HidnSeek Callback</option>
845
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
846
+	print 'selected';
847
+}
848
+?>>Blitzortung</option>
849
+										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') {
850
+	print 'selected';
851
+}
852
+?>>Sailaway</option>
853
+										<option value="sailawayfull" <?php if (isset($source['format']) && $source['format'] == 'sailawayfull') {
854
+	print 'selected';
855
+}
856
+?>>Sailaway with missions, races,...</option>
636 857
 									</select>
637 858
 								</td>
638 859
 								<td>
639
-									<input type="text" name="name[]" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
860
+									<input type="text" name="name[]" value="<?php if (isset($source['name'])) {
861
+	print $source['name'];
862
+}
863
+?>" />
640 864
 								</td>
641
-								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
642
-								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
865
+								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
866
+	print 'checked';
867
+}
868
+?> /></td>
869
+								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
870
+	print 'checked';
871
+}
872
+?> /></td>
643 873
 								<td>
644 874
 									<select name="timezones[]">
645 875
 								<?php
@@ -649,7 +879,9 @@  discard block
 block discarded – undo
649 879
 											print '<option selected>'.$timezones.'</option>';
650 880
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
651 881
 											print '<option selected>'.$timezones.'</option>';
652
-										} else print '<option>'.$timezones.'</option>';
882
+										} else {
883
+											print '<option>'.$timezones.'</option>';
884
+										}
653 885
 									}
654 886
 								?>
655 887
 									</select>
@@ -707,7 +939,9 @@  discard block
 block discarded – undo
707 939
 									foreach($timezonelist as $timezones){
708 940
 										if ($timezones == 'UTC') {
709 941
 											print '<option selected>'.$timezones.'</option>';
710
-										} else print '<option>'.$timezones.'</option>';
942
+										} else {
943
+											print '<option>'.$timezones.'</option>';
944
+										}
711 945
 									}
712 946
 								?>
713 947
 									</select>
@@ -732,11 +966,17 @@  discard block
 block discarded – undo
732 966
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
733 967
 					<p>
734 968
 						<label for="acarshost">ACARS UDP host</label>
735
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
969
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
970
+	print $globalACARSHost;
971
+}
972
+?>" />
736 973
 					</p>
737 974
 					<p>
738 975
 						<label for="acarsport">ACARS UDP port</label>
739
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
976
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
977
+	print $globalACARSPort;
978
+}
979
+?>" />
740 980
 					</p>
741 981
 					<p class="help-block"><i>daemon-acars.php</i> can only be run as daemon. It's an alternate script for ACARS data, <i>daemon-spotter.php</i> may be better.</p>
742 982
 				</fieldset>
@@ -763,17 +1003,38 @@  discard block
 block discarded – undo
763 1003
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
764 1004
 				    <td>
765 1005
 					<select name="newslang[]">
766
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
767
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
1006
+					    <option value="en"<?php if ($lng == 'en') {
1007
+	print ' selected';
1008
+}
1009
+?>>English</option>
1010
+					    <option value="fr"<?php if ($lng == 'fr') {
1011
+	print ' selected';
1012
+}
1013
+?>>French</option>
768 1014
 					</select>
769 1015
 				    </td>
770 1016
 				    <td>
771 1017
 					<select name="newstype[]">
772
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
773
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
774
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
775
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
776
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
1018
+					    <option value="global"<?php if ($type == 'global') {
1019
+	print ' selected';
1020
+}
1021
+?>>Global</option>
1022
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
1023
+	print ' selected';
1024
+}
1025
+?>>Aircraft</option>
1026
+					    <option value="marine"<?php if ($type == 'marine') {
1027
+	print ' selected';
1028
+}
1029
+?>>Marine</option>
1030
+					    <option value="tracker"<?php if ($type == 'tracker') {
1031
+	print ' selected';
1032
+}
1033
+?>>Tracker</option>
1034
+					    <option value="satellite"<?php if ($type == 'Satellite') {
1035
+	print ' selected';
1036
+}
1037
+?>>Satellite</option>
777 1038
 					</select>
778 1039
 				    </td>
779 1040
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -857,7 +1118,10 @@  discard block
 block discarded – undo
857 1118
 			</p>
858 1119
 			<p>
859 1120
 				<label for="corsproxy">CORS proxy</label>
860
-				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
1121
+				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) {
1122
+	print $globalCORSproxy;
1123
+} else {
1124
+	print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
861 1125
 				<p class="help-block">CORS proxy used for some WMS servers</p>
862 1126
 			</p>
863 1127
 <!--
@@ -920,13 +1184,18 @@  discard block
 block discarded – undo
920 1184
 			<div id="schedules_options">
921 1185
 				<p>
922 1186
 					<label for="britishairways">British Airways API Key</label>
923
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1187
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey;
1188
+}
1189
+?>" />
924 1190
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
925 1191
 				</p>
926 1192
 				<!--
927 1193
 				<p>
928 1194
 					<label for="transavia">Transavia Test API Consumer Key</label>
929
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1195
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1196
+	print $globalTransaviaKey;
1197
+}
1198
+?>" />
930 1199
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
931 1200
 				</p>
932 1201
 				-->
@@ -935,10 +1204,16 @@  discard block
 block discarded – undo
935 1204
 						<b>Lufthansa API Key</b>
936 1205
 						<p>
937 1206
 							<label for="lufthansakey">Key</label>
938
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1207
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1208
+	print $globalLufthansaKey['key'];
1209
+}
1210
+?>" />
939 1211
 						</p><p>
940 1212
 							<label for="lufthansasecret">Secret</label>
941
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1213
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1214
+	print $globalLufthansaKey['secret'];
1215
+}
1216
+?>" />
942 1217
 						</p>
943 1218
 					</div>
944 1219
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -948,11 +1223,17 @@  discard block
 block discarded – undo
948 1223
 						<b>FlightAware API Key</b>
949 1224
 						<p>
950 1225
 							<label for="flightawareusername">Username</label>
951
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1226
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1227
+	print $globalFlightAwareUsername;
1228
+}
1229
+?>" />
952 1230
 						</p>
953 1231
 						<p>
954 1232
 							<label for="flightawarepassword">API key</label>
955
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1233
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1234
+	print $globalFlightAwarePassword;
1235
+}
1236
+?>" />
956 1237
 						</p>
957 1238
 					</div>
958 1239
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -969,10 +1250,22 @@  discard block
 block discarded – undo
969 1250
 				<p>
970 1251
 					<label for="mapmatchingsource">Map Matching source</label>
971 1252
 					<select name="mapmatchingsource" id="mapmatchingsource">
972
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
973
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
974
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
975
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1253
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1254
+	print 'selected="selected" ';
1255
+}
1256
+?>>FlightAirMap Map Matching</option>
1257
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1258
+	print 'selected="selected" ';
1259
+}
1260
+?>>GraphHopper</option>
1261
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1262
+	print 'selected="selected" ';
1263
+}
1264
+?>>OSMR</option>
1265
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1266
+	print 'selected="selected" ';
1267
+}
1268
+?>>Mapbox</option>
976 1269
 					</select>
977 1270
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
978 1271
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -980,7 +1273,10 @@  discard block
 block discarded – undo
980 1273
 				<br />
981 1274
 				<p>
982 1275
 					<label for="graphhopper">GraphHopper API Key</label>
983
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1276
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1277
+	print $globalGraphHopperKey;
1278
+}
1279
+?>" />
984 1280
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
985 1281
 				</p>
986 1282
 			</div>
@@ -998,7 +1294,10 @@  discard block
 block discarded – undo
998 1294
 			</p>
999 1295
 			<p>
1000 1296
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
1001
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1297
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1298
+	print $globalNOTAMSource;
1299
+}
1300
+?>" />
1002 1301
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
1003 1302
 			</p>
1004 1303
 			<br />
@@ -1014,14 +1313,20 @@  discard block
 block discarded – undo
1014 1313
 			<div id="metarsrc">
1015 1314
 				<p>
1016 1315
 					<label for="metarsource">URL of your METAR source</label>
1017
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1316
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1317
+	print $globalMETARurl;
1318
+}
1319
+?>" />
1018 1320
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
1019 1321
 				</p>
1020 1322
 			</div>
1021 1323
 			<br />
1022 1324
 			<p>
1023 1325
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
1024
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1326
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1327
+	print $globalBitlyAccessToken;
1328
+}
1329
+?>" />
1025 1330
 			</p>
1026 1331
 			<br />
1027 1332
 			<p>
@@ -1037,11 +1342,26 @@  discard block
 block discarded – undo
1037 1342
 			<p>
1038 1343
 				<label for="geoid_source">Geoid Source</label>
1039 1344
 				<select name="geoid_source" id="geoid_source">
1040
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
1041
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
1042
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
1043
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
1044
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1345
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1346
+	print ' selected="selected"';
1347
+}
1348
+?>>EGM96 15' (2.1MB)</option>
1349
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1350
+	print ' selected="selected"';
1351
+}
1352
+?>>EGM96 5' (19MB)</option>
1353
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1354
+	print ' selected="selected"';
1355
+}
1356
+?>>EGM2008 5' (19MB)</option>
1357
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1358
+	print ' selected="selected"';
1359
+}
1360
+?>>EGM2008 2.5' (75MB)</option>
1361
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1362
+	print ' selected="selected"';
1363
+}
1364
+?>>EGM2008 1' (470MB)</option>
1045 1365
 				</select>
1046 1366
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
1047 1367
 			</p>
@@ -1063,7 +1383,12 @@  discard block
 block discarded – undo
1063 1383
 			</p>
1064 1384
 			<p>
1065 1385
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
1066
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1386
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1387
+	print $globalArchiveMonths;
1388
+} else {
1389
+	echo '1';
1390
+}
1391
+?>" />
1067 1392
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
1068 1393
 			</p>
1069 1394
 			<p>
@@ -1073,12 +1398,22 @@  discard block
 block discarded – undo
1073 1398
 			</p>
1074 1399
 			<p>
1075 1400
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
1076
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1401
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1402
+	print $globalArchiveKeepMonths;
1403
+} else {
1404
+	echo '1';
1405
+}
1406
+?>" />
1077 1407
 				<p class="help-block">0 to disable</p>
1078 1408
 			</p>
1079 1409
 			<p>
1080 1410
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
1081
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1411
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1412
+	print $globalArchiveKeepTrackMonths;
1413
+} else {
1414
+	echo '1';
1415
+}
1416
+?>" />
1082 1417
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
1083 1418
 			</p>
1084 1419
 			<br />
@@ -1088,7 +1423,12 @@  discard block
 block discarded – undo
1088 1423
 				<p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p>
1089 1424
 				<div id="cronends"> 
1090 1425
 					<label for="cronend">Run script for xx seconds</label>
1091
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1426
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1427
+	print $globalCronEnd;
1428
+} else {
1429
+	print '0';
1430
+}
1431
+?>" />
1092 1432
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
1093 1433
 				</div>
1094 1434
 			</p>
@@ -1147,20 +1487,40 @@  discard block
 block discarded – undo
1147 1487
 			<br />
1148 1488
 			<p>
1149 1489
 				<label for="refresh">Show flights detected since xxx seconds</label>
1150
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1490
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1491
+	echo $globalLiveInterval;
1492
+} else {
1493
+	echo '200';
1494
+}
1495
+?>" />
1151 1496
 			</p>
1152 1497
 			<p>
1153 1498
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1154
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1499
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1500
+	echo $globalMapRefresh;
1501
+} else {
1502
+	echo '30';
1503
+}
1504
+?>" />
1155 1505
 			</p>
1156 1506
 			<p>
1157 1507
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1158
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1508
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1509
+	echo $globalMapIdleTimeout;
1510
+} else {
1511
+	echo '30';
1512
+}
1513
+?>" />
1159 1514
 				<p class="help-block">0 to disable</p>
1160 1515
 			</p>
1161 1516
 			<p>
1162 1517
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1163
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1518
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1519
+	echo $globalMinFetch;
1520
+} else {
1521
+	echo '20';
1522
+}
1523
+?>" />
1164 1524
 			</p>
1165 1525
 			<p>
1166 1526
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1179,12 +1539,20 @@  discard block
 block discarded – undo
1179 1539
 			<br />
1180 1540
 			<p>
1181 1541
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1182
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1542
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1543
+	echo $globalClosestMinDist;
1544
+} else {
1545
+	echo '50';
1546
+}
1547
+?>" />
1183 1548
 			</p>
1184 1549
 			<br />
1185 1550
 			<p>
1186 1551
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1187
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1552
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1553
+	echo $globalAircraftSize;
1554
+}
1555
+?>" />
1188 1556
 			</p>
1189 1557
 			<br />
1190 1558
 			<p>
@@ -1203,22 +1571,42 @@  discard block
 block discarded – undo
1203 1571
 			<br />
1204 1572
 			<p>
1205 1573
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1206
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1574
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1575
+	echo $globalAircraftIconColor;
1576
+} else {
1577
+	echo '1a3151';
1578
+}
1579
+?>" />
1207 1580
 			</p>
1208 1581
 			<br />
1209 1582
 			<p>
1210 1583
 				<label for="marineiconcolor">Color of marine icon on map</label>
1211
-				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" />
1584
+				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) {
1585
+	echo $globalMarineIconColor;
1586
+} else {
1587
+	echo '43d1d8';
1588
+}
1589
+?>" />
1212 1590
 			</p>
1213 1591
 			<br />
1214 1592
 			<p>
1215 1593
 				<label for="trackericoncolor">Color of tracker icon on map</label>
1216
-				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" />
1594
+				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) {
1595
+	echo $globalTrackerIconColor;
1596
+} else {
1597
+	echo '1a3151';
1598
+}
1599
+?>" />
1217 1600
 			</p>
1218 1601
 			<br />
1219 1602
 			<p>
1220 1603
 				<label for="satelliteiconcolor">Color of satellite icon on map</label>
1221
-				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" />
1604
+				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) {
1605
+	echo $globalSatelliteIconColor;
1606
+} else {
1607
+	echo '1a3151';
1608
+}
1609
+?>" />
1222 1610
 			</p>
1223 1611
 			<?php
1224 1612
 				if (!is_writable('../cache')) {
@@ -1242,14 +1630,27 @@  discard block
 block discarded – undo
1242 1630
 			<p>
1243 1631
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1244 1632
 				<div class="range">
1245
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1246
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1633
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1634
+	echo $globalAirportZoom;
1635
+} else {
1636
+	echo '7';
1637
+}
1638
+?>" />
1639
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1640
+	echo $globalAirportZoom;
1641
+} else {
1642
+	echo '7';
1643
+}
1644
+?></output>
1247 1645
 				</div>
1248 1646
 			</p>
1249 1647
 			<br />
1250 1648
 			<p>
1251 1649
 				<label for="customcss">Custom CSS web path</label>
1252
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1650
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1651
+	echo $globalCustomCSS;
1652
+}
1653
+?>" />
1253 1654
 			</p>
1254 1655
 		</fieldset>
1255 1656
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1279,8 +1680,12 @@  discard block
 block discarded – undo
1279 1680
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1280 1681
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1281 1682
 
1282
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1283
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1683
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1684
+		$error .= 'Mysql driver for PDO must be loaded';
1685
+	}
1686
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1687
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1688
+	}
1284 1689
 	
1285 1690
 	$_SESSION['database_root'] = $dbroot;
1286 1691
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1359,15 +1764,23 @@  discard block
 block discarded – undo
1359 1764
 	$source_city = $_POST['source_city'];
1360 1765
 	$source_country = $_POST['source_country'];
1361 1766
 	$source_ref = $_POST['source_ref'];
1362
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1363
-	else $source_id = array();
1767
+	if (isset($source_id)) {
1768
+		$source_id = $_POST['source_id'];
1769
+	} else {
1770
+		$source_id = array();
1771
+	}
1364 1772
 	
1365 1773
 	$sources = array();
1366 1774
 	foreach ($source_name as $keys => $name) {
1367
-	    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]);
1368
-	    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]);
1775
+	    if (isset($source_id[$keys])) {
1776
+	    	$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]);
1777
+	    } else {
1778
+	    	$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]);
1779
+	    }
1780
+	}
1781
+	if (count($sources) > 0) {
1782
+		$_SESSION['sources'] = $sources;
1369 1783
 	}
1370
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1371 1784
 
1372 1785
 	$newsurl = $_POST['newsurl'];
1373 1786
 	$newslng = $_POST['newslang'];
@@ -1380,7 +1793,9 @@  discard block
 block discarded – undo
1380 1793
 		$lng = $newslng[$newskey];
1381 1794
 		if (isset($newsfeeds[$type][$lng])) {
1382 1795
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1383
-		} else $newsfeeds[$type][$lng] = array($url);
1796
+		} else {
1797
+			$newsfeeds[$type][$lng] = array($url);
1798
+		}
1384 1799
 	    }
1385 1800
 	}
1386 1801
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1405,17 +1820,29 @@  discard block
 block discarded – undo
1405 1820
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1406 1821
 
1407 1822
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1408
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1409
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1823
+	if ($globalaircraft == 'aircraft') {
1824
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1825
+	} else {
1826
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1827
+	}
1410 1828
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1411
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1412
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1829
+	if ($globaltracker == 'tracker') {
1830
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1831
+	} else {
1832
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1833
+	}
1413 1834
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1414
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1415
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1835
+	if ($globalmarine == 'marine') {
1836
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1837
+	} else {
1838
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1839
+	}
1416 1840
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1417
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1418
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1841
+	if ($globalsatellite == 'satellite') {
1842
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1843
+	} else {
1844
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1845
+	}
1419 1846
 
1420 1847
 /*	
1421 1848
 	$globalSBS1Hosts = array();
@@ -1437,23 +1864,37 @@  discard block
 block discarded – undo
1437 1864
 	$name = $_POST['name'];
1438 1865
 	$format = $_POST['format'];
1439 1866
 	$timezones = $_POST['timezones'];
1440
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1441
-	else $sourcestats = array();
1442
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1443
-	else $noarchive = array();
1867
+	if (isset($_POST['sourcestats'])) {
1868
+		$sourcestats = $_POST['sourcestats'];
1869
+	} else {
1870
+		$sourcestats = array();
1871
+	}
1872
+	if (isset($_POST['noarchive'])) {
1873
+		$noarchive = $_POST['noarchive'];
1874
+	} else {
1875
+		$noarchive = array();
1876
+	}
1444 1877
 	$gSources = array();
1445 1878
 	$forcepilots = false;
1446 1879
 	foreach ($host as $key => $h) {
1447
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1448
-		else $cov = 'FALSE';
1449
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1450
-		else $arch = 'FALSE';
1880
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1881
+			$cov = 'TRUE';
1882
+		} else {
1883
+			$cov = 'FALSE';
1884
+		}
1885
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1886
+			$arch = 'TRUE';
1887
+		} else {
1888
+			$arch = 'FALSE';
1889
+		}
1451 1890
 		if (strpos($format[$key],'_callback')) {
1452 1891
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1453 1892
 		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1454 1893
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1455 1894
 		}
1456
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1895
+		if ($format[$key] == 'airwhere') {
1896
+			$forcepilots = true;
1897
+		}
1457 1898
 	}
1458 1899
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1459 1900
 
@@ -1484,7 +1925,9 @@  discard block
 block discarded – undo
1484 1925
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1485 1926
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1486 1927
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1487
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1928
+	} else {
1929
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1930
+	}
1488 1931
 
1489 1932
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1490 1933
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1525,7 +1968,9 @@  discard block
 block discarded – undo
1525 1968
 
1526 1969
 	// Create in settings.php keys not yet configurable if not already here
1527 1970
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1528
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1971
+	if (!isset($globalDebug)) {
1972
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1973
+	}
1529 1974
 
1530 1975
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1531 1976
 	if ($resetyearstats == 'resetyearstats') {
@@ -1568,37 +2013,56 @@  discard block
 block discarded – undo
1568 2013
 	}
1569 2014
 */
1570 2015
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1571
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1572
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1573
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1574
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
2016
+	if ($globalsbs == 'sbs') {
2017
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
2018
+	} else {
2019
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
2020
+	}
2021
+	if ($globalaprs == 'aprs') {
2022
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
2023
+	} else {
2024
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
2025
+	}
1575 2026
 	$va = false;
1576 2027
 	if ($globalivao == 'ivao') {
1577 2028
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1578 2029
 		$va = true;
1579
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2030
+	} else {
2031
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2032
+	}
1580 2033
 	if ($globalvatsim == 'vatsim') {
1581 2034
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1582 2035
 		$va = true;
1583
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2036
+	} else {
2037
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2038
+	}
1584 2039
 	if ($globalphpvms == 'phpvms') {
1585 2040
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1586 2041
 		$va = true;
1587
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2042
+	} else {
2043
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2044
+	}
1588 2045
 	if ($globalvam == 'vam') {
1589 2046
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1590 2047
 		$va = true;
1591
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2048
+	} else {
2049
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2050
+	}
1592 2051
 	if ($va) {
1593 2052
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1594
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2053
+	} else {
2054
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2055
+	}
1595 2056
 	if ($globalva == 'va' || $va) {
1596 2057
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1597 2058
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1598 2059
 	} else {
1599 2060
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1600
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1601
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2061
+		if ($forcepilots) {
2062
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
2063
+		} else {
2064
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2065
+		}
1602 2066
 	}
1603 2067
 	if ($globalvm == 'vm') {
1604 2068
 		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
@@ -1858,7 +2322,9 @@  discard block
 block discarded – undo
1858 2322
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1859 2323
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1860 2324
 
1861
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2325
+	if (!isset($globalTransaction)) {
2326
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2327
+	}
1862 2328
 
1863 2329
 	// Set some defaults values...
1864 2330
 	if (!isset($globalAircraftImageSources)) {
@@ -1873,15 +2339,23 @@  discard block
 block discarded – undo
1873 2339
 
1874 2340
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1875 2341
 
1876
-	if ($error == '') settings::modify_settings($settings);
1877
-	if ($error == '') settings::comment_settings($settings_comment);
2342
+	if ($error == '') {
2343
+		settings::modify_settings($settings);
2344
+	}
2345
+	if ($error == '') {
2346
+		settings::comment_settings($settings_comment);
2347
+	}
1878 2348
 	if ($error != '') {
1879 2349
 		print '<div class="info column">'.$error.'</div>';
1880 2350
 		require('../footer.php');
1881 2351
 		exit;
1882 2352
 	} else {
1883
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1884
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2353
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2354
+			$_SESSION['waypoints'] = 1;
2355
+		}
2356
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2357
+			$_SESSION['owner'] = 1;
2358
+		}
1885 2359
 		if (isset($_POST['createdb'])) {
1886 2360
 			$_SESSION['install'] = 'database_create';
1887 2361
 		} else {
@@ -1918,10 +2392,18 @@  discard block
 block discarded – undo
1918 2392
 	$popw = false;
1919 2393
 	foreach ($_SESSION['done'] as $done) {
1920 2394
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1921
-	    if ($done == 'Create database') $pop = true;
1922
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1923
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1924
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2395
+	    if ($done == 'Create database') {
2396
+	    	$pop = true;
2397
+	    }
2398
+	    if ($_SESSION['install'] == 'database_create') {
2399
+	    	$pop = true;
2400
+	    }
2401
+	    if ($_SESSION['install'] == 'database_import') {
2402
+	    	$popi = true;
2403
+	    }
2404
+	    if ($_SESSION['install'] == 'waypoints') {
2405
+	    	$popw = true;
2406
+	    }
1925 2407
 	}
1926 2408
 	if ($pop) {
1927 2409
 	    sleep(5);
@@ -1932,7 +2414,9 @@  discard block
 block discarded – undo
1932 2414
 	} else if ($popw) {
1933 2415
 	    sleep(5);
1934 2416
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1935
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2417
+	} else {
2418
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2419
+	}
1936 2420
 	print '</div></ul>';
1937 2421
 	print '<div id="error"></div>';
1938 2422
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
require/class.MarineLive.php 2 patches
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -27,33 +27,33 @@  discard block
 block discarded – undo
27 27
      * @param bool $and
28 28
      * @return string the SQL part
29 29
      */
30
-	public function getFilter($filter = array(),$where = false,$and = false) {
30
+	public function getFilter($filter = array(), $where = false, $and = false) {
31 31
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
32 32
 		$filters = array();
33 33
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
34 34
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
35 35
 				$filters = $globalStatsFilters[$globalFilterName];
36 36
 			} else {
37
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
37
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
38 38
 			}
39 39
 		}
40 40
 		if (isset($filter[0]['source'])) {
41
-			$filters = array_merge($filters,$filter);
41
+			$filters = array_merge($filters, $filter);
42 42
 		}
43
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
43
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
44 44
 		$filter_query_join = '';
45 45
 		$filter_query_where = '';
46
-		foreach($filters as $flt) {
46
+		foreach ($filters as $flt) {
47 47
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
48 48
 				if (isset($flt['source'])) {
49
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
49
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
50 50
 				} else {
51
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
51
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
52 52
 				}
53 53
 			}
54 54
 		}
55 55
 		if (isset($filter['source']) && !empty($filter['source'])) {
56
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
56
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
57 57
 		}
58 58
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
59 59
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
92 92
 				}
93 93
 			}
94
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
94
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
95 95
 		}
96 96
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
97
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
97
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
98 98
 		}
99 99
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
100 100
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
101 101
 		if ($filter_query_where != '') {
102
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
102
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
103 103
 		}
104 104
 		$filter_query = $filter_query_join.$filter_query_where;
105 105
 		return $filter_query;
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 		if ($limit != '')
125 125
 		{
126 126
 			$limit_array = explode(',', $limit);
127
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
128
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
127
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
128
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
129 129
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
130 130
 			{
131 131
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
141 141
 			}
142 142
 		}
143
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
143
+		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
144 144
 
145 145
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
146 146
 		if ($globalDBdriver == 'mysql') {
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		} else {
150 150
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
151 151
 		}
152
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
152
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
153 153
 
154 154
 		return $spotter_array;
155 155
 	}
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		global $globalDBdriver, $globalLiveInterval;
166 166
 		date_default_timezone_set('UTC');
167 167
 
168
-		$filter_query = $this->getFilter($filter,true,true);
168
+		$filter_query = $this->getFilter($filter, true, true);
169 169
 
170 170
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
171 171
 		if ($globalDBdriver == 'mysql') {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		try {
180 180
 			$sth = $this->db->prepare($query);
181 181
 			$sth->execute();
182
-		} catch(PDOException $e) {
182
+		} catch (PDOException $e) {
183 183
 			echo $e->getMessage();
184 184
 			die;
185 185
 		}
@@ -197,26 +197,26 @@  discard block
 block discarded – undo
197 197
      * @param string $id
198 198
      * @return array the spotter information
199 199
      */
200
-	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '')
200
+	public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false, $id = '')
201 201
 	{
202 202
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
203 203
 		date_default_timezone_set('UTC');
204 204
 		$usecoord = false;
205 205
 		if (is_array($coord) && !empty($coord)) {
206
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
207
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
208
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
209
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
206
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
207
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
208
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
209
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
210 210
 			$usecoord = true;
211 211
 		}
212
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
213
-		$filter_query = $this->getFilter($filter,true,true);
212
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
213
+		$filter_query = $this->getFilter($filter, true, true);
214 214
 
215 215
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
216 216
 		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
217 217
 		if ($globalDBdriver == 'mysql') {
218 218
 			if (isset($globalArchive) && $globalArchive === TRUE) {
219
-				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
219
+				$query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
220 220
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
221 221
 				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
222 222
 				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 				    ORDER BY fammarine_id, date";
231 231
 				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
232 232
 			} else {
233
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
233
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
234 234
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
235 235
 				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
236 236
 				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 			}
241 241
 		} else {
242 242
 			if (isset($globalArchive) && $globalArchive === TRUE) {
243
-				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
243
+				$query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
244 244
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
245 245
 				if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
246 246
 				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		try {
268 268
 			$sth = $this->db->prepare($query);
269 269
 			$sth->execute($query_values);
270
-		} catch(PDOException $e) {
270
+		} catch (PDOException $e) {
271 271
 			echo $e->getMessage();
272 272
 			die;
273 273
 		}
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
      * @param bool $limit
284 284
      * @return array the spotter information
285 285
      */
286
-	public function getMinLastLiveMarineDataByID($id = '',$filter = array(), $limit = false)
286
+	public function getMinLastLiveMarineDataByID($id = '', $filter = array(), $limit = false)
287 287
 	{
288 288
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
289 289
 		date_default_timezone_set('UTC');
290
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
291
-		$filter_query = $this->getFilter($filter,true,true);
290
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
291
+		$filter_query = $this->getFilter($filter, true, true);
292 292
 
293 293
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
294 294
 		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		try {
334 334
 			$sth = $this->db->prepare($query);
335 335
 			$sth->execute($query_values);
336
-		} catch(PDOException $e) {
336
+		} catch (PDOException $e) {
337 337
 			echo $e->getMessage();
338 338
 			die;
339 339
 		}
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	public function getLiveMarineCount($filter = array())
351 351
 	{
352 352
 		global $globalDBdriver, $globalLiveInterval;
353
-		$filter_query = $this->getFilter($filter,true,true);
353
+		$filter_query = $this->getFilter($filter, true, true);
354 354
 
355 355
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
356 356
 		if ($globalDBdriver == 'mysql') {
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 		try {
362 362
 			$sth = $this->db->prepare($query);
363 363
 			$sth->execute();
364
-		} catch(PDOException $e) {
364
+		} catch (PDOException $e) {
365 365
 			echo $e->getMessage();
366 366
 			die;
367 367
 		}
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 		$filter_query = $this->getFilter($filter);
386 386
 
387 387
 		if (is_array($coord)) {
388
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
389
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
390
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
391
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
388
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
389
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
390
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
391
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
392 392
 		} else return array();
393 393
 		if ($globalDBdriver == 'mysql') {
394 394
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query;
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
412 412
 		$Marine = new Marine($this->db);
413 413
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
414
-		$filter_query = $this->getFilter($filter,true,true);
414
+		$filter_query = $this->getFilter($filter, true, true);
415 415
 
416 416
 		if (is_array($coord)) {
417
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
418
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
419
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
420
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
417
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
418
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
419
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
420
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
421 421
 		} else return array();
422 422
 		/*
423 423
 		if ($globalDBdriver == 'mysql') {
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
 		*/
433 433
 		if ($globalDBdriver == 'mysql') {
434 434
 			if (isset($globalArchive) && $globalArchive === TRUE) {
435
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
435
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
436 436
 				    FROM marine_live 
437 437
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date 
438 438
 				    AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
439 439
 				    AND marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY race_rank,date DESC';
440 440
 			} else {
441
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
441
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
442 442
 				    FROM marine_live 
443 443
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
444 444
 				    FROM marine_live l 
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
 			}
451 451
 		} else {
452 452
 			if (isset($globalArchive) && $globalArchive === TRUE) {
453
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
453
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
454 454
 				    FROM marine_live 
455 455
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date 
456 456
 				    AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
457 457
 				    AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
458 458
 				    AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' ORDER BY race_rank, date DESC";
459 459
 			} else {
460
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
460
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
461 461
 				    FROM marine_live 
462 462
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
463 463
 				    FROM marine_live l 
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 				if ($interval == '1m')
518 518
 				{
519 519
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
520
-				} else if ($interval == '15m'){
520
+				} else if ($interval == '15m') {
521 521
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
522 522
 				}
523 523
 			}
@@ -525,14 +525,14 @@  discard block
 block discarded – undo
525 525
 			$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
526 526
 		}
527 527
 
528
-		$query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
528
+		$query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
529 529
                    WHERE marine_live.latitude <> '' 
530 530
                                    AND marine_live.longitude <> '' 
531 531
                    ".$additional_query."
532 532
                    HAVING distance < :radius  
533 533
                                    ORDER BY distance";
534 534
 
535
-		$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
535
+		$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
536 536
 
537 537
 		return $spotter_array;
538 538
 	}
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 		date_default_timezone_set('UTC');
551 551
 
552 552
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
553
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
553
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
554 554
 
555
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
555
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
556 556
 
557 557
 		return $spotter_array;
558 558
 	}
@@ -564,14 +564,14 @@  discard block
 block discarded – undo
564 564
      * @param $date
565 565
      * @return array the spotter information
566 566
      */
567
-	public function getDateLiveMarineDataByIdent($ident,$date)
567
+	public function getDateLiveMarineDataByIdent($ident, $date)
568 568
 	{
569 569
 		$Marine = new Marine($this->db);
570 570
 		date_default_timezone_set('UTC');
571 571
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
572 572
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
573
-		$date = date('c',$date);
574
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
573
+		$date = date('c', $date);
574
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
575 575
 		return $spotter_array;
576 576
 	}
577 577
 
@@ -582,14 +582,14 @@  discard block
 block discarded – undo
582 582
      * @param $date
583 583
      * @return array the spotter information
584 584
      */
585
-	public function getDateLiveMarineDataByMMSI($mmsi,$date)
585
+	public function getDateLiveMarineDataByMMSI($mmsi, $date)
586 586
 	{
587 587
 		$Marine = new Marine($this->db);
588 588
 		date_default_timezone_set('UTC');
589 589
 		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
590 590
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.mmsi = :mmsi AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
591
-		$date = date('c',$date);
592
-		$spotter_array = $Marine->getDataFromDB($query,array(':mmsi' => $mmsi,':date' => $date));
591
+		$date = date('c', $date);
592
+		$spotter_array = $Marine->getDataFromDB($query, array(':mmsi' => $mmsi, ':date' => $date));
593 593
 		return $spotter_array;
594 594
 	}
595 595
 
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 		date_default_timezone_set('UTC');
606 606
 
607 607
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
608
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
608
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
609 609
 
610
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
610
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
611 611
 
612 612
 		return $spotter_array;
613 613
 	}
@@ -619,15 +619,15 @@  discard block
 block discarded – undo
619 619
      * @param $date
620 620
      * @return array the spotter information
621 621
      */
622
-	public function getDateLiveMarineDataById($id,$date)
622
+	public function getDateLiveMarineDataById($id, $date)
623 623
 	{
624 624
 		$Marine = new Marine($this->db);
625 625
 		date_default_timezone_set('UTC');
626 626
 
627 627
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
628
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
629
-                $date = date('c',$date);
630
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
628
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
629
+                $date = date('c', $date);
630
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
631 631
 
632 632
 		return $spotter_array;
633 633
 	}
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      * @param bool $liveinterval
641 641
      * @return array the spotter information
642 642
      */
643
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
643
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
644 644
 	{
645 645
 		global $globalDBdriver, $globalLiveInterval;
646 646
 		date_default_timezone_set('UTC');
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		try {
660 660
 			$sth = $this->db->prepare($query);
661 661
 			$sth->execute(array(':id' => $id));
662
-		} catch(PDOException $e) {
662
+		} catch (PDOException $e) {
663 663
 			echo $e->getMessage();
664 664
 			die;
665 665
 		}
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
 	{
678 678
 		date_default_timezone_set('UTC');
679 679
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
680
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
681 681
     		try {
682 682
 			
683 683
 			$sth = $this->db->prepare($query);
684 684
 			$sth->execute(array(':ident' => $ident));
685
-		} catch(PDOException $e) {
685
+		} catch (PDOException $e) {
686 686
 			echo $e->getMessage();
687 687
 			die;
688 688
 		}
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			
713 713
 			$sth = $this->db->prepare($query);
714 714
 			$sth->execute();
715
-		} catch(PDOException $e) {
715
+		} catch (PDOException $e) {
716 716
 			return "error";
717 717
 		}
718 718
 
@@ -735,14 +735,14 @@  discard block
 block discarded – undo
735 735
 				
736 736
 				$sth = $this->db->prepare($query);
737 737
 				$sth->execute();
738
-			} catch(PDOException $e) {
738
+			} catch (PDOException $e) {
739 739
 				return "error";
740 740
 			}
741 741
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
742 742
                         $i = 0;
743
-                        $j =0;
743
+                        $j = 0;
744 744
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
745
-			foreach($all as $row)
745
+			foreach ($all as $row)
746 746
 			{
747 747
 				$i++;
748 748
 				$j++;
@@ -750,9 +750,9 @@  discard block
 block discarded – undo
750 750
 					if ($globalDebug) echo ".";
751 751
 				    	try {
752 752
 						
753
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
753
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
754 754
 						$sth->execute();
755
-					} catch(PDOException $e) {
755
+					} catch (PDOException $e) {
756 756
 						return "error";
757 757
 					}
758 758
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -763,9 +763,9 @@  discard block
 block discarded – undo
763 763
 			if ($i > 0) {
764 764
     				try {
765 765
 					
766
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
766
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
767 767
 					$sth->execute();
768
-				} catch(PDOException $e) {
768
+				} catch (PDOException $e) {
769 769
 					return "error";
770 770
 				}
771 771
 			}
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 				
779 779
 				$sth = $this->db->prepare($query);
780 780
 				$sth->execute();
781
-			} catch(PDOException $e) {
781
+			} catch (PDOException $e) {
782 782
 				return "error";
783 783
 			}
784 784
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -827,13 +827,13 @@  discard block
 block discarded – undo
827 827
 	public function deleteLiveMarineDataByIdent($ident)
828 828
 	{
829 829
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
830
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
830
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
831 831
         
832 832
     		try {
833 833
 			
834 834
 			$sth = $this->db->prepare($query);
835 835
 			$sth->execute(array(':ident' => $ident));
836
-		} catch(PDOException $e) {
836
+		} catch (PDOException $e) {
837 837
 			return "error";
838 838
 		}
839 839
 
@@ -849,13 +849,13 @@  discard block
 block discarded – undo
849 849
 	public function deleteLiveMarineDataById($id)
850 850
 	{
851 851
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
852
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
852
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
853 853
         
854 854
     		try {
855 855
 			
856 856
 			$sth = $this->db->prepare($query);
857 857
 			$sth->execute(array(':id' => $id));
858
-		} catch(PDOException $e) {
858
+		} catch (PDOException $e) {
859 859
 			return "error";
860 860
 		}
861 861
 
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 	*/
872 872
 	public function getAllRaces()
873 873
 	{
874
-		$query  = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
874
+		$query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
875 875
 		$sth = $this->db->prepare($query);
876 876
 		$sth->execute();
877 877
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -887,13 +887,13 @@  discard block
 block discarded – undo
887 887
 	{
888 888
 		global $globalDBdriver;
889 889
 		if ($globalDBdriver == 'mysql') {
890
-			$query  = 'SELECT marine_live.ident FROM marine_live 
890
+			$query = 'SELECT marine_live.ident FROM marine_live 
891 891
 				WHERE marine_live.ident = :ident 
892 892
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
893 893
 				AND marine_live.date < UTC_TIMESTAMP()';
894 894
 			$query_data = array(':ident' => $ident);
895 895
 		} else {
896
-			$query  = "SELECT marine_live.ident FROM marine_live 
896
+			$query = "SELECT marine_live.ident FROM marine_live 
897 897
 				WHERE marine_live.ident = :ident 
898 898
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
899 899
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -902,8 +902,8 @@  discard block
 block discarded – undo
902 902
 		
903 903
 		$sth = $this->db->prepare($query);
904 904
 		$sth->execute($query_data);
905
-		$ident_result='';
906
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
905
+		$ident_result = '';
906
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
907 907
 		{
908 908
 			$ident_result = $row['ident'];
909 909
 		}
@@ -920,13 +920,13 @@  discard block
 block discarded – undo
920 920
 	{
921 921
 		global $globalDBdriver;
922 922
 		if ($globalDBdriver == 'mysql') {
923
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
923
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
924 924
 				WHERE marine_live.ident = :ident 
925 925
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
926 926
 //				AND marine_live.date < UTC_TIMESTAMP()";
927 927
 			$query_data = array(':ident' => $ident);
928 928
 		} else {
929
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
929
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
930 930
 				WHERE marine_live.ident = :ident 
931 931
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
932 932
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 		
936 936
 		$sth = $this->db->prepare($query);
937 937
 		$sth->execute($query_data);
938
-		$ident_result='';
939
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
938
+		$ident_result = '';
939
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
940 940
 		{
941 941
 			$ident_result = $row['fammarine_id'];
942 942
 		}
@@ -953,13 +953,13 @@  discard block
 block discarded – undo
953 953
 	{
954 954
 		global $globalDBdriver;
955 955
 		if ($globalDBdriver == 'mysql') {
956
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
956
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
957 957
 				WHERE marine_live.fammarine_id = :id 
958 958
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
959 959
 //				AND marine_live.date < UTC_TIMESTAMP()";
960 960
 			$query_data = array(':id' => $id);
961 961
 		} else {
962
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
962
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
963 963
 				WHERE marine_live.fammarine_id = :id 
964 964
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
965 965
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 		
969 969
 		$sth = $this->db->prepare($query);
970 970
 		$sth->execute($query_data);
971
-		$ident_result='';
972
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
971
+		$ident_result = '';
972
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
973 973
 		{
974 974
 			$ident_result = $row['fammarine_id'];
975 975
 		}
@@ -986,13 +986,13 @@  discard block
 block discarded – undo
986 986
 	{
987 987
 		global $globalDBdriver;
988 988
 		if ($globalDBdriver == 'mysql') {
989
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
989
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
990 990
 				WHERE marine_live.mmsi = :mmsi 
991 991
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
992 992
 //				AND marine_live.date < UTC_TIMESTAMP()";
993 993
 			$query_data = array(':mmsi' => $mmsi);
994 994
 		} else {
995
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
995
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
996 996
 				WHERE marine_live.mmsi = :mmsi 
997 997
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
998 998
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
 		
1002 1002
 		$sth = $this->db->prepare($query);
1003 1003
 		$sth->execute($query_data);
1004
-		$ident_result='';
1005
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1004
+		$ident_result = '';
1005
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1006 1006
 		{
1007 1007
 			$ident_result = $row['fammarine_id'];
1008 1008
 		}
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
      * @param string $race_time
1043 1043
      * @return String success or false
1044 1044
      */
1045
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1045
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1046 1046
 	{
1047 1047
 		global $globalArchive, $globalDebug;
1048 1048
 		$Common = new Common();
@@ -1094,39 +1094,39 @@  discard block
 block discarded – undo
1094 1094
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1095 1095
 
1096 1096
         
1097
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1098
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1099
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1100
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1101
-		$distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1102
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1103
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1104
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1105
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1106
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1107
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
1108
-		$typeid = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
1109
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
1110
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
1111
-		$statusid = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
1112
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1113
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1114
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
1115
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
1116
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
1117
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
1118
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1119
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1120
-		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1097
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1098
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1099
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1100
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1101
+		$distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1102
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1103
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1104
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1105
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1106
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1107
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
1108
+		$typeid = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
1109
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
1110
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
1111
+		$statusid = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
1112
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1113
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1114
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
1115
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
1116
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
1117
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
1118
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
1119
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
1120
+		$race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT);
1121 1121
 		if ($race_rank == '') $race_rank = NULL;
1122
-		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1122
+		$race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1123 1123
 		if ($race_time == '') $race_time = NULL;
1124 1124
 		if ($typeid == '') $typeid = NULL;
1125 1125
 		if ($statusid == '') $statusid = NULL;
1126 1126
 		if ($distance == '') $distance = NULL;
1127 1127
 
1128 1128
             	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1129
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1129
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1130 1130
             	if ($arrival_date == '') $arrival_date = NULL;
1131 1131
             	$query = '';
1132 1132
 		if ($globalArchive) {
@@ -1135,19 +1135,19 @@  discard block
 block discarded – undo
1135 1135
 		}
1136 1136
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
1137 1137
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:typeid,:status,:statusid,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)';
1138
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':typeid' => $typeid,':status' => $status,':statusid' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_time' => $race_time,':race_rank' => $race_rank);
1138
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':typeid' => $typeid, ':status' => $status, ':statusid' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_time' => $race_time, ':race_rank' => $race_rank);
1139 1139
 		try {
1140 1140
 			$sth = $this->db->prepare($query);
1141 1141
 			$sth->execute($query_values);
1142 1142
 			$sth->closeCursor();
1143
-		} catch(PDOException $e) {
1143
+		} catch (PDOException $e) {
1144 1144
 			return "error : ".$e->getMessage();
1145 1145
 		}
1146 1146
 		
1147 1147
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1148 1148
 			if ($globalDebug) echo '(Add to Marine archive : ';
1149 1149
 			$MarineArchive = new MarineArchive($this->db);
1150
-			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time);
1150
+			$result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country, $captain_id, $captain_name, $race_id, $race_name, $distance, $race_rank, $race_time);
1151 1151
 			if ($globalDebug) echo $result.')';
1152 1152
 		}
1153 1153
 		return "success";
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 
1156 1156
 	public function getOrderBy()
1157 1157
 	{
1158
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1158
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1159 1159
 		return $orderby;
1160 1160
 	}
1161 1161
 
Please login to merge, or discard this patch.
Braces   +164 added lines, -55 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 	public function __construct($dbc = null) {
17 17
 		$Connection = new Connection($dbc);
18 18
 		$this->db = $Connection->db();
19
-		if ($this->db === null) die('Error: No DB connection. (MarineLive)');
19
+		if ($this->db === null) {
20
+			die('Error: No DB connection. (MarineLive)');
21
+		}
20 22
 	}
21 23
 
22 24
 
@@ -40,7 +42,9 @@  discard block
 block discarded – undo
40 42
 		if (isset($filter[0]['source'])) {
41 43
 			$filters = array_merge($filters,$filter);
42 44
 		}
43
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
45
+		if (is_array($globalFilter)) {
46
+			$filter = array_merge($filter,$globalFilter);
47
+		}
44 48
 		$filter_query_join = '';
45 49
 		$filter_query_where = '';
46 50
 		foreach($filters as $flt) {
@@ -96,8 +100,11 @@  discard block
 block discarded – undo
96 100
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
97 101
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
98 102
 		}
99
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
100
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
103
+		if ($filter_query_where == '' && $where) {
104
+			$filter_query_where = ' WHERE';
105
+		} elseif ($filter_query_where != '' && $and) {
106
+			$filter_query_where .= ' AND';
107
+		}
101 108
 		if ($filter_query_where != '') {
102 109
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
103 110
 		}
@@ -140,9 +147,13 @@  discard block
 block discarded – undo
140 147
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
141 148
 			}
142 149
 		}
143
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
150
+		if ($orderby_query == '') {
151
+			$orderby_query= ' ORDER BY date DESC';
152
+		}
144 153
 
145
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
146 157
 		if ($globalDBdriver == 'mysql') {
147 158
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
148 159
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -167,7 +178,9 @@  discard block
 block discarded – undo
167 178
 
168 179
 		$filter_query = $this->getFilter($filter,true,true);
169 180
 
170
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
181
+		if (!isset($globalLiveInterval)) {
182
+			$globalLiveInterval = '200';
183
+		}
171 184
 		if ($globalDBdriver == 'mysql') {
172 185
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
173 186
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY marine_live.race_rank";
@@ -212,58 +225,96 @@  discard block
 block discarded – undo
212 225
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
213 226
 		$filter_query = $this->getFilter($filter,true,true);
214 227
 
215
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
216
-		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
228
+		if (!isset($globalLiveInterval)) {
229
+			$globalLiveInterval = '200';
230
+		}
231
+		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') {
232
+			$globalMap3DMarinesLimit = '300';
233
+		}
217 234
 		if ($globalDBdriver == 'mysql') {
218 235
 			if (isset($globalArchive) && $globalArchive === TRUE) {
219 236
 				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
220 237
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
221
-				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
222
-				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
238
+				if ($usecoord) {
239
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
240
+				}
241
+				if ($id != '') {
242
+					$query .= "OR marine_archive.fammarine_id = :id ";
243
+				}
223 244
 				$query .= "UNION
224 245
 				    SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
225 246
 				    FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date";
226
-				if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
227
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
247
+				if ($usecoord) {
248
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
249
+				}
250
+				if ($id != '') {
251
+					$query .= "OR marine_live.fammarine_id = :id ";
252
+				}
228 253
 				$query .= ") AS marine 
229 254
 				    WHERE latitude <> '0' AND longitude <> '0' 
230 255
 				    ORDER BY fammarine_id, date";
231
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
256
+				if ($limit) {
257
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
258
+				}
232 259
 			} else {
233 260
 				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
234 261
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
235
-				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
236
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
262
+				if ($usecoord) {
263
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
264
+				}
265
+				if ($id != '') {
266
+					$query .= "OR marine_live.fammarine_id = :id ";
267
+				}
237 268
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
238 269
 				ORDER BY marine_live.fammarine_id, marine_live.date";
239
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
270
+				if ($limit) {
271
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
272
+				}
240 273
 			}
241 274
 		} else {
242 275
 			if (isset($globalArchive) && $globalArchive === TRUE) {
243 276
 				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
244 277
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
245
-				if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
246
-				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
278
+				if ($usecoord) {
279
+					$query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
280
+				}
281
+				if ($id != '') {
282
+					$query .= "OR marine_archive.fammarine_id = :id ";
283
+				}
247 284
 				$query .= "UNION
248 285
 				    SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
249 286
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date";
250
-				if ($usecoord) $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
251
-				if ($id != '') $query .= " OR marine_live.fammarine_id = :id";
287
+				if ($usecoord) {
288
+					$query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
289
+				}
290
+				if ($id != '') {
291
+					$query .= " OR marine_live.fammarine_id = :id";
292
+				}
252 293
 				$query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' ";
253 294
 				$query .= "ORDER BY fammarine_id, date";
254
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
295
+				if ($limit) {
296
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
297
+				}
255 298
 			} else {
256 299
 				$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
257 300
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date ";
258
-				if ($usecoord) $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
259
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
301
+				if ($usecoord) {
302
+					$query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
303
+				}
304
+				if ($id != '') {
305
+					$query .= "OR marine_live.fammarine_id = :id ";
306
+				}
260 307
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
261 308
 				ORDER BY marine_live.fammarine_id, marine_live.date";
262
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
309
+				if ($limit) {
310
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
311
+				}
263 312
 			}
264 313
 		}
265 314
 		$query_values = array();
266
-		if ($id != '') $query_values = array(':id' => $id);
315
+		if ($id != '') {
316
+			$query_values = array(':id' => $id);
317
+		}
267 318
 		try {
268 319
 			$sth = $this->db->prepare($query);
269 320
 			$sth->execute($query_values);
@@ -290,8 +341,12 @@  discard block
 block discarded – undo
290 341
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
291 342
 		$filter_query = $this->getFilter($filter,true,true);
292 343
 
293
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
294
-		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
344
+		if (!isset($globalLiveInterval)) {
345
+			$globalLiveInterval = '200';
346
+		}
347
+		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') {
348
+			$globalMap3DMarinesLimit = '300';
349
+		}
295 350
 		if ($globalDBdriver == 'mysql') {
296 351
 			if (isset($globalArchive) && $globalArchive === TRUE) {
297 352
 				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
@@ -302,13 +357,17 @@  discard block
 block discarded – undo
302 357
 				$query .= ") AS marine 
303 358
 				    WHERE latitude <> '0' AND longitude <> '0' 
304 359
 				    ORDER BY fammarine_id, date";
305
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
360
+				if ($limit) {
361
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
362
+				}
306 363
 			} else {
307 364
 				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
308 365
 				    FROM marine_live'.$filter_query.' marine_live.fammarine_id = :id ';
309 366
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
310 367
 				ORDER BY marine_live.fammarine_id, marine_live.date";
311
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
368
+				if ($limit) {
369
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
370
+				}
312 371
 			}
313 372
 		} else {
314 373
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -320,13 +379,17 @@  discard block
 block discarded – undo
320 379
 				$query .= ") AS marine 
321 380
 				    WHERE latitude <> '0' AND longitude <> '0' 
322 381
 				    ORDER BY fammarine_id, date";
323
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
382
+				if ($limit) {
383
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
384
+				}
324 385
 			} else {
325 386
 				$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
326 387
 				    FROM marine_live".$filter_query." marine_live.fammarine_id = :id ";
327 388
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
328 389
 				ORDER BY marine_live.fammarine_id, marine_live.date";
329
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
390
+				if ($limit) {
391
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
392
+				}
330 393
 			}
331 394
 		}
332 395
 		$query_values = array(':id' => $id);
@@ -352,7 +415,9 @@  discard block
 block discarded – undo
352 415
 		global $globalDBdriver, $globalLiveInterval;
353 416
 		$filter_query = $this->getFilter($filter,true,true);
354 417
 
355
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
418
+		if (!isset($globalLiveInterval)) {
419
+			$globalLiveInterval = '200';
420
+		}
356 421
 		if ($globalDBdriver == 'mysql') {
357 422
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
358 423
 		} else {
@@ -381,7 +446,9 @@  discard block
 block discarded – undo
381 446
 	{
382 447
 		global $globalDBdriver, $globalLiveInterval;
383 448
 		$Marine = new Marine($this->db);
384
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
449
+		if (!isset($globalLiveInterval)) {
450
+			$globalLiveInterval = '200';
451
+		}
385 452
 		$filter_query = $this->getFilter($filter);
386 453
 
387 454
 		if (is_array($coord)) {
@@ -389,7 +456,9 @@  discard block
 block discarded – undo
389 456
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
390 457
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
391 458
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
392
-		} else return array();
459
+		} else {
460
+			return array();
461
+		}
393 462
 		if ($globalDBdriver == 'mysql') {
394 463
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query;
395 464
 		} else {
@@ -410,7 +479,9 @@  discard block
 block discarded – undo
410 479
 	{
411 480
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
412 481
 		$Marine = new Marine($this->db);
413
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
482
+		if (!isset($globalLiveInterval)) {
483
+			$globalLiveInterval = '200';
484
+		}
414 485
 		$filter_query = $this->getFilter($filter,true,true);
415 486
 
416 487
 		if (is_array($coord)) {
@@ -418,7 +489,9 @@  discard block
 block discarded – undo
418 489
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
419 490
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
420 491
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
421
-		} else return array();
492
+		} else {
493
+			return array();
494
+		}
422 495
 		/*
423 496
 		if ($globalDBdriver == 'mysql') {
424 497
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
@@ -648,11 +721,15 @@  discard block
 block discarded – undo
648 721
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
649 722
 		if ($globalDBdriver == 'mysql') {
650 723
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
651
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
724
+			if ($liveinterval) {
725
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
726
+			}
652 727
 			$query .= ' ORDER BY date';
653 728
 		} else {
654 729
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
655
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
730
+			if ($liveinterval) {
731
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
732
+			}
656 733
 			$query .= ' ORDER BY date';
657 734
 		}
658 735
 
@@ -747,7 +824,9 @@  discard block
 block discarded – undo
747 824
 				$i++;
748 825
 				$j++;
749 826
 				if ($j == 30) {
750
-					if ($globalDebug) echo ".";
827
+					if ($globalDebug) {
828
+						echo ".";
829
+					}
751 830
 				    	try {
752 831
 						
753 832
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1064,7 +1143,9 @@  discard block
 block discarded – undo
1064 1143
 			{
1065 1144
 				return false;
1066 1145
 			}
1067
-		} else return '';
1146
+		} else {
1147
+			return '';
1148
+		}
1068 1149
 
1069 1150
 		if ($longitude != '')
1070 1151
 		{
@@ -1072,7 +1153,9 @@  discard block
 block discarded – undo
1072 1153
 			{
1073 1154
 				return false;
1074 1155
 			}
1075
-		} else return '';
1156
+		} else {
1157
+			return '';
1158
+		}
1076 1159
 
1077 1160
 
1078 1161
 		if ($heading != '')
@@ -1081,7 +1164,9 @@  discard block
 block discarded – undo
1081 1164
 			{
1082 1165
 				return false;
1083 1166
 			}
1084
-		} else $heading = 0;
1167
+		} else {
1168
+			$heading = 0;
1169
+		}
1085 1170
 
1086 1171
 		if ($groundspeed != '')
1087 1172
 		{
@@ -1089,9 +1174,13 @@  discard block
 block discarded – undo
1089 1174
 			{
1090 1175
 				return false;
1091 1176
 			}
1092
-		} else $groundspeed = 0;
1177
+		} else {
1178
+			$groundspeed = 0;
1179
+		}
1093 1180
 		date_default_timezone_set('UTC');
1094
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1181
+		if ($date == '') {
1182
+			$date = date("Y-m-d H:i:s", time());
1183
+		}
1095 1184
 
1096 1185
         
1097 1186
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1118,19 +1207,35 @@  discard block
 block discarded – undo
1118 1207
 		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1119 1208
 		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1120 1209
 		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1121
-		if ($race_rank == '') $race_rank = NULL;
1210
+		if ($race_rank == '') {
1211
+			$race_rank = NULL;
1212
+		}
1122 1213
 		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1123
-		if ($race_time == '') $race_time = NULL;
1124
-		if ($typeid == '') $typeid = NULL;
1125
-		if ($statusid == '') $statusid = NULL;
1126
-		if ($distance == '') $distance = NULL;
1214
+		if ($race_time == '') {
1215
+			$race_time = NULL;
1216
+		}
1217
+		if ($typeid == '') {
1218
+			$typeid = NULL;
1219
+		}
1220
+		if ($statusid == '') {
1221
+			$statusid = NULL;
1222
+		}
1223
+		if ($distance == '') {
1224
+			$distance = NULL;
1225
+		}
1127 1226
 
1128 1227
             	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1129
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1130
-            	if ($arrival_date == '') $arrival_date = NULL;
1228
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1229
+            		$heading = 0;
1230
+            	}
1231
+            	if ($arrival_date == '') {
1232
+            		$arrival_date = NULL;
1233
+            	}
1131 1234
             	$query = '';
1132 1235
 		if ($globalArchive) {
1133
-			if ($globalDebug) echo '-- Delete previous data -- ';
1236
+			if ($globalDebug) {
1237
+				echo '-- Delete previous data -- ';
1238
+			}
1134 1239
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
1135 1240
 		}
1136 1241
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
@@ -1145,10 +1250,14 @@  discard block
 block discarded – undo
1145 1250
 		}
1146 1251
 		
1147 1252
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1148
-			if ($globalDebug) echo '(Add to Marine archive : ';
1253
+			if ($globalDebug) {
1254
+				echo '(Add to Marine archive : ';
1255
+			}
1149 1256
 			$MarineArchive = new MarineArchive($this->db);
1150 1257
 			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time);
1151
-			if ($globalDebug) echo $result.')';
1258
+			if ($globalDebug) {
1259
+				echo $result.')';
1260
+			}
1152 1261
 		}
1153 1262
 		return "success";
1154 1263
 	}
Please login to merge, or discard this patch.
require/class.MarineImport.php 3 patches
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -16,25 +16,25 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/class.Stats.php');
17 17
 require_once(dirname(__FILE__).'/class.Source.php');
18 18
 if (isset($globalServerAPRS) && $globalServerAPRS) {
19
-    require_once(dirname(__FILE__).'/class.APRS.php');
19
+	require_once(dirname(__FILE__).'/class.APRS.php');
20 20
 }
21 21
 
22 22
 class MarineImport {
23
-    private $all_tracked = array();
24
-    private $last_delete_hourly = 0;
25
-    private $last_delete = 0;
26
-    private $stats = array();
27
-    private $tmd = 0;
28
-    private $source_location = array();
29
-    public $db = null;
30
-    public $nb = 0;
23
+	private $all_tracked = array();
24
+	private $last_delete_hourly = 0;
25
+	private $last_delete = 0;
26
+	private $stats = array();
27
+	private $tmd = 0;
28
+	private $source_location = array();
29
+	public $db = null;
30
+	public $nb = 0;
31 31
 
32
-    public function __construct($dbc = null) {
32
+	public function __construct($dbc = null) {
33 33
 	global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB;
34 34
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
35
-	    $Connection = new Connection($dbc);
36
-	    $this->db = $Connection->db();
37
-	    date_default_timezone_set('UTC');
35
+		$Connection = new Connection($dbc);
36
+		$this->db = $Connection->db();
37
+		date_default_timezone_set('UTC');
38 38
 	}
39 39
 	// Get previous source stats
40 40
 	/*
@@ -53,79 +53,79 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 	*/
55 55
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
56
-	    $APRSMarine = new APRSMarine();
57
-	    //$APRSSpotter->connect();
56
+		$APRSMarine = new APRSMarine();
57
+		//$APRSSpotter->connect();
58
+	}
58 59
 	}
59
-    }
60 60
 
61
-    public function checkAll() {
61
+	public function checkAll() {
62 62
 	global $globalDebug, $globalNoDB, $globalVM;
63 63
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
64
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
65
-	    foreach ($this->all_tracked as $key => $flight) {
64
+		if ($globalDebug) echo "Update last seen tracked data...\n";
65
+		foreach ($this->all_tracked as $key => $flight) {
66 66
 		if (isset($this->all_tracked[$key]['id'])) {
67
-		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
68
-    		    $Marine = new Marine($this->db);
69
-    		    if (isset($globalVM) && $globalVM) {
67
+			//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
68
+				$Marine = new Marine($this->db);
69
+				if (isset($globalVM) && $globalVM) {
70 70
 			if ($this->all_tracked[$key]['status'] == 'Racing') {
71
-    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
72
-    			} else {
73
-    			    $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
74
-    			    if ($timerace > time()) $finaldatetime = NULL;
75
-    			    else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
-    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
77
-    			}
78
-    		    } else {
71
+					$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
72
+				} else {
73
+					$timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
74
+					if ($timerace > time()) $finaldatetime = NULL;
75
+					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
+					$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
77
+				}
78
+				} else {
79 79
 			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
80
-		    }
80
+			}
81
+		}
81 82
 		}
82
-	    }
83 83
 	}
84
-    }
84
+	}
85 85
 
86
-    public function del() {
86
+	public function del() {
87 87
 	global $globalDebug, $globalNoDB, $globalNoImport;
88 88
 	// Delete old infos
89 89
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
90 90
 	foreach ($this->all_tracked as $key => $flight) {
91
-    	    if (isset($flight['lastupdate'])) {
92
-        	if ($flight['lastupdate'] < (time()-3000)) {
93
-            	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94
-            		if (isset($this->all_tracked[$key]['id'])) {
95
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
96
-			    /*
91
+			if (isset($flight['lastupdate'])) {
92
+			if ($flight['lastupdate'] < (time()-3000)) {
93
+					if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94
+					if (isset($this->all_tracked[$key]['id'])) {
95
+						if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
96
+				/*
97 97
 			    $MarineLive = new MarineLive();
98 98
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
99 99
 			    $MarineLive->db = null;
100 100
 			    */
101
-            		    //$real_arrival = $this->arrival($key);
102
-            		    $Marine = new Marine($this->db);
103
-            		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
101
+						//$real_arrival = $this->arrival($key);
102
+						$Marine = new Marine($this->db);
103
+						if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
104 104
 				if (isset($globalVM) && $globalVM) {
105
-				    if ($this->all_tracked[$key]['status'] == 'Racing') {
105
+					if ($this->all_tracked[$key]['status'] == 'Racing') {
106 106
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
107
-				    } else {
107
+					} else {
108 108
 					$timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time'];
109
-	        			if ($timerace > time()) $finaldatetime = NULL;
109
+						if ($timerace > time()) $finaldatetime = NULL;
110 110
 					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
111 111
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
112
-				    }
112
+					}
113 113
 				} else {
114 114
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
115 115
 				}
116 116
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
117
-			    }
118
-			    // Put in archive
117
+				}
118
+				// Put in archive
119 119
 //				$Marine->db = null;
120 120
 			}
121
-            	    }
122
-            	    unset($this->all_tracked[$key]);
123
-    	        }
124
-	    }
125
-        }
126
-    }
121
+					}
122
+					unset($this->all_tracked[$key]);
123
+				}
124
+		}
125
+		}
126
+	}
127 127
 
128
-    public function add($line) {
128
+	public function add($line) {
129 129
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM;
130 130
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
131 131
 	date_default_timezone_set('UTC');
@@ -134,106 +134,106 @@  discard block
 block discarded – undo
134 134
 	
135 135
 	// SBS format is CSV format
136 136
 	if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
137
-	    print_r($line);
138
-  	    if (isset($line['mmsi']) || isset($line['id'])) {
137
+		print_r($line);
138
+  		if (isset($line['mmsi']) || isset($line['id'])) {
139 139
 
140 140
 		
141 141
 		// Increment message number
142 142
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
143
-		    $current_date = date('Y-m-d');
144
-		    if (isset($line['source_name'])) $source = $line['source_name'];
145
-		    else $source = '';
146
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
147
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
148
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
149
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
150
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
143
+			$current_date = date('Y-m-d');
144
+			if (isset($line['source_name'])) $source = $line['source_name'];
145
+			else $source = '';
146
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
147
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
148
+				$this->stats[$current_date][$source]['msg']['date'] = time();
149
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
150
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
151 151
 		}
152 152
 		
153 153
 		
154 154
 		$Common = new Common();
155 155
 		$AIS = new AIS();
156
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
157
-	        else $id = trim($line['id']);
156
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
157
+			else $id = trim($line['id']);
158 158
 		
159 159
 		if (!isset($this->all_tracked[$id])) {
160
-		    $this->all_tracked[$id] = array();
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
162
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
164
-		    if (!isset($line['id'])) {
160
+			$this->all_tracked[$id] = array();
161
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
162
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
164
+			if (!isset($line['id'])) {
165 165
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
166 166
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
167
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
168
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
167
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
168
+			if ($globalAllTracked !== FALSE) $dataFound = true;
169 169
 		}
170 170
 		
171 171
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
173
-		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
172
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
173
+			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
174 174
 			$Marine = new Marine($this->db);
175 175
 			$identity = $Marine->getIdentity($line['mmsi']);
176 176
 			if (!empty($identity)) {
177
-			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
178
-			    $this->all_tracked[$id]['type'] = $identity['type'];
179
-			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
177
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
178
+				$this->all_tracked[$id]['type'] = $identity['type'];
179
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
180 180
 			}
181 181
 			//print_r($identity);
182 182
 			unset($Marine);
183 183
 			//$dataFound = true;
184
-		    }
184
+			}
185 185
 		}
186 186
 		if (isset($line['type_id'])) {
187
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
188
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
187
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
188
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
189 189
 		}
190 190
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
191
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
192
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
191
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
192
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
193 193
 		} elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') {
194
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
194
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
195 195
 		}
196 196
 		if (isset($line['status']) && $line['status'] != '') {
197
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
197
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
198 198
 		}
199 199
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
200
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
201
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
200
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
201
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
202 202
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
203
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
203
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
204 204
 				$Marine = new Marine($this->db);
205 205
 				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
206 206
 				unset($Marine);
207
-			    }
207
+				}
208
+			}
208 209
 			}
209
-		    }
210 210
 		}
211 211
 
212 212
 
213 213
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
214
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
214
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
215 215
 		}
216 216
 		if (isset($line['imo']) && $line['imo'] != '') {
217
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
217
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
218 218
 		}
219 219
 		if (isset($line['callsign']) && $line['callsign'] != '') {
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
220
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
221 221
 		}
222 222
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
223
-		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
223
+			if (!isset($this->all_tracked[$id]['arrival_code'])) {
224 224
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
225 225
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
226 226
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
227
-			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
227
+				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
228 228
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
229
-				    $Marine = new Marine($this->db);
230
-				    $fromsource = NULL;
231
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
232
-				    $Marine->db = null;
229
+					$Marine = new Marine($this->db);
230
+					$fromsource = NULL;
231
+					$Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
232
+					$Marine->db = null;
233
+				}
233 234
 				}
234
-			    }
235 235
 			}
236
-		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
236
+			} elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
237 237
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
238 238
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
239 239
 			if (!isset($line['id'])) {
@@ -241,50 +241,50 @@  discard block
 block discarded – undo
241 241
 				$this->all_tracked[$id]['forcenew'] = 1;
242 242
 				$this->all_tracked[$id]['addedMarine'] = 0;
243 243
 			}
244
-		    }
244
+			}
245 245
 		}
246 246
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
247
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
247
+			if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
248 248
 		}
249 249
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
250
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
251 251
 		}
252 252
 		if (isset($line['captain_name']) && $line['captain_name'] != '') {
253
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
253
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
254 254
 		}
255 255
 		if (isset($line['race_id']) && $line['race_id'] != '') {
256
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
256
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
257 257
 		}
258 258
 		if (isset($line['race_name']) && $line['race_name'] != '') {
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
259
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
260 260
 		}
261 261
 		if (isset($line['race_rank']) && $line['race_rank'] != '') {
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank']));
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank']));
263 263
 		}
264 264
 		if (isset($line['race_time']) && $line['race_time'] != '') {
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time']));
265
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time']));
266 266
 		}
267 267
 		if (isset($line['race_begin']) && $line['race_begin'] != '') {
268
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin']));
268
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin']));
269 269
 		}
270 270
 		if (isset($line['distance']) && $line['distance'] != '') {
271
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance']));
271
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance']));
272 272
 		}
273 273
 
274 274
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
275 275
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
276
-		    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
276
+			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
277 277
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
278
-			    $timeelapsed = microtime(true);
279
-			    $Marine = new Marine($this->db);
280
-			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
281
-			    $Marine->db = null;
278
+				$timeelapsed = microtime(true);
279
+				$Marine = new Marine($this->db);
280
+				$Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
281
+				$Marine->db = null;
282
+			}
282 283
 			}
283
-		    }
284
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
285
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
284
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
285
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
286 286
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
287
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
287
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
288 288
 				$timeelapsed = microtime(true);
289 289
 				$Marine = new Marine($this->db);
290 290
 				$fromsource = NULL;
@@ -292,20 +292,20 @@  discard block
 block discarded – undo
292 292
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
293 293
 				$Marine->db = null;
294 294
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
295
-			    }
295
+				}
296
+			}
296 297
 			}
297
-		    }
298
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
298
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
299 299
 		}
300 300
 
301 301
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
302
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
302
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
303 303
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
304
-		    } else {
304
+			} else {
305 305
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
306 306
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
307 307
 				return '';
308
-		    }
308
+			}
309 309
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
310 310
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
311 311
 			return '';
@@ -322,33 +322,33 @@  discard block
 block discarded – undo
322 322
 
323 323
 
324 324
 		if (isset($line['speed'])) {
325
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2)));
326
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
325
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2)));
326
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
327 327
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
328
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
329
-		    if ($distance > 1000 && $distance < 10000) {
328
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
329
+			if ($distance > 1000 && $distance < 10000) {
330 330
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
331 331
 			$speed = $speed*3.6;
332 332
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
333 333
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n";
334
-		    }
334
+			}
335 335
 		}
336 336
 
337
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
339
-	    	    else unset($timediff);
340
-	    	    if ($this->tmd > 5 ||
341
-	    		!isset($timediff) ||
342
-	    		$timediff > $globalLiveInterval ||
343
-	    		(
344
-	    		    $timediff > 30 && 
345
-	    		    isset($this->all_tracked[$id]['latitude']) &&
346
-	    		    isset($this->all_tracked[$id]['longitude']) &&
347
-	    		    $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
348
-	    		)
349
-	    		) {
337
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
339
+				else unset($timediff);
340
+				if ($this->tmd > 5 ||
341
+				!isset($timediff) ||
342
+				$timediff > $globalLiveInterval ||
343
+				(
344
+					$timediff > 30 && 
345
+					isset($this->all_tracked[$id]['latitude']) &&
346
+					isset($this->all_tracked[$id]['longitude']) &&
347
+					$Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
348
+				)
349
+				) {
350 350
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
351
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
351
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
352 352
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
353 353
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
354 354
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -356,217 +356,217 @@  discard block
 block discarded – undo
356 356
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
357 357
 				$timeelapsed = microtime(true);
358 358
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
359
-				    $Marine = new Marine($this->db);
360
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
361
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
362
-				    $Marine->db = null;
363
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+					$Marine = new Marine($this->db);
360
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
361
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
362
+					$Marine->db = null;
363
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364 364
 				}
365 365
 				$this->tmd = 0;
366 366
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
367
-			    }
367
+				}
368 368
 			}
369 369
 
370 370
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
371 371
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
372 372
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
373
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374
-				    $dataFound = true;
375
-				    $this->all_tracked[$id]['time_last_coord'] = time();
373
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374
+					$dataFound = true;
375
+					$this->all_tracked[$id]['time_last_coord'] = time();
376 376
 				}
377 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
378 378
 			}
379 379
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
380
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
380
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
381 381
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
382 382
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
383
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384
-				    $dataFound = true;
385
-				    $this->all_tracked[$id]['time_last_coord'] = time();
383
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384
+					$dataFound = true;
385
+					$this->all_tracked[$id]['time_last_coord'] = time();
386 386
 				}
387 387
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
388 388
 			}
389 389
 
390
-		    } else if ($globalDebug && $timediff > 20) {
390
+			} else if ($globalDebug && $timediff > 20) {
391 391
 			$this->tmd = $this->tmd + 1;
392 392
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
393 393
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
394 394
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
395 395
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
396
-		    }
396
+			}
397 397
 		}
398 398
 		if (isset($line['last_update']) && $line['last_update'] != '') {
399
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
400
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
399
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
400
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
401 401
 		}
402 402
 		if (isset($line['format_source']) && $line['format_source'] != '') {
403
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
403
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
404 404
 		}
405 405
 		if (isset($line['source_name']) && $line['source_name'] != '') {
406
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
406
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
407 407
 		}
408 408
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
409
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
409
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
410 410
 		}
411 411
 		
412 412
 		if (isset($line['heading']) && $line['heading'] != '') {
413
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
416
-		    //$dataFound = true;
413
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
416
+			//$dataFound = true;
417 417
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
418
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
419
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
418
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
419
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
422 422
   		}
423 423
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
424 424
 
425 425
 
426 426
 
427 427
 		if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) {
428
-		    $this->all_tracked[$id]['lastupdate'] = time();
429
-		    if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) {
430
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
431
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
428
+			$this->all_tracked[$id]['lastupdate'] = time();
429
+			if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) {
430
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
431
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
432 432
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
434
-				    $timeelapsed = microtime(true);
435
-				    $MarineLive = new MarineLive($this->db);
436
-				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
433
+					if ($globalDebug) echo "Check if vessel is already in DB...";
434
+					$timeelapsed = microtime(true);
435
+					$MarineLive = new MarineLive($this->db);
436
+					if (isset($line['id']) && isset($globalVM) && $globalVM) {
437 437
 					$Marine = new Marine($this->db);
438 438
 					$recent_ident = $Marine->checkId($line['id']);
439 439
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
440 440
 					$Marine->db=null;
441
-				    } elseif (isset($line['id'])) {
441
+					} elseif (isset($line['id'])) {
442 442
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
443 443
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
444
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
444
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
445 445
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
446 446
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
447
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
447
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
448 448
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
449 449
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
450
-				    } else $recent_ident = '';
451
-				    $MarineLive->db=null;
452
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
450
+					} else $recent_ident = '';
451
+					$MarineLive->db=null;
452
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
454 454
 				} else $recent_ident = '';
455
-			    } else {
455
+				} else {
456 456
 				$recent_ident = '';
457 457
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
458
-			    }
459
-			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
460
-			    if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461
-			    {
458
+				}
459
+				//if there was no vessel with the same callsign within the last hour and go post it into the archive
460
+				if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461
+				{
462 462
 				if ($globalDebug) {
463 463
 					if ($this->all_tracked[$id]['mmsi'] != '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
464 464
 					else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
465 465
 				}
466 466
 				//adds the spotter data for the archive
467
-				    $highlight = '';
468
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
469
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
467
+					$highlight = '';
468
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
469
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
470 470
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
471
-					    $timeelapsed = microtime(true);
472
-					    $Marine = new Marine($this->db);
473
-					    if (isset($globalVM) && $globalVM && ($this->all_tracked[$id]['race_begin'] != '' || $this->all_tracked[$id]['format_source'] == 'sailaway')) {
471
+						$timeelapsed = microtime(true);
472
+						$Marine = new Marine($this->db);
473
+						if (isset($globalVM) && $globalVM && ($this->all_tracked[$id]['race_begin'] != '' || $this->all_tracked[$id]['format_source'] == 'sailaway')) {
474 474
 						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['race_begin'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
475
-					    } else {
475
+						} else {
476 476
 						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
477
-					    }
478
-					    $Marine->db = null;
479
-					    if ($globalDebug && isset($result)) echo $result."\n";
480
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
477
+						}
478
+						$Marine->db = null;
479
+						if ($globalDebug && isset($result)) echo $result."\n";
480
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481 481
 					}
482
-				    }
483
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
482
+					}
483
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
484 484
 					// Add source stat in DB
485 485
 					$Stats = new Stats($this->db);
486 486
 					if (!empty($this->stats)) {
487
-					    if ($globalDebug) echo 'Add source stats : ';
488
-				    	    foreach($this->stats as $date => $data) {
487
+						if ($globalDebug) echo 'Add source stats : ';
488
+							foreach($this->stats as $date => $data) {
489 489
 						foreach($data as $source => $sourced) {
490
-					    	    //print_r($sourced);
491
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
493
-				    		    if (isset($sourced['msg'])) {
494
-				    			if (time() - $sourced['msg']['date'] > 10) {
495
-				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
496
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
497
-			    			    	    unset($this->stats[$date][$source]['msg']);
498
-			    				}
499
-			    			    }
500
-			    			}
501
-			    			if ($date != date('Y-m-d')) {
502
-			    			    unset($this->stats[$date]);
503
-			    			}
504
-				    	    }
505
-				    	    if ($globalDebug) echo 'Done'."\n";
490
+								//print_r($sourced);
491
+									if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
+									if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
493
+								if (isset($sourced['msg'])) {
494
+								if (time() - $sourced['msg']['date'] > 10) {
495
+										$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
496
+										echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
497
+										unset($this->stats[$date][$source]['msg']);
498
+								}
499
+								}
500
+							}
501
+							if ($date != date('Y-m-d')) {
502
+								unset($this->stats[$date]);
503
+							}
504
+							}
505
+							if ($globalDebug) echo 'Done'."\n";
506 506
 					}
507 507
 					$Stats->db = null;
508
-				    }
508
+					}
509 509
 				    
510
-				    $this->del();
510
+					$this->del();
511 511
 				//$ignoreImport = false;
512 512
 				$this->all_tracked[$id]['addedMarine'] = 1;
513 513
 				//print_r($this->all_tracked[$id]);
514 514
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
515
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 12 hours...";
516
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
517
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
515
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 12 hours...";
516
+					//MarineLive->deleteLiveMarineDataNotUpdated();
517
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 518
 					$MarineLive = new MarineLive($this->db);
519 519
 					$MarineLive->deleteLiveMarineData();
520 520
 					$MarineLive->db=null;
521 521
 					if ($globalDebug) echo " Done\n";
522
-				    }
523
-				    $this->last_delete = time();
522
+					}
523
+					$this->last_delete = time();
524 524
 				}
525
-			    } elseif ($recent_ident != '') {
525
+				} elseif ($recent_ident != '') {
526 526
 				$this->all_tracked[$id]['id'] = $recent_ident;
527 527
 				$this->all_tracked[$id]['addedMarine'] = 1;
528 528
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
529
-				    if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) {
529
+					if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) {
530 530
 					$Marine = new Marine($this->db);
531 531
 					if (isset($globalVM) && $globalVM) {
532
-					    if ($this->all_tracked[$id]['status'] == 'Racing') {
532
+						if ($this->all_tracked[$id]['status'] == 'Racing') {
533 533
 						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
534
-					    } else {
534
+						} else {
535 535
 						//$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536 536
 						$timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
537 537
 						if ($timerace > time()) $finaldatetime = NULL;
538 538
 						else $finaldatetime = date('Y-m-d H:i:s',$timerace);
539 539
 
540 540
 						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
541
-					    }
541
+						}
542 542
 					} else {
543
-					    $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
543
+						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
544 544
 					}
545 545
 					$Marine->db = null;
546
-				    }
546
+					}
547 547
 				}
548 548
 				
549
-			    }
549
+				}
550 550
 			}
551
-		    }
552
-		    //adds the spotter LIVE data
553
-		    if ($globalDebug) {
551
+			}
552
+			//adds the spotter LIVE data
553
+			if ($globalDebug) {
554 554
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
555
-		    }
556
-		    $ignoreImport = false;
557
-		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
558
-		    if (!$ignoreImport) {
555
+			}
556
+			$ignoreImport = false;
557
+			if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
558
+			if (!$ignoreImport) {
559 559
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
560 560
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
561 561
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
562
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
562
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
563 563
 					$timeelapsed = microtime(true);
564 564
 					$MarineLive = new MarineLive($this->db);
565 565
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
566 566
 					$MarineLive->db = null;
567 567
 					if ($globalDebug) echo $result."\n";
568 568
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
569
-				    }
569
+					}
570 570
 				}
571 571
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
572 572
 					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 					if ($stats_heading == 16) $stats_heading = 0;
602 602
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
603 603
 						for ($i=0;$i<=15;$i++) {
604
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
604
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
605 605
 						}
606 606
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
607 607
 					} else {
@@ -614,11 +614,11 @@  discard block
 block discarded – undo
614 614
 					//var_dump($this->stats);
615 615
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
616 616
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
617
-						    end($this->stats[$current_date][$source]['hist']);
618
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
617
+							end($this->stats[$current_date][$source]['hist']);
618
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
619 619
 						} else $mini = 0;
620 620
 						for ($i=$mini;$i<=$distance;$i+=10) {
621
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
621
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
622 622
 						}
623 623
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
624 624
 					} else {
@@ -634,30 +634,30 @@  discard block
 block discarded – undo
634 634
 			
635 635
 			
636 636
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
637
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
637
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
638 638
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
639 639
 				$MarineLive = new MarineLive($this->db);
640 640
 				$MarineLive->deleteLiveMarineDataNotUpdated();
641 641
 				$MarineLive->db = null;
642 642
 				//MarineLive->deleteLiveMarineData();
643 643
 				if ($globalDebug) echo " Done\n";
644
-			    }
645
-			    $this->last_delete_hourly = time();
644
+				}
645
+				$this->last_delete_hourly = time();
646 646
 			}
647 647
 			
648
-		    }
649
-		    //$ignoreImport = false;
648
+			}
649
+			//$ignoreImport = false;
650 650
 		}
651 651
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
652 652
 		if ($send) return $this->all_tracked[$id];
653
-	    }
653
+		}
654
+	}
654 655
 	}
655
-    }
656 656
     
657
-    public function race_add($data) {
658
-        $Marine = new Marine();
659
-        $Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']);
660
-        $Marine->db = null;
661
-    }
657
+	public function race_add($data) {
658
+		$Marine = new Marine();
659
+		$Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']);
660
+		$Marine->db = null;
661
+	}
662 662
 }
663 663
 ?>
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
     		    $Marine = new Marine($this->db);
69 69
     		    if (isset($globalVM) && $globalVM) {
70 70
 			if ($this->all_tracked[$key]['status'] == 'Racing') {
71
-    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
71
+    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
72 72
     			} else {
73
-    			    $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
73
+    			    $timerace = (strtotime($this->all_tracked[$key]['race_begin']) + $this->all_tracked[$key]['race_time']);
74 74
     			    if ($timerace > time()) $finaldatetime = NULL;
75
-    			    else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
-    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
75
+    			    else $finaldatetime = date('Y-m-d H:i:s', $timerace);
76
+    			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $finaldatetime, $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
77 77
     			}
78 78
     		    } else {
79
-			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
79
+			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
80 80
 		    }
81 81
 		}
82 82
 	    }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
90 90
 	foreach ($this->all_tracked as $key => $flight) {
91 91
     	    if (isset($flight['lastupdate'])) {
92
-        	if ($flight['lastupdate'] < (time()-3000)) {
92
+        	if ($flight['lastupdate'] < (time() - 3000)) {
93 93
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94 94
             		if (isset($this->all_tracked[$key]['id'])) {
95 95
             		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
104 104
 				if (isset($globalVM) && $globalVM) {
105 105
 				    if ($this->all_tracked[$key]['status'] == 'Racing') {
106
-					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
106
+					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
107 107
 				    } else {
108
-					$timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time'];
108
+					$timerace = strtotime($this->all_tracked[$key]['race_begin']) + $this->all_tracked[$key]['race_time'];
109 109
 	        			if ($timerace > time()) $finaldatetime = NULL;
110
-					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
111
-					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
110
+					else $finaldatetime = date('Y-m-d H:i:s', $timerace);
111
+					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $finaldatetime, $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
112 112
 				    }
113 113
 				} else {
114
-					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
114
+					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
115 115
 				}
116 116
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
117 117
 			    }
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
     }
127 127
 
128 128
     public function add($line) {
129
-	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM;
129
+	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine, $globalLiveInterval, $globalVM;
130 130
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
131 131
 	date_default_timezone_set('UTC');
132 132
 	$dataFound = false;
133 133
 	$send = false;
134 134
 	
135 135
 	// SBS format is CSV format
136
-	if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
136
+	if (is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
137 137
 	    print_r($line);
138 138
   	    if (isset($line['mmsi']) || isset($line['id'])) {
139 139
 
@@ -158,25 +158,25 @@  discard block
 block discarded – undo
158 158
 		
159 159
 		if (!isset($this->all_tracked[$id])) {
160 160
 		    $this->all_tracked[$id] = array();
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
162
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
161
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0));
162
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '', 'captain_id' => '', 'captain_name' => '', 'race_id' => '', 'race_name' => '', 'distance' => NULL, 'race_rank' => NULL, 'race_time' => NULL, 'race_begin' => ''));
163
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
164 164
 		    if (!isset($line['id'])) {
165 165
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
166
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
167
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
166
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
167
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
168 168
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
169 169
 		}
170 170
 		
171 171
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
172
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
173 173
 		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
174 174
 			$Marine = new Marine($this->db);
175 175
 			$identity = $Marine->getIdentity($line['mmsi']);
176 176
 			if (!empty($identity)) {
177 177
 			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
178 178
 			    $this->all_tracked[$id]['type'] = $identity['type'];
179
-			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
179
+			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($identity['type'])));
180 180
 			}
181 181
 			//print_r($identity);
182 182
 			unset($Marine);
@@ -184,25 +184,25 @@  discard block
 block discarded – undo
184 184
 		    }
185 185
 		}
186 186
 		if (isset($line['type_id'])) {
187
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
188
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
187
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
188
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id']));
189 189
 		}
190 190
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
191
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
192
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
191
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
192
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($line['type'])));
193 193
 		} elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') {
194
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
194
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
195 195
 		}
196 196
 		if (isset($line['status']) && $line['status'] != '') {
197
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
197
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
198 198
 		}
199 199
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
200
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
200
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id']));
201 201
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
202 202
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
203 203
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
204 204
 				$Marine = new Marine($this->db);
205
-				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
205
+				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']);
206 206
 				unset($Marine);
207 207
 			    }
208 208
 			}
@@ -211,24 +211,24 @@  discard block
 block discarded – undo
211 211
 
212 212
 
213 213
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
214
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
214
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type']));
215 215
 		}
216 216
 		if (isset($line['imo']) && $line['imo'] != '') {
217
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
217
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
218 218
 		}
219 219
 		if (isset($line['callsign']) && $line['callsign'] != '') {
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
220
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
221 221
 		}
222 222
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
223 223
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
224
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
224
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
225 225
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
226 226
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
227 227
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
228 228
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
229 229
 				    $Marine = new Marine($this->db);
230 230
 				    $fromsource = NULL;
231
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
231
+				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource);
232 232
 				    $Marine->db = null;
233 233
 				}
234 234
 			    }
@@ -244,31 +244,31 @@  discard block
 block discarded – undo
244 244
 		    }
245 245
 		}
246 246
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
247
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
247
+		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
248 248
 		}
249 249
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
250
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
250
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_id' => $line['captain_id']));
251 251
 		}
252 252
 		if (isset($line['captain_name']) && $line['captain_name'] != '') {
253
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
253
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_name' => $line['captain_name']));
254 254
 		}
255 255
 		if (isset($line['race_id']) && $line['race_id'] != '') {
256
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
256
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_id' => $line['race_id']));
257 257
 		}
258 258
 		if (isset($line['race_name']) && $line['race_name'] != '') {
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
259
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_name' => $line['race_name']));
260 260
 		}
261 261
 		if (isset($line['race_rank']) && $line['race_rank'] != '') {
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank']));
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_rank' => $line['race_rank']));
263 263
 		}
264 264
 		if (isset($line['race_time']) && $line['race_time'] != '') {
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time']));
265
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_time' => $line['race_time']));
266 266
 		}
267 267
 		if (isset($line['race_begin']) && $line['race_begin'] != '') {
268
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin']));
268
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_begin' => $line['race_begin']));
269 269
 		}
270 270
 		if (isset($line['distance']) && $line['distance'] != '') {
271
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance']));
271
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('distance' => $line['distance']));
272 272
 		}
273 273
 
274 274
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
@@ -277,44 +277,44 @@  discard block
 block discarded – undo
277 277
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
278 278
 			    $timeelapsed = microtime(true);
279 279
 			    $Marine = new Marine($this->db);
280
-			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
280
+			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['type']);
281 281
 			    $Marine->db = null;
282 282
 			}
283 283
 		    }
284
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
284
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
285 285
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
286 286
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
287 287
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
288 288
 				$timeelapsed = microtime(true);
289 289
 				$Marine = new Marine($this->db);
290 290
 				$fromsource = NULL;
291
-				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
291
+				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
292 292
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
293 293
 				$Marine->db = null;
294
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
294
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
295 295
 			    }
296 296
 			}
297 297
 		    }
298
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
298
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
299 299
 		}
300 300
 
301
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
301
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) {
302 302
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
303
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
303
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
304 304
 		    } else {
305 305
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
306 306
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
307 307
 				return '';
308 308
 		    }
309
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
309
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) {
310 310
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
311 311
 			return '';
312
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
312
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) {
313 313
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
314 314
 			return '';
315 315
 		} elseif (!isset($line['datetime'])) {
316 316
 			date_default_timezone_set('UTC');
317
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
317
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
318 318
 		} else {
319 319
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
320 320
 			return '';
@@ -322,20 +322,20 @@  discard block
 block discarded – undo
322 322
 
323 323
 
324 324
 		if (isset($line['speed'])) {
325
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2)));
326
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
325
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'], 2)));
326
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
327 327
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
328
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
328
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
329 329
 		    if ($distance > 1000 && $distance < 10000) {
330 330
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
331 331
 			$speed = $speed*3.6;
332
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
332
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed, 2)));
333 333
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n";
334 334
 		    }
335 335
 		}
336 336
 
337 337
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
338
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
339 339
 	    	    else unset($timediff);
340 340
 	    	    if ($this->tmd > 5 ||
341 341
 	    		!isset($timediff) ||
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 	    		    $timediff > 30 && 
345 345
 	    		    isset($this->all_tracked[$id]['latitude']) &&
346 346
 	    		    isset($this->all_tracked[$id]['longitude']) &&
347
-	    		    $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
347
+	    		    $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'))
348 348
 	    		)
349 349
 	    		) {
350 350
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
351
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
351
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
352 352
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
353 353
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
354 354
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 				$timeelapsed = microtime(true);
358 358
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
359 359
 				    $Marine = new Marine($this->db);
360
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
360
+				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
361 361
 				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
362 362
 				    $Marine->db = null;
363
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
363
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
364 364
 				}
365 365
 				$this->tmd = 0;
366 366
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
@@ -369,55 +369,55 @@  discard block
 block discarded – undo
369 369
 
370 370
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
371 371
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
372
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
372
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
373 373
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374 374
 				    $dataFound = true;
375 375
 				    $this->all_tracked[$id]['time_last_coord'] = time();
376 376
 				}
377
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
377
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
378 378
 			}
379 379
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
380 380
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
381 381
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
382
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
382
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
383 383
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384 384
 				    $dataFound = true;
385 385
 				    $this->all_tracked[$id]['time_last_coord'] = time();
386 386
 				}
387
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
387
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
388 388
 			}
389 389
 
390 390
 		    } else if ($globalDebug && $timediff > 20) {
391 391
 			$this->tmd = $this->tmd + 1;
392 392
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
393
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
394
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
393
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
394
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
395 395
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
396 396
 		    }
397 397
 		}
398 398
 		if (isset($line['last_update']) && $line['last_update'] != '') {
399 399
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
400
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
400
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
401 401
 		}
402 402
 		if (isset($line['format_source']) && $line['format_source'] != '') {
403
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
403
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
404 404
 		}
405 405
 		if (isset($line['source_name']) && $line['source_name'] != '') {
406
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
406
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
407 407
 		}
408 408
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
409
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
409
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
410 410
 		}
411 411
 		
412 412
 		if (isset($line['heading']) && $line['heading'] != '') {
413
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
413
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
415
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
416 416
 		    //$dataFound = true;
417 417
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
418
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
419
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
418
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
419
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
420
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421 421
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
422 422
   		}
423 423
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 		if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) {
428 428
 		    $this->all_tracked[$id]['lastupdate'] = time();
429 429
 		    if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) {
430
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
430
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
431 431
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
432 432
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433 433
 				    if ($globalDebug) echo "Check if vessel is already in DB...";
@@ -436,28 +436,28 @@  discard block
 block discarded – undo
436 436
 				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
437 437
 					$Marine = new Marine($this->db);
438 438
 					$recent_ident = $Marine->checkId($line['id']);
439
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
440
-					$Marine->db=null;
439
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
440
+					$Marine->db = null;
441 441
 				    } elseif (isset($line['id'])) {
442 442
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
443
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
443
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
444 444
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
445 445
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
446
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
446
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
447 447
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
448 448
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
449
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
449
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
450 450
 				    } else $recent_ident = '';
451
-				    $MarineLive->db=null;
451
+				    $MarineLive->db = null;
452 452
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453 453
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
454 454
 				} else $recent_ident = '';
455 455
 			    } else {
456 456
 				$recent_ident = '';
457
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
457
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
458 458
 			    }
459 459
 			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
460
-			    if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
460
+			    if ($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461 461
 			    {
462 462
 				if ($globalDebug) {
463 463
 					if ($this->all_tracked[$id]['mmsi'] != '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
@@ -465,19 +465,19 @@  discard block
 block discarded – undo
465 465
 				}
466 466
 				//adds the spotter data for the archive
467 467
 				    $highlight = '';
468
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
468
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
469 469
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
470 470
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
471 471
 					    $timeelapsed = microtime(true);
472 472
 					    $Marine = new Marine($this->db);
473 473
 					    if (isset($globalVM) && $globalVM && ($this->all_tracked[$id]['race_begin'] != '' || $this->all_tracked[$id]['format_source'] == 'sailaway')) {
474
-						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['race_begin'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
474
+						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['race_begin'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']);
475 475
 					    } else {
476
-						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
476
+						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']);
477 477
 					    }
478 478
 					    $Marine->db = null;
479 479
 					    if ($globalDebug && isset($result)) echo $result."\n";
480
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
480
+					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
481 481
 					}
482 482
 				    }
483 483
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
 					$Stats = new Stats($this->db);
486 486
 					if (!empty($this->stats)) {
487 487
 					    if ($globalDebug) echo 'Add source stats : ';
488
-				    	    foreach($this->stats as $date => $data) {
489
-						foreach($data as $source => $sourced) {
488
+				    	    foreach ($this->stats as $date => $data) {
489
+						foreach ($data as $source => $sourced) {
490 490
 					    	    //print_r($sourced);
491
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
491
+				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date);
492
+				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date);
493 493
 				    		    if (isset($sourced['msg'])) {
494 494
 				    			if (time() - $sourced['msg']['date'] > 10) {
495 495
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
496
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
496
+				    		    	    echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date);
497 497
 			    			    	    unset($this->stats[$date][$source]['msg']);
498 498
 			    				}
499 499
 			    			    }
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 518
 					$MarineLive = new MarineLive($this->db);
519 519
 					$MarineLive->deleteLiveMarineData();
520
-					$MarineLive->db=null;
520
+					$MarineLive->db = null;
521 521
 					if ($globalDebug) echo " Done\n";
522 522
 				    }
523 523
 				    $this->last_delete = time();
@@ -530,17 +530,17 @@  discard block
 block discarded – undo
530 530
 					$Marine = new Marine($this->db);
531 531
 					if (isset($globalVM) && $globalVM) {
532 532
 					    if ($this->all_tracked[$id]['status'] == 'Racing') {
533
-						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
533
+						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']);
534 534
 					    } else {
535 535
 						//$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536
-						$timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536
+						$timerace = (strtotime($this->all_tracked[$id]['race_begin']) + $this->all_tracked[$id]['race_time']);
537 537
 						if ($timerace > time()) $finaldatetime = NULL;
538
-						else $finaldatetime = date('Y-m-d H:i:s',$timerace);
538
+						else $finaldatetime = date('Y-m-d H:i:s', $timerace);
539 539
 
540
-						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
540
+						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $finaldatetime, $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']);
541 541
 					    }
542 542
 					} else {
543
-					    $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
543
+					    $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']);
544 544
 					}
545 545
 					$Marine->db = null;
546 546
 				    }
@@ -556,20 +556,20 @@  discard block
 block discarded – undo
556 556
 		    $ignoreImport = false;
557 557
 		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
558 558
 		    if (!$ignoreImport) {
559
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
559
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
560 560
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
561 561
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
562 562
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
563 563
 					$timeelapsed = microtime(true);
564 564
 					$MarineLive = new MarineLive($this->db);
565
-					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
565
+					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']);
566 566
 					$MarineLive->db = null;
567 567
 					if ($globalDebug) echo $result."\n";
568
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
568
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
569 569
 				    }
570 570
 				}
571 571
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
572
-					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
572
+					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
573 573
 				}
574 574
 				$this->all_tracked[$id]['putinarchive'] = false;
575 575
 
@@ -588,19 +588,19 @@  discard block
 block discarded – undo
588 588
 							$latitude = $globalCenterLatitude;
589 589
 							$longitude = $globalCenterLongitude;
590 590
 						}
591
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
591
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
592 592
 					} else {
593 593
 						$latitude = $this->source_location[$source]['latitude'];
594 594
 						$longitude = $this->source_location[$source]['longitude'];
595 595
 					}
596
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
596
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
597 597
 					//$stats_heading = $stats_heading%22.5;
598 598
 					$stats_heading = round($stats_heading/22.5);
599
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
599
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
600 600
 					$current_date = date('Y-m-d');
601 601
 					if ($stats_heading == 16) $stats_heading = 0;
602 602
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
603
-						for ($i=0;$i<=15;$i++) {
603
+						for ($i = 0; $i <= 15; $i++) {
604 604
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
605 605
 						}
606 606
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -615,9 +615,9 @@  discard block
 block discarded – undo
615 615
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
616 616
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
617 617
 						    end($this->stats[$current_date][$source]['hist']);
618
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
618
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
619 619
 						} else $mini = 0;
620
-						for ($i=$mini;$i<=$distance;$i+=10) {
620
+						for ($i = $mini; $i <= $distance; $i += 10) {
621 621
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
622 622
 						}
623 623
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 
630 630
 				$this->all_tracked[$id]['lastupdate'] = time();
631 631
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
632
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
632
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
633 633
 			//$this->del();
634 634
 			
635 635
 			
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
     
657 657
     public function race_add($data) {
658 658
         $Marine = new Marine();
659
-        $Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']);
659
+        $Marine->addRace($data['id'], $data['name'], $data['creator'], $data['desc'], $data['startdate'], $data['markers']);
660 660
         $Marine->db = null;
661 661
     }
662 662
 }
Please login to merge, or discard this patch.
Braces   +225 added lines, -78 removed lines patch added patch discarded remove patch
@@ -61,7 +61,9 @@  discard block
 block discarded – undo
61 61
     public function checkAll() {
62 62
 	global $globalDebug, $globalNoDB, $globalVM;
63 63
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
64
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
64
+	    if ($globalDebug) {
65
+	    	echo "Update last seen tracked data...\n";
66
+	    }
65 67
 	    foreach ($this->all_tracked as $key => $flight) {
66 68
 		if (isset($this->all_tracked[$key]['id'])) {
67 69
 		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -71,8 +73,11 @@  discard block
 block discarded – undo
71 73
     			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
72 74
     			} else {
73 75
     			    $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
74
-    			    if ($timerace > time()) $finaldatetime = NULL;
75
-    			    else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
+    			    if ($timerace > time()) {
77
+    			    	$finaldatetime = NULL;
78
+    			    } else {
79
+    			    	$finaldatetime = date('Y-m-d H:i:s',$timerace);
80
+    			    }
76 81
     			    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
77 82
     			}
78 83
     		    } else {
@@ -86,13 +91,17 @@  discard block
 block discarded – undo
86 91
     public function del() {
87 92
 	global $globalDebug, $globalNoDB, $globalNoImport;
88 93
 	// Delete old infos
89
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
94
+	if ($globalDebug) {
95
+		echo 'Delete old values and update latest data...'."\n";
96
+	}
90 97
 	foreach ($this->all_tracked as $key => $flight) {
91 98
     	    if (isset($flight['lastupdate'])) {
92 99
         	if ($flight['lastupdate'] < (time()-3000)) {
93 100
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94 101
             		if (isset($this->all_tracked[$key]['id'])) {
95
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
102
+            		    if ($globalDebug) {
103
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
104
+            		    }
96 105
 			    /*
97 106
 			    $MarineLive = new MarineLive();
98 107
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -106,14 +115,19 @@  discard block
 block discarded – undo
106 115
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
107 116
 				    } else {
108 117
 					$timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time'];
109
-	        			if ($timerace > time()) $finaldatetime = NULL;
110
-					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
118
+	        			if ($timerace > time()) {
119
+	        				$finaldatetime = NULL;
120
+	        			} else {
121
+						$finaldatetime = date('Y-m-d H:i:s',$timerace);
122
+					}
111 123
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
112 124
 				    }
113 125
 				} else {
114 126
 					$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
115 127
 				}
116
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
128
+				if ($globalDebug && $result != 'success') {
129
+					echo '!!! ERROR : '.$result."\n";
130
+				}
117 131
 			    }
118 132
 			    // Put in archive
119 133
 //				$Marine->db = null;
@@ -127,7 +141,9 @@  discard block
 block discarded – undo
127 141
 
128 142
     public function add($line) {
129 143
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM;
130
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
144
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
145
+		$globalCoordMinChange = '0.02';
146
+	}
131 147
 	date_default_timezone_set('UTC');
132 148
 	$dataFound = false;
133 149
 	$send = false;
@@ -141,20 +157,30 @@  discard block
 block discarded – undo
141 157
 		// Increment message number
142 158
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
143 159
 		    $current_date = date('Y-m-d');
144
-		    if (isset($line['source_name'])) $source = $line['source_name'];
145
-		    else $source = '';
146
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
160
+		    if (isset($line['source_name'])) {
161
+		    	$source = $line['source_name'];
162
+		    } else {
163
+		    	$source = '';
164
+		    }
165
+		    if ($source == '' || $line['format_source'] == 'aprs') {
166
+		    	$source = $line['format_source'];
167
+		    }
147 168
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
148 169
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
149 170
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
150
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
171
+		    } else {
172
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
173
+		    }
151 174
 		}
152 175
 		
153 176
 		
154 177
 		$Common = new Common();
155 178
 		$AIS = new AIS();
156
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
157
-	        else $id = trim($line['id']);
179
+	        if (!isset($line['id'])) {
180
+	        	$id = trim($line['mmsi']);
181
+	        } else {
182
+	        	$id = trim($line['id']);
183
+	        }
158 184
 		
159 185
 		if (!isset($this->all_tracked[$id])) {
160 186
 		    $this->all_tracked[$id] = array();
@@ -162,10 +188,16 @@  discard block
 block discarded – undo
162 188
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163 189
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
164 190
 		    if (!isset($line['id'])) {
165
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
191
+			if (!isset($globalDaemon)) {
192
+				$globalDaemon = TRUE;
193
+			}
166 194
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
167
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
168
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
195
+		     } else {
196
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
197
+		     }
198
+		    if ($globalAllTracked !== FALSE) {
199
+		    	$dataFound = true;
200
+		    }
169 201
 		}
170 202
 		
171 203
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -222,7 +254,9 @@  discard block
 block discarded – undo
222 254
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
223 255
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
224 256
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
225
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
257
+			if ($globalDebug) {
258
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
259
+			}
226 260
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
227 261
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
228 262
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -235,7 +269,9 @@  discard block
 block discarded – undo
235 269
 			}
236 270
 		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
237 271
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
238
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
272
+			if ($globalDebug) {
273
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
274
+			}
239 275
 			if (!isset($line['id'])) {
240 276
 				$this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi');
241 277
 				$this->all_tracked[$id]['forcenew'] = 1;
@@ -244,7 +280,9 @@  discard block
 block discarded – undo
244 280
 		    }
245 281
 		}
246 282
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
247
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
283
+		    if (strtotime($line['arrival_date']) > time()) {
284
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
285
+		    }
248 286
 		}
249 287
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
250 288
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
@@ -289,34 +327,49 @@  discard block
 block discarded – undo
289 327
 				$Marine = new Marine($this->db);
290 328
 				$fromsource = NULL;
291 329
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
292
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
330
+				if ($globalDebug && $result != 'success') {
331
+					echo '!!! ERROR : '.$result."\n";
332
+				}
293 333
 				$Marine->db = null;
294
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
334
+				if ($globalDebugTimeElapsed) {
335
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
336
+				}
295 337
 			    }
296 338
 			}
297 339
 		    }
298
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
340
+		    if (!isset($this->all_tracked[$id]['id'])) {
341
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
342
+		    }
299 343
 		}
300 344
 
301 345
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
302 346
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
303 347
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
304 348
 		    } else {
305
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
306
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
349
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
350
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
351
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
352
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
353
+				}
307 354
 				return '';
308 355
 		    }
309 356
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
310
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
357
+			if ($globalDebug) {
358
+				echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
359
+			}
311 360
 			return '';
312 361
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
313
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
362
+			if ($globalDebug) {
363
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
364
+			}
314 365
 			return '';
315 366
 		} elseif (!isset($line['datetime'])) {
316 367
 			date_default_timezone_set('UTC');
317 368
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
318 369
 		} else {
319
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
370
+			if ($globalDebug) {
371
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
372
+			}
320 373
 			return '';
321 374
 		}
322 375
 
@@ -329,14 +382,21 @@  discard block
 block discarded – undo
329 382
 		    if ($distance > 1000 && $distance < 10000) {
330 383
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
331 384
 			$speed = $speed*3.6;
332
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
333
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n";
385
+			if ($speed < 1000) {
386
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
387
+			}
388
+  			if ($globalDebug) {
389
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n";
390
+  			}
334 391
 		    }
335 392
 		}
336 393
 
337 394
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
339
-	    	    else unset($timediff);
395
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
396
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
397
+	    	    } else {
398
+	    	    	unset($timediff);
399
+	    	    }
340 400
 	    	    if ($this->tmd > 5 ||
341 401
 	    		!isset($timediff) ||
342 402
 	    		$timediff > $globalLiveInterval ||
@@ -353,22 +413,32 @@  discard block
 block discarded – undo
353 413
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
354 414
 				$this->all_tracked[$id]['putinarchive'] = true;
355 415
 				
356
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
416
+				if ($globalDebug) {
417
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
418
+				}
357 419
 				$timeelapsed = microtime(true);
358 420
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
359 421
 				    $Marine = new Marine($this->db);
360 422
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
361
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
423
+				    if (!empty($all_country)) {
424
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
425
+				    }
362 426
 				    $Marine->db = null;
363
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
427
+				    if ($globalDebugTimeElapsed) {
428
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
429
+				    }
364 430
 				}
365 431
 				$this->tmd = 0;
366
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
432
+				if ($globalDebug) {
433
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
434
+				}
367 435
 			    }
368 436
 			}
369 437
 
370 438
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
371
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
439
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
440
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
441
+				}
372 442
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
373 443
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374 444
 				    $dataFound = true;
@@ -377,8 +447,12 @@  discard block
 block discarded – undo
377 447
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
378 448
 			}
379 449
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
380
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
381
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
450
+			    if ($line['longitude'] > 180) {
451
+			    	$line['longitude'] = $line['longitude'] - 360;
452
+			    }
453
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
454
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
455
+				}
382 456
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
383 457
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384 458
 				    $dataFound = true;
@@ -396,7 +470,9 @@  discard block
 block discarded – undo
396 470
 		    }
397 471
 		}
398 472
 		if (isset($line['last_update']) && $line['last_update'] != '') {
399
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
473
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
474
+		    	$dataFound = true;
475
+		    }
400 476
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
401 477
 		}
402 478
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -410,15 +486,21 @@  discard block
 block discarded – undo
410 486
 		}
411 487
 		
412 488
 		if (isset($line['heading']) && $line['heading'] != '') {
413
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
489
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
490
+		    	$this->all_tracked[$id]['putinarchive'] = true;
491
+		    }
414 492
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415 493
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
416 494
 		    //$dataFound = true;
417 495
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
418 496
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
419 497
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
498
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
499
+		    	$this->all_tracked[$id]['putinarchive'] = true;
500
+		    }
501
+  		    if ($globalDebug) {
502
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
503
+  		    }
422 504
   		}
423 505
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
424 506
 
@@ -430,28 +512,45 @@  discard block
 block discarded – undo
430 512
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
431 513
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
432 514
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
515
+				    if ($globalDebug) {
516
+				    	echo "Check if vessel is already in DB...";
517
+				    }
434 518
 				    $timeelapsed = microtime(true);
435 519
 				    $MarineLive = new MarineLive($this->db);
436 520
 				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
437 521
 					$Marine = new Marine($this->db);
438 522
 					$recent_ident = $Marine->checkId($line['id']);
439
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
523
+					if ($globalDebugTimeElapsed) {
524
+						echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
525
+					}
440 526
 					$Marine->db=null;
441 527
 				    } elseif (isset($line['id'])) {
442 528
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
443
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
529
+					if ($globalDebugTimeElapsed) {
530
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
531
+					}
444 532
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
445 533
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
446
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
534
+					if ($globalDebugTimeElapsed) {
535
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
536
+					}
447 537
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
448 538
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
449
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
450
-				    } else $recent_ident = '';
539
+					if ($globalDebugTimeElapsed) {
540
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
541
+					}
542
+				    } else {
543
+				    	$recent_ident = '';
544
+				    }
451 545
 				    $MarineLive->db=null;
452
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
454
-				} else $recent_ident = '';
546
+				    if ($globalDebug && $recent_ident == '') {
547
+				    	echo " Not in DB.\n";
548
+				    } elseif ($globalDebug && $recent_ident != '') {
549
+				    	echo " Already in DB.\n";
550
+				    }
551
+				} else {
552
+					$recent_ident = '';
553
+				}
455 554
 			    } else {
456 555
 				$recent_ident = '';
457 556
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -460,12 +559,17 @@  discard block
 block discarded – undo
460 559
 			    if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461 560
 			    {
462 561
 				if ($globalDebug) {
463
-					if ($this->all_tracked[$id]['mmsi'] != '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
464
-					else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
562
+					if ($this->all_tracked[$id]['mmsi'] != '') {
563
+						echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
564
+					} else {
565
+						echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
566
+					}
465 567
 				}
466 568
 				//adds the spotter data for the archive
467 569
 				    $highlight = '';
468
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
570
+				    if (!isset($this->all_tracked[$id]['id'])) {
571
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
572
+				    }
469 573
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
470 574
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
471 575
 					    $timeelapsed = microtime(true);
@@ -476,20 +580,30 @@  discard block
 block discarded – undo
476 580
 						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
477 581
 					    }
478 582
 					    $Marine->db = null;
479
-					    if ($globalDebug && isset($result)) echo $result."\n";
480
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
583
+					    if ($globalDebug && isset($result)) {
584
+					    	echo $result."\n";
585
+					    }
586
+					    if ($globalDebugTimeElapsed) {
587
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
588
+					    }
481 589
 					}
482 590
 				    }
483 591
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
484 592
 					// Add source stat in DB
485 593
 					$Stats = new Stats($this->db);
486 594
 					if (!empty($this->stats)) {
487
-					    if ($globalDebug) echo 'Add source stats : ';
595
+					    if ($globalDebug) {
596
+					    	echo 'Add source stats : ';
597
+					    }
488 598
 				    	    foreach($this->stats as $date => $data) {
489 599
 						foreach($data as $source => $sourced) {
490 600
 					    	    //print_r($sourced);
491
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
601
+				    	    	    if (isset($sourced['polar'])) {
602
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
603
+				    	    	    }
604
+				    	    	    if (isset($sourced['hist'])) {
605
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
606
+				    	    	    }
493 607
 				    		    if (isset($sourced['msg'])) {
494 608
 				    			if (time() - $sourced['msg']['date'] > 10) {
495 609
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -502,7 +616,9 @@  discard block
 block discarded – undo
502 616
 			    			    unset($this->stats[$date]);
503 617
 			    			}
504 618
 				    	    }
505
-				    	    if ($globalDebug) echo 'Done'."\n";
619
+				    	    if ($globalDebug) {
620
+				    	    	echo 'Done'."\n";
621
+				    	    }
506 622
 					}
507 623
 					$Stats->db = null;
508 624
 				    }
@@ -512,13 +628,17 @@  discard block
 block discarded – undo
512 628
 				$this->all_tracked[$id]['addedMarine'] = 1;
513 629
 				//print_r($this->all_tracked[$id]);
514 630
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
515
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 12 hours...";
631
+				    if ($globalDebug) {
632
+				    	echo "---- Deleting Live Marine data older than 12 hours...";
633
+				    }
516 634
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
517 635
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 636
 					$MarineLive = new MarineLive($this->db);
519 637
 					$MarineLive->deleteLiveMarineData();
520 638
 					$MarineLive->db=null;
521
-					if ($globalDebug) echo " Done\n";
639
+					if ($globalDebug) {
640
+						echo " Done\n";
641
+					}
522 642
 				    }
523 643
 				    $this->last_delete = time();
524 644
 				}
@@ -534,8 +654,11 @@  discard block
 block discarded – undo
534 654
 					    } else {
535 655
 						//$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536 656
 						$timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
537
-						if ($timerace > time()) $finaldatetime = NULL;
538
-						else $finaldatetime = date('Y-m-d H:i:s',$timerace);
657
+						if ($timerace > time()) {
658
+							$finaldatetime = NULL;
659
+						} else {
660
+							$finaldatetime = date('Y-m-d H:i:s',$timerace);
661
+						}
539 662
 
540 663
 						$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
541 664
 					    }
@@ -554,18 +677,26 @@  discard block
 block discarded – undo
554 677
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
555 678
 		    }
556 679
 		    $ignoreImport = false;
557
-		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
680
+		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') {
681
+		    	$ignoreImport = true;
682
+		    }
558 683
 		    if (!$ignoreImport) {
559 684
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
560
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
685
+				if ($globalDebug) {
686
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
687
+				}
561 688
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
562 689
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
563 690
 					$timeelapsed = microtime(true);
564 691
 					$MarineLive = new MarineLive($this->db);
565 692
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
566 693
 					$MarineLive->db = null;
567
-					if ($globalDebug) echo $result."\n";
568
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
694
+					if ($globalDebug) {
695
+						echo $result."\n";
696
+					}
697
+					if ($globalDebugTimeElapsed) {
698
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
699
+					}
569 700
 				    }
570 701
 				}
571 702
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -577,7 +708,9 @@  discard block
 block discarded – undo
577 708
 				
578 709
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
579 710
 					$source = $this->all_tracked[$id]['source_name'];
580
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
711
+					if ($source == '') {
712
+						$source = $this->all_tracked[$id]['format_source'];
713
+					}
581 714
 					if (!isset($this->source_location[$source])) {
582 715
 						$Location = new Source($this->db);
583 716
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -598,7 +731,9 @@  discard block
 block discarded – undo
598 731
 					$stats_heading = round($stats_heading/22.5);
599 732
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
600 733
 					$current_date = date('Y-m-d');
601
-					if ($stats_heading == 16) $stats_heading = 0;
734
+					if ($stats_heading == 16) {
735
+						$stats_heading = 0;
736
+					}
602 737
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
603 738
 						for ($i=0;$i<=15;$i++) {
604 739
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -616,7 +751,9 @@  discard block
 block discarded – undo
616 751
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
617 752
 						    end($this->stats[$current_date][$source]['hist']);
618 753
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
619
-						} else $mini = 0;
754
+						} else {
755
+							$mini = 0;
756
+						}
620 757
 						for ($i=$mini;$i<=$distance;$i+=10) {
621 758
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
622 759
 						}
@@ -628,19 +765,27 @@  discard block
 block discarded – undo
628 765
 				
629 766
 
630 767
 				$this->all_tracked[$id]['lastupdate'] = time();
631
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
632
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
768
+				if ($this->all_tracked[$id]['putinarchive']) {
769
+					$send = true;
770
+				}
771
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
772
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
773
+			}
633 774
 			//$this->del();
634 775
 			
635 776
 			
636 777
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
637 778
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
638
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
779
+				if ($globalDebug) {
780
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
781
+				}
639 782
 				$MarineLive = new MarineLive($this->db);
640 783
 				$MarineLive->deleteLiveMarineDataNotUpdated();
641 784
 				$MarineLive->db = null;
642 785
 				//MarineLive->deleteLiveMarineData();
643
-				if ($globalDebug) echo " Done\n";
786
+				if ($globalDebug) {
787
+					echo " Done\n";
788
+				}
644 789
 			    }
645 790
 			    $this->last_delete_hourly = time();
646 791
 			}
@@ -649,7 +794,9 @@  discard block
 block discarded – undo
649 794
 		    //$ignoreImport = false;
650 795
 		}
651 796
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
652
-		if ($send) return $this->all_tracked[$id];
797
+		if ($send) {
798
+			return $this->all_tracked[$id];
799
+		}
653 800
 	    }
654 801
 	}
655 802
     }
Please login to merge, or discard this patch.