Completed
Push — master ( 06f826...32823f )
by Yannick
68:39 queued 38:54
created
scripts/daemon-spotter.php 3 patches
Indentation   +1117 added lines, -1117 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,46 +149,46 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
177
-        	//$formats[$id] = 'aircraftjson';
178
-        	$globalSources[$id]['format'] = 'aircraftjson';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraft$/i',$host)) {
182
-        	//$formats[$id] = 'planefinderclient';
183
-        	$globalSources[$id]['format'] = 'planefinderclient';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
-    	    } else if (preg_match('/opensky/i',$host)) {
187
-        	//$formats[$id] = 'aircraftlistjson';
188
-        	$globalSources[$id]['format'] = 'opensky';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/aircraft.json$/i',$host)) {
177
+			//$formats[$id] = 'aircraftjson';
178
+			$globalSources[$id]['format'] = 'aircraftjson';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
+			} else if (preg_match('/aircraft$/i',$host)) {
182
+			//$formats[$id] = 'planefinderclient';
183
+			$globalSources[$id]['format'] = 'planefinderclient';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
+			} else if (preg_match('/opensky/i',$host)) {
187
+			//$formats[$id] = 'aircraftlistjson';
188
+			$globalSources[$id]['format'] = 'opensky';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
+			/*
192 192
     	    // Disabled for now, site change source format
193 193
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
194 194
         	//$formats[$id] = 'radarvirtueljson';
@@ -200,128 +200,128 @@  discard block
 block discarded – undo
200 200
         	    exit(0);
201 201
         	}
202 202
     	    */
203
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
-        	//$formats[$id] = 'planeupdatefaa';
205
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
206
-        	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
-        	    exit(0);
211
-        	}
212
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'phpvmacars';
215
-        	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
-        	//$formats[$id] = 'phpvmacars';
219
-        	$globalSources[$id]['format'] = 'vaos';
220
-        	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
-            } else if (preg_match('/whazzup/i',$host)) {
227
-        	//$formats[$id] = 'whazzup';
228
-        	$globalSources[$id]['format'] = 'whazzup';
229
-        	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
-            } else if (preg_match('/blitzortung/i',$host)) {
232
-        	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
-            } else if (preg_match('/airwhere/i',$host)) {
235
-        	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
-            } else if (preg_match('/recentpireps/i',$host)) {
238
-        	//$formats[$id] = 'pirepsjson';
239
-        	$globalSources[$id]['format'] = 'pirepsjson';
240
-        	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
-        	//$formats[$id] = 'fr24json';
244
-        	$globalSources[$id]['format'] = 'fr24json';
245
-        	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
-        	    exit(0);
250
-        	}
251
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
252
-        	//$formats[$id] = 'fr24json';
253
-        	$globalSources[$id]['format'] = 'myshiptracking';
254
-        	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
-        	    exit(0);
259
-        	}
260
-            //} else if (preg_match('/10001/',$host)) {
261
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
-        	//$formats[$id] = 'tsv';
263
-        	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
-            }
266
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
-    		    if ($idf !== false) {
270
-    			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276
-	    $hostport = explode(':',$host);
277
-	    if (isset($hostport[1])) {
203
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
+			//$formats[$id] = 'planeupdatefaa';
205
+			$globalSources[$id]['format'] = 'planeupdatefaa';
206
+			//$last_exec['planeupdatefaa'] = 0;
207
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
+				exit(0);
211
+			}
212
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'phpvmacars';
215
+			//$last_exec['phpvmacars'] = 0;
216
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
+			//$formats[$id] = 'phpvmacars';
219
+			$globalSources[$id]['format'] = 'vaos';
220
+			//$last_exec['phpvmacars'] = 0;
221
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'vam';
225
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
+			} else if (preg_match('/whazzup/i',$host)) {
227
+			//$formats[$id] = 'whazzup';
228
+			$globalSources[$id]['format'] = 'whazzup';
229
+			//$last_exec['whazzup'] = 0;
230
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
+			} else if (preg_match('/blitzortung/i',$host)) {
232
+			$globalSources[$id]['format'] = 'blitzortung';
233
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
+			} else if (preg_match('/airwhere/i',$host)) {
235
+			$globalSources[$id]['format'] = 'airwhere';
236
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
+			} else if (preg_match('/recentpireps/i',$host)) {
238
+			//$formats[$id] = 'pirepsjson';
239
+			$globalSources[$id]['format'] = 'pirepsjson';
240
+			//$last_exec['pirepsjson'] = 0;
241
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
+			//$formats[$id] = 'fr24json';
244
+			$globalSources[$id]['format'] = 'fr24json';
245
+			//$last_exec['fr24json'] = 0;
246
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
+				exit(0);
250
+			}
251
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
252
+			//$formats[$id] = 'fr24json';
253
+			$globalSources[$id]['format'] = 'myshiptracking';
254
+			//$last_exec['fr24json'] = 0;
255
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
+				exit(0);
259
+			}
260
+			//} else if (preg_match('/10001/',$host)) {
261
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
+			//$formats[$id] = 'tsv';
263
+			$globalSources[$id]['format'] = 'tsv';
264
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
+			}
266
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
+				if ($idf !== false) {
270
+				$httpfeeds[$id] = $idf;
271
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
+			} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
+			elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276
+		$hostport = explode(':',$host);
277
+		if (isset($hostport[1])) {
278 278
 		$port = $hostport[1];
279 279
 		$hostn = $hostport[0];
280
-	    } else {
280
+		} else {
281 281
 		$port = $globalSources[$id]['port'];
282 282
 		$hostn = $globalSources[$id]['host'];
283
-	    }
284
-	    $Common = new Common();
285
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
286
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
287
-    	    } else {
288
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
289
-	    }
290
-	    if ($s) {
291
-    	        $sockets[$id] = $s;
292
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
293
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
283
+		}
284
+		$Common = new Common();
285
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
286
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
287
+			} else {
288
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
289
+		}
290
+		if ($s) {
291
+				$sockets[$id] = $s;
292
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
293
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
294 294
 			//$formats[$id] = 'aprs';
295 295
 			$globalSources[$id]['format'] = 'aprs';
296 296
 			//$aprs_connect = 0;
297 297
 			//$use_aprs = true;
298
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
298
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
299 299
 			$globalSources[$id]['format'] = 'vrstcp';
300
-    		    } elseif ($port == '10001') {
301
-        		//$formats[$id] = 'tsv';
302
-        		$globalSources[$id]['format'] = 'tsv';
303
-		    } elseif ($port == '30002') {
304
-        		//$formats[$id] = 'raw';
305
-        		$globalSources[$id]['format'] = 'raw';
306
-		    } elseif ($port == '5001') {
307
-        		//$formats[$id] = 'raw';
308
-        		$globalSources[$id]['format'] = 'flightgearmp';
309
-		    } elseif ($port == '30005') {
300
+				} elseif ($port == '10001') {
301
+				//$formats[$id] = 'tsv';
302
+				$globalSources[$id]['format'] = 'tsv';
303
+			} elseif ($port == '30002') {
304
+				//$formats[$id] = 'raw';
305
+				$globalSources[$id]['format'] = 'raw';
306
+			} elseif ($port == '5001') {
307
+				//$formats[$id] = 'raw';
308
+				$globalSources[$id]['format'] = 'flightgearmp';
309
+			} elseif ($port == '30005') {
310 310
 			// Not yet supported
311
-        		//$formats[$id] = 'beast';
312
-        		$globalSources[$id]['format'] = 'beast';
313
-		    //} else $formats[$id] = 'sbs';
314
-		    } else $globalSources[$id]['format'] = 'sbs';
315
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
311
+				//$formats[$id] = 'beast';
312
+				$globalSources[$id]['format'] = 'beast';
313
+			//} else $formats[$id] = 'sbs';
314
+			} else $globalSources[$id]['format'] = 'sbs';
315
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
316 316
 		}
317 317
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
318
-            } else {
318
+			} else {
319 319
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
320 320
 		sleep(10);
321 321
 		connect_all($hosts);
322
-    	    }
323
-        }
324
-    }
322
+			}
323
+		}
324
+	}
325 325
 }
326 326
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
327 327
 
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
 //connect_all($globalSources);
345 345
 
346 346
 if (isset($globalProxy) && $globalProxy) {
347
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
347
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
348 348
 } else {
349
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
349
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
350 350
 }
351 351
 
352 352
 // APRS Configuration
@@ -355,21 +355,21 @@  discard block
 block discarded – undo
355 355
 	die;
356 356
 }
357 357
 foreach ($globalSources as $key => $source) {
358
-    if (!isset($source['format'])) {
359
-        $globalSources[$key]['format'] = 'auto';
360
-    }
361
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
362
-        unset($globalSources[$key]);
363
-    }
358
+	if (!isset($source['format'])) {
359
+		$globalSources[$key]['format'] = 'auto';
360
+	}
361
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
362
+		unset($globalSources[$key]);
363
+	}
364 364
 }
365 365
 connect_all($globalSources);
366 366
 foreach ($globalSources as $key => $source) {
367
-    if (isset($source['format']) && $source['format'] == 'aprs') {
367
+	if (isset($source['format']) && $source['format'] == 'aprs') {
368 368
 	$aprs_connect = 0;
369 369
 	$use_aprs = true;
370 370
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
371 371
 	break;
372
-    }
372
+	}
373 373
 }
374 374
 
375 375
 if ($use_aprs) {
@@ -410,133 +410,133 @@  discard block
 block discarded – undo
410 410
 
411 411
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
412 412
 while ($i > 0) {
413
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
413
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
414 414
 
415
-    if (!$globalDaemon) $i = $endtime-time();
416
-    // Delete old ATC
417
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
415
+	if (!$globalDaemon) $i = $endtime-time();
416
+	// Delete old ATC
417
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
418 418
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
419
-        $ATC->deleteOldATC();
420
-    }
419
+		$ATC->deleteOldATC();
420
+	}
421 421
     
422
-    if (count($last_exec) == count($globalSources)) {
422
+	if (count($last_exec) == count($globalSources)) {
423 423
 	$max = $globalMinFetch;
424 424
 	foreach ($last_exec as $last) {
425
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
425
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
426 426
 	}
427 427
 	if ($max < $globalMinFetch) {
428
-	    if ($globalDebug) echo 'Sleeping...'."\n";
429
-	    sleep($globalMinFetch-$max+2);
428
+		if ($globalDebug) echo 'Sleeping...'."\n";
429
+		sleep($globalMinFetch-$max+2);
430
+	}
430 431
 	}
431
-    }
432 432
 
433 433
     
434
-    //foreach ($formats as $id => $value) {
435
-    foreach ($globalSources as $id => $value) {
434
+	//foreach ($formats as $id => $value) {
435
+	foreach ($globalSources as $id => $value) {
436 436
 	date_default_timezone_set('UTC');
437 437
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
438 438
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
439 439
 	if ($value['format'] === 'deltadbtxt' && 
440
-	    (
440
+		(
441 441
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
442 442
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
443
-	    )
443
+		)
444 444
 	) {
445
-	    //$buffer = $Common->getData($hosts[$id]);
446
-	    $buffer = $Common->getData($value['host']);
447
-	    if ($buffer != '') $reset = 0;
448
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
-	    $buffer = explode('\n',$buffer);
450
-	    foreach ($buffer as $line) {
451
-    		if ($line != '' && count($line) > 7) {
452
-    		    $line = explode(',', $line);
453
-	            $data = array();
454
-	            $data['hex'] = $line[1]; // hex
455
-	            $data['ident'] = $line[2]; // ident
456
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
461
-	            $data['verticalrate'] = ''; // vertical rate
462
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463
-	            $data['emergency'] = ''; // emergency
464
-		    $data['datetime'] = date('Y-m-d H:i:s');
465
-		    $data['format_source'] = 'deltadbtxt';
466
-    		    $data['id_source'] = $id_source;
467
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
470
-    		    $SI->add($data);
471
-		    unset($data);
472
-    		}
473
-    	    }
474
-    	    $last_exec[$id]['last'] = time();
445
+		//$buffer = $Common->getData($hosts[$id]);
446
+		$buffer = $Common->getData($value['host']);
447
+		if ($buffer != '') $reset = 0;
448
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
+		$buffer = explode('\n',$buffer);
450
+		foreach ($buffer as $line) {
451
+			if ($line != '' && count($line) > 7) {
452
+				$line = explode(',', $line);
453
+				$data = array();
454
+				$data['hex'] = $line[1]; // hex
455
+				$data['ident'] = $line[2]; // ident
456
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
461
+				$data['verticalrate'] = ''; // vertical rate
462
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463
+				$data['emergency'] = ''; // emergency
464
+			$data['datetime'] = date('Y-m-d H:i:s');
465
+			$data['format_source'] = 'deltadbtxt';
466
+				$data['id_source'] = $id_source;
467
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
470
+				$SI->add($data);
471
+			unset($data);
472
+			}
473
+			}
474
+			$last_exec[$id]['last'] = time();
475 475
 	} elseif ($value['format'] === 'aisnmeatxt' && 
476
-	    (
476
+		(
477 477
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
478 478
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
479
-	    )
479
+		)
480 480
 	) {
481
-	    date_default_timezone_set('CET');
482
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483
-	    date_default_timezone_set('UTC');
484
-	    if ($buffer != '') $reset = 0;
485
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
-	    $buffer = explode('\n',$buffer);
487
-	    foreach ($buffer as $line) {
481
+		date_default_timezone_set('CET');
482
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483
+		date_default_timezone_set('UTC');
484
+		if ($buffer != '') $reset = 0;
485
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
+		$buffer = explode('\n',$buffer);
487
+		foreach ($buffer as $line) {
488 488
 		if ($line != '') {
489
-		    //echo "'".$line."'\n";
490
-		    $add = false;
491
-		    $ais_data = $AIS->parse_line(trim($line));
492
-		    $data = array();
493
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
505
-		    if (isset($ais_data['timestamp'])) {
489
+			//echo "'".$line."'\n";
490
+			$add = false;
491
+			$ais_data = $AIS->parse_line(trim($line));
492
+			$data = array();
493
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
505
+			if (isset($ais_data['timestamp'])) {
506 506
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
507 507
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
508
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
509
-			    $add = true;
508
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
509
+				$add = true;
510 510
 			}
511
-		    } else {
511
+			} else {
512 512
 			$data['datetime'] = date('Y-m-d H:i:s');
513 513
 			$add = true;
514
-		    }
515
-		    $data['format_source'] = 'aisnmeatxt';
516
-    		    $data['id_source'] = $id_source;
517
-		    //print_r($data);
518
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
520
-		    unset($data);
514
+			}
515
+			$data['format_source'] = 'aisnmeatxt';
516
+				$data['id_source'] = $id_source;
517
+			//print_r($data);
518
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
520
+			unset($data);
521 521
 		}
522
-    	    }
523
-    	    $last_exec[$id]['last'] = time();
522
+			}
523
+			$last_exec[$id]['last'] = time();
524 524
 	} elseif ($value['format'] === 'aisnmeahttp') {
525
-	    $arr = $httpfeeds;
526
-	    $w = $e = null;
525
+		$arr = $httpfeeds;
526
+		$w = $e = null;
527 527
 	    
528
-	    if (isset($arr[$id])) {
528
+		if (isset($arr[$id])) {
529 529
 		$nn = stream_select($arr,$w,$e,$timeout);
530 530
 		if ($nn > 0) {
531
-		    foreach ($httpfeeds as $feed) {
531
+			foreach ($httpfeeds as $feed) {
532 532
 			$buffer = stream_get_line($feed,2000,"\n");
533 533
 			if ($buffer === FALSE) {
534
-			    connect_all($globalSources);
534
+				connect_all($globalSources);
535 535
 			}
536 536
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
537 537
 			$buffer = explode('\n',$buffer);
538 538
 			foreach ($buffer as $line) {
539
-			    if ($line != '') {
539
+				if ($line != '') {
540 540
 				$ais_data = $AIS->parse_line(trim($line));
541 541
 				$data = array();
542 542
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -554,117 +554,117 @@  discard block
 block discarded – undo
554 554
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
555 555
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
556 556
 				if (isset($ais_data['timestamp'])) {
557
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558 558
 				} else {
559
-				    $data['datetime'] = date('Y-m-d H:i:s');
559
+					$data['datetime'] = date('Y-m-d H:i:s');
560 560
 				}
561 561
 				$data['format_source'] = 'aisnmeahttp';
562 562
 				$data['id_source'] = $id_source;
563 563
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
564 564
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
565 565
 				unset($data);
566
-			    }
566
+				}
567
+			}
567 568
 			}
568
-		    }
569 569
 		} else {
570
-		    $format = $value['format'];
571
-		    if (isset($tt[$format])) $tt[$format]++;
572
-		    else $tt[$format] = 0;
573
-		    if ($tt[$format] > 30) {
570
+			$format = $value['format'];
571
+			if (isset($tt[$format])) $tt[$format]++;
572
+			else $tt[$format] = 0;
573
+			if ($tt[$format] > 30) {
574 574
 			if ($globalDebug) echo 'Reconnect...'."\n";
575 575
 			sleep(2);
576 576
 			//$sourceeen[] = $value;
577 577
 			//connect_all($sourceeen);
578 578
 			//$sourceeen = array();
579 579
 			connect_all($globalSources);
580
-		    }
580
+			}
581
+		}
581 582
 		}
582
-	    }
583 583
 	} elseif ($value['format'] === 'myshiptracking' && 
584
-	    (
584
+		(
585 585
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
586 586
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
587
-	    )
587
+		)
588 588
 	) {
589
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
590
-	    if ($buffer != '') {
589
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
590
+		if ($buffer != '') {
591 591
 		//echo $buffer;
592 592
 		$all_data = json_decode($buffer,true);
593 593
 		//print_r($all_data);
594 594
 		if (isset($all_data[0]['DATA'])) {
595
-		    foreach ($all_data[0]['DATA'] as $line) {
595
+			foreach ($all_data[0]['DATA'] as $line) {
596 596
 			if ($line != '') {
597
-			    $data = array();
598
-			    $data['ident'] = $line['NAME'];
599
-			    $data['mmsi'] = $line['MMSI'];
600
-			    if (strlen($data['mmsi']) > 9) {
597
+				$data = array();
598
+				$data['ident'] = $line['NAME'];
599
+				$data['mmsi'] = $line['MMSI'];
600
+				if (strlen($data['mmsi']) > 9) {
601 601
 				$data['mmsi'] = substr($data['mmsi'],-9);
602
-			    }
603
-			    $data['speed'] = $line['SOG'];
604
-			    $data['heading'] = $line['COG'];
605
-			    $data['latitude'] = $line['LAT'];
606
-			    $data['longitude'] = $line['LNG'];
607
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608
-			    //$data['type_id'] = $line['TYPE'];
609
-			    $data['imo'] = $line['IMO'];
610
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
612
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613
-			    $data['format_source'] = 'myshiptracking';
614
-			    $data['id_source'] = $id_source;
615
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616
-			    $MI->add($data);
617
-			    unset($data);
602
+				}
603
+				$data['speed'] = $line['SOG'];
604
+				$data['heading'] = $line['COG'];
605
+				$data['latitude'] = $line['LAT'];
606
+				$data['longitude'] = $line['LNG'];
607
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608
+				//$data['type_id'] = $line['TYPE'];
609
+				$data['imo'] = $line['IMO'];
610
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
612
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613
+				$data['format_source'] = 'myshiptracking';
614
+				$data['id_source'] = $id_source;
615
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616
+				$MI->add($data);
617
+				unset($data);
618 618
 			}
619
-		    }
619
+			}
620
+		}
620 621
 		}
621
-	    }
622
-	    $last_exec[$id]['last'] = time();
622
+		$last_exec[$id]['last'] = time();
623 623
 	} elseif ($value['format'] === 'boatbeaconapp' && 
624
-	    (
624
+		(
625 625
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
626 626
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
627
-	    )
627
+		)
628 628
 	) {
629
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
630
-	    if ($buffer != '') {
629
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
630
+		if ($buffer != '') {
631 631
 		$all_data = json_decode($buffer,true);
632 632
 		if (isset($all_data[0]['mmsi'])) {
633
-		    foreach ($all_data as $line) {
633
+			foreach ($all_data as $line) {
634 634
 			if ($line != '') {
635
-			    $data = array();
636
-			    $data['ident'] = $line['shipname'];
637
-			    $data['callsign'] = $line['callsign'];
638
-			    $data['mmsi'] = substr($line['mmsi'],-9);
639
-			    $data['speed'] = $line['sog'];
640
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
641
-			    $data['latitude'] = $line['latitude'];
642
-			    $data['longitude'] = $line['longitude'];
643
-			    $data['type_id'] = $line['shiptype'];
644
-			    $data['arrival_code'] = $line['destination'];
645
-			    $data['datetime'] = $line['time'];
646
-			    $data['format_source'] = 'boatbeaconapp';
647
-			    $data['id_source'] = $id_source;
648
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
649
-			    $MI->add($data);
650
-			    unset($data);
635
+				$data = array();
636
+				$data['ident'] = $line['shipname'];
637
+				$data['callsign'] = $line['callsign'];
638
+				$data['mmsi'] = substr($line['mmsi'],-9);
639
+				$data['speed'] = $line['sog'];
640
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
641
+				$data['latitude'] = $line['latitude'];
642
+				$data['longitude'] = $line['longitude'];
643
+				$data['type_id'] = $line['shiptype'];
644
+				$data['arrival_code'] = $line['destination'];
645
+				$data['datetime'] = $line['time'];
646
+				$data['format_source'] = 'boatbeaconapp';
647
+				$data['id_source'] = $id_source;
648
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
649
+				$MI->add($data);
650
+				unset($data);
651
+			}
651 652
 			}
652
-		    }
653 653
 		}
654 654
 		
655
-	    }
656
-    	    $last_exec[$id]['last'] = time();
655
+		}
656
+			$last_exec[$id]['last'] = time();
657 657
 	} elseif ($value['format'] === 'boatnerd' && 
658
-	    (
658
+		(
659 659
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
660 660
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
661
-	    )
661
+		)
662 662
 	) {
663
-	    $buffer = $Common->getData($value['host']);
664
-	    if ($buffer != '') {
663
+		$buffer = $Common->getData($value['host']);
664
+		if ($buffer != '') {
665 665
 		$all_data = json_decode($buffer,true);
666 666
 		if (isset($all_data['features'][0]['id'])) {
667
-		    foreach ($all_data['features'] as $line) {
667
+			foreach ($all_data['features'] as $line) {
668 668
 			print_r($line);
669 669
 			$data = array();
670 670
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -684,76 +684,76 @@  discard block
 block discarded – undo
684 684
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
685 685
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
686 686
 			unset($data);
687
-		    }
687
+			}
688 688
 		}
689 689
 		
690
-	    }
691
-    	    $last_exec[$id]['last'] = time();
690
+		}
691
+			$last_exec[$id]['last'] = time();
692 692
 	} elseif ($value['format'] === 'shipplotter' && 
693
-	    (
693
+		(
694 694
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
695 695
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
696
-	    )
696
+		)
697 697
 	) {
698
-	    if ($globalDebug) echo 'download...';
699
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
-	    if ($globalDebug) echo 'done !'."\n";
701
-	    // FIXME: Need more work
702
-	    if ($buffer != '') $reset = 0;
703
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704
-	    $buffer = explode('\n',$buffer);
705
-	    foreach ($buffer as $line) {
698
+		if ($globalDebug) echo 'download...';
699
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
+		if ($globalDebug) echo 'done !'."\n";
701
+		// FIXME: Need more work
702
+		if ($buffer != '') $reset = 0;
703
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704
+		$buffer = explode('\n',$buffer);
705
+		foreach ($buffer as $line) {
706 706
 		if ($line != '') {
707
-		    $data = array();
708
-		    //echo $line."\n";
709
-		    $data['mmsi'] = (int)substr($line,0,9);
710
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
711
-		    $data['status_id'] = substr($line,21,2);
712
-		    $data['type_id'] = substr($line,24,3);
713
-		    $data['latitude'] = substr($line,29,9);
714
-		    $data['longitude'] = substr($line,41,9);
715
-		    $data['speed'] = round(substr($line,51,5));
716
-		    //$data['course'] = substr($line,57,5);
717
-		    $data['heading'] = round(substr($line,63,3));
718
-		    //$data['draft'] = substr($line,67,4);
719
-		    //$data['length'] = substr($line,72,3);
720
-		    //$data['beam'] = substr($line,76,2);
721
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
722
-		    //$data['callsign'] = trim(substr($line,100,7);
723
-		    $data['arrival_code'] = substr($line,108,20);
724
-		    //$data['etaDate'] = substr($line,129,5);
725
-		    //$data['etaTime'] = substr($line,135,5);
726
-		    $data['format_source'] = 'shipplotter';
727
-    		    $data['id_source'] = $id_source;
728
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
729
-		    //print_r($data);
730
-		    //echo 'Add...'."\n";
731
-		    $MI->add($data);
732
-		    unset($data);
707
+			$data = array();
708
+			//echo $line."\n";
709
+			$data['mmsi'] = (int)substr($line,0,9);
710
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
711
+			$data['status_id'] = substr($line,21,2);
712
+			$data['type_id'] = substr($line,24,3);
713
+			$data['latitude'] = substr($line,29,9);
714
+			$data['longitude'] = substr($line,41,9);
715
+			$data['speed'] = round(substr($line,51,5));
716
+			//$data['course'] = substr($line,57,5);
717
+			$data['heading'] = round(substr($line,63,3));
718
+			//$data['draft'] = substr($line,67,4);
719
+			//$data['length'] = substr($line,72,3);
720
+			//$data['beam'] = substr($line,76,2);
721
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
722
+			//$data['callsign'] = trim(substr($line,100,7);
723
+			$data['arrival_code'] = substr($line,108,20);
724
+			//$data['etaDate'] = substr($line,129,5);
725
+			//$data['etaTime'] = substr($line,135,5);
726
+			$data['format_source'] = 'shipplotter';
727
+				$data['id_source'] = $id_source;
728
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
729
+			//print_r($data);
730
+			//echo 'Add...'."\n";
731
+			$MI->add($data);
732
+			unset($data);
733 733
 		}
734
-    	    }
735
-    	    $last_exec[$id]['last'] = time();
734
+			}
735
+			$last_exec[$id]['last'] = time();
736 736
 	} elseif ($value['format'] === 'sailaway' && 
737
-	    (
737
+		(
738 738
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
739 739
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
740
-	    )
740
+		)
741 741
 	) {
742
-	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
742
+		if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
743 743
 		$authsailaway = $Common->getData('https://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);
744 744
 		//echo $authsailaway;
745 745
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
746 746
 		if (isset($setcookie[1][0])) {
747
-		    $sailaway_authcookie = $setcookie[1][0];
747
+			$sailaway_authcookie = $setcookie[1][0];
748
+		}
748 749
 		}
749
-	    }
750 750
 
751
-	    if ($globalDebug) echo '! Download... ';
752
-	    for ($i =0; $i <= 1; $i++) {
751
+		if ($globalDebug) echo '! Download... ';
752
+		for ($i =0; $i <= 1; $i++) {
753 753
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
754 754
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
755
-	    if ($globalDebug) echo 'done'."\n";
756
-	    if ($buffer != '') {
755
+		if ($globalDebug) echo 'done'."\n";
756
+		if ($buffer != '') {
757 757
 		$all_data = json_decode($buffer,true);
758 758
 		if (isset($all_data['missions'])) {
759 759
 			foreach ($all_data['missions'] as $mission) {
@@ -772,19 +772,19 @@  discard block
 block discarded – undo
772 772
 					//print_r($race_data);
773 773
 					unset($racebuffer);
774 774
 					if (isset($race_data['mission'])) {
775
-					    $datar = array();
776
-					    $datar['id'] = $mission['misnr'];
777
-					    $datar['desc'] = $race_data['mission']['misdescr'];
778
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
779
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
780
-					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
781
-					    $markers = array();
782
-					    foreach ($race_data['mission']['course'] as $course) {
775
+						$datar = array();
776
+						$datar['id'] = $mission['misnr'];
777
+						$datar['desc'] = $race_data['mission']['misdescr'];
778
+						$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
779
+						$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
780
+						$datar['startdate'] = $race_data['mission']['misstartdatetime'];
781
+						$markers = array();
782
+						foreach ($race_data['mission']['course'] as $course) {
783 783
 						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
784
-					    }
785
-					    $datar['markers'] = json_encode($markers);
786
-					    //print_r($datar);
787
-					    $MI->race_add($datar);
784
+						}
785
+						$datar['markers'] = json_encode($markers);
786
+						//print_r($datar);
787
+						$MI->race_add($datar);
788 788
 					}
789 789
 				}
790 790
 				if ($bufferm != '') {
@@ -847,34 +847,34 @@  discard block
 block discarded – undo
847 847
 				}
848 848
 			}
849 849
 		}
850
-	    }
851
-	    }
852
-    	    $last_exec[$id]['last'] = time();
850
+		}
851
+		}
852
+			$last_exec[$id]['last'] = time();
853 853
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
854 854
 	} elseif (
855
-	    (
855
+		(
856 856
 		$value['format'] === 'whazzup' && 
857 857
 		(
858
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
859
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
858
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
859
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
860 860
 		)
861
-	    ) || (
861
+		) || (
862 862
 		$value['format'] === 'vatsimtxt' && 
863 863
 		(
864
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
865
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
864
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
865
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
866
+		)
866 867
 		)
867
-	    )
868 868
 	) {
869
-	    //$buffer = $Common->getData($hosts[$id]);
870
-	    $buffer = $Common->getData($value['host']);
871
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
872
-	    $buffer = explode('\n',$buffer);
873
-	    $reset = 0;
874
-	    foreach ($buffer as $line) {
875
-    		if ($line != '') {
876
-    		    $line = explode(':', $line);
877
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
869
+		//$buffer = $Common->getData($hosts[$id]);
870
+		$buffer = $Common->getData($value['host']);
871
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
872
+		$buffer = explode('\n',$buffer);
873
+		$reset = 0;
874
+		foreach ($buffer as $line) {
875
+			if ($line != '') {
876
+				$line = explode(':', $line);
877
+				if (count($line) > 30 && $line[0] != 'callsign') {
878 878
 			$data = array();
879 879
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
880 880
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -887,37 +887,37 @@  discard block
 block discarded – undo
887 887
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
888 888
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
889 889
 			$data['latitude'] = $line[5]; // lat
890
-	        	$data['longitude'] = $line[6]; // long
891
-	        	$data['verticalrate'] = ''; // vertical rate
892
-	        	$data['squawk'] = ''; // squawk
893
-	        	$data['emergency'] = ''; // emergency
894
-	        	$data['waypoints'] = $line[30];
890
+				$data['longitude'] = $line[6]; // long
891
+				$data['verticalrate'] = ''; // vertical rate
892
+				$data['squawk'] = ''; // squawk
893
+				$data['emergency'] = ''; // emergency
894
+				$data['waypoints'] = $line[30];
895 895
 			$data['datetime'] = date('Y-m-d H:i:s');
896 896
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
897 897
 			//if (isset($line[37])) $data['last_update'] = $line[37];
898
-		        $data['departure_airport_icao'] = $line[11];
899
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
900
-		        $data['arrival_airport_icao'] = $line[13];
898
+				$data['departure_airport_icao'] = $line[11];
899
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
900
+				$data['arrival_airport_icao'] = $line[13];
901 901
 			$data['frequency'] = $line[4];
902 902
 			$data['type'] = $line[18];
903 903
 			$data['range'] = $line[19];
904 904
 			if (isset($line[35])) $data['info'] = $line[35];
905
-    			$data['id_source'] = $id_source;
906
-	    		//$data['arrival_airport_time'] = ;
907
-	    		if ($line[9] != '') {
908
-	    		    $aircraft_data = explode('/',$line[9]);
909
-	    		    if (isset($aircraft_data[1])) {
910
-	    			$data['aircraft_icao'] = $aircraft_data[1];
911
-	    		    }
912
-        		}
913
-	    		/*
905
+				$data['id_source'] = $id_source;
906
+				//$data['arrival_airport_time'] = ;
907
+				if ($line[9] != '') {
908
+					$aircraft_data = explode('/',$line[9]);
909
+					if (isset($aircraft_data[1])) {
910
+					$data['aircraft_icao'] = $aircraft_data[1];
911
+					}
912
+				}
913
+				/*
914 914
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
915 915
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
916 916
 	    		*/
917
-	    		$data['format_source'] = $value['format'];
917
+				$data['format_source'] = $value['format'];
918 918
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919 919
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
-    			if ($line[3] === 'PILOT') $SI->add($data);
920
+				if ($line[3] === 'PILOT') $SI->add($data);
921 921
 			elseif ($line[3] === 'ATC') {
922 922
 				//print_r($data);
923 923
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -938,21 +938,21 @@  discard block
 block discarded – undo
938 938
 					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']);
939 939
 				}
940 940
 			}
941
-    			unset($data);
942
-    		    }
943
-    		}
944
-    	    }
945
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
946
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
947
-    	    $last_exec[$id]['last'] = time();
948
-    	} elseif ($value['format'] === 'airwhere' && 
949
-    	    (
950
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
951
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
952
-    	    )
953
-    	) {
954
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
955
-	    if ($buffer != '') {
941
+				unset($data);
942
+				}
943
+			}
944
+			}
945
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
946
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
947
+			$last_exec[$id]['last'] = time();
948
+		} elseif ($value['format'] === 'airwhere' && 
949
+			(
950
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
951
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
952
+			)
953
+		) {
954
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
955
+		if ($buffer != '') {
956 956
 		$all_data = simplexml_load_string($buffer);
957 957
 		foreach($all_data->children() as $childdata) {
958 958
 			$data = array();
@@ -974,10 +974,10 @@  discard block
 block discarded – undo
974 974
 			$SI->add($data);
975 975
 			unset($data);
976 976
 		}
977
-	    }
978
-	    $Source->deleteOldLocationByType('gs');
979
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
980
-	    if ($buffer != '') {
977
+		}
978
+		$Source->deleteOldLocationByType('gs');
979
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
980
+		if ($buffer != '') {
981 981
 		$all_data = simplexml_load_string($buffer);
982 982
 		foreach($all_data->children() as $childdata) {
983 983
 			$data = array();
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 			}
996 996
 			unset($data);
997 997
 		}
998
-	    }
999
-	    $last_exec[$id]['last'] = time();
998
+		}
999
+		$last_exec[$id]['last'] = time();
1000 1000
 	/*
1001 1001
 	} if ($value['format'] === 'aircraftlistjson') {
1002 1002
 	    print_r($globalSources);
@@ -1004,17 +1004,17 @@  discard block
 block discarded – undo
1004 1004
 	    echo $globalMinFetch;
1005 1005
 	*/
1006 1006
 	} elseif ($value['format'] === 'aircraftlistjson' && 
1007
-	    (
1007
+		(
1008 1008
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1009 1009
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1010
-	    )
1010
+		)
1011 1011
 	) {
1012
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1013
-	    if ($buffer != '') {
1014
-	        $all_data = json_decode($buffer,true);
1012
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
1013
+		if ($buffer != '') {
1014
+			$all_data = json_decode($buffer,true);
1015 1015
 		if (isset($all_data['acList'])) {
1016
-		    $reset = 0;
1017
-		    foreach ($all_data['acList'] as $line) {
1016
+			$reset = 0;
1017
+			foreach ($all_data['acList'] as $line) {
1018 1018
 			$data = array();
1019 1019
 			$data['hex'] = $line['Icao']; // hex
1020 1020
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1037,10 +1037,10 @@  discard block
 block discarded – undo
1037 1037
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1038 1038
 			if (isset($data['latitude'])) $SI->add($data);
1039 1039
 			unset($data);
1040
-		    }
1040
+			}
1041 1041
 		} elseif (is_array($all_data)) {
1042
-		    $reset = 0;
1043
-		    foreach ($all_data as $line) {
1042
+			$reset = 0;
1043
+			foreach ($all_data as $line) {
1044 1044
 			$data = array();
1045 1045
 			$data['hex'] = $line['hex']; // hex
1046 1046
 			$data['ident'] = $line['flight']; // ident
@@ -1060,291 +1060,291 @@  discard block
 block discarded – undo
1060 1060
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1061 1061
 			$SI->add($data);
1062 1062
 			unset($data);
1063
-		    }
1063
+			}
1064 1064
 		}
1065
-	    } elseif ($globalDebug) echo 'No data'."\n";
1066
-    	    //$last_exec['aircraftlistjson'] = time();
1067
-    	    $last_exec[$id]['last'] = time();
1068
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1069
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1070
-    	    (
1071
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1072
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1073
-    	    )
1074
-    	) {
1075
-	    $buffer = $Common->getData($value['host']);
1076
-	    $all_data = json_decode($buffer,true);
1077
-	    if (isset($all_data['planes'])) {
1065
+		} elseif ($globalDebug) echo 'No data'."\n";
1066
+			//$last_exec['aircraftlistjson'] = time();
1067
+			$last_exec[$id]['last'] = time();
1068
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1069
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1070
+			(
1071
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1072
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1073
+			)
1074
+		) {
1075
+		$buffer = $Common->getData($value['host']);
1076
+		$all_data = json_decode($buffer,true);
1077
+		if (isset($all_data['planes'])) {
1078 1078
 		$reset = 0;
1079 1079
 		foreach ($all_data['planes'] as $key => $line) {
1080
-		    $data = array();
1081
-		    $data['hex'] = $key; // hex
1082
-		    $data['ident'] = $line[3]; // ident
1083
-		    $data['altitude'] = $line[6]; // altitude
1084
-		    $data['speed'] = $line[8]; // speed
1085
-		    $data['heading'] = $line[7]; // heading
1086
-		    $data['latitude'] = $line[4]; // lat
1087
-		    $data['longitude'] = $line[5]; // long
1088
-		    //$data['verticalrate'] = $line[]; // verticale rate
1089
-		    $data['squawk'] = $line[10]; // squawk
1090
-		    $data['emergency'] = ''; // emergency
1091
-		    $data['registration'] = $line[2];
1092
-		    $data['aircraft_icao'] = $line[0];
1093
-		    $deparr = explode('-',$line[1]);
1094
-		    if (count($deparr) === 2) {
1080
+			$data = array();
1081
+			$data['hex'] = $key; // hex
1082
+			$data['ident'] = $line[3]; // ident
1083
+			$data['altitude'] = $line[6]; // altitude
1084
+			$data['speed'] = $line[8]; // speed
1085
+			$data['heading'] = $line[7]; // heading
1086
+			$data['latitude'] = $line[4]; // lat
1087
+			$data['longitude'] = $line[5]; // long
1088
+			//$data['verticalrate'] = $line[]; // verticale rate
1089
+			$data['squawk'] = $line[10]; // squawk
1090
+			$data['emergency'] = ''; // emergency
1091
+			$data['registration'] = $line[2];
1092
+			$data['aircraft_icao'] = $line[0];
1093
+			$deparr = explode('-',$line[1]);
1094
+			if (count($deparr) === 2) {
1095 1095
 			$data['departure_airport_icao'] = $deparr[0];
1096 1096
 			$data['arrival_airport_icao'] = $deparr[1];
1097
-		    }
1098
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1099
-	    	    $data['format_source'] = 'planeupdatefaa';
1100
-    		    $data['id_source'] = $id_source;
1101
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1102
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1103
-		    $SI->add($data);
1104
-		    unset($data);
1097
+			}
1098
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1099
+				$data['format_source'] = 'planeupdatefaa';
1100
+				$data['id_source'] = $id_source;
1101
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1102
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1103
+			$SI->add($data);
1104
+			unset($data);
1105
+		}
1105 1106
 		}
1106
-	    }
1107
-	    //$last_exec['planeupdatefaa'] = time();
1108
-	    $last_exec[$id]['last'] = time();
1107
+		//$last_exec['planeupdatefaa'] = time();
1108
+		$last_exec[$id]['last'] = time();
1109 1109
 	} elseif ($value['format'] === 'opensky' && 
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']);
1116
-	    $all_data = json_decode($buffer,true);
1117
-	    if (isset($all_data['states'])) {
1115
+		$buffer = $Common->getData($value['host']);
1116
+		$all_data = json_decode($buffer,true);
1117
+		if (isset($all_data['states'])) {
1118 1118
 		$reset = 0;
1119 1119
 		foreach ($all_data['states'] as $key => $line) {
1120
-		    $data = array();
1121
-		    $data['hex'] = $line[0]; // hex
1122
-		    $data['ident'] = trim($line[1]); // ident
1123
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1124
-		    $data['speed'] = round($line[9]*1.94384); // speed
1125
-		    $data['heading'] = round($line[10]); // heading
1126
-		    $data['latitude'] = $line[6]; // lat
1127
-		    $data['longitude'] = $line[5]; // long
1128
-		    $data['verticalrate'] = $line[11]; // verticale rate
1129
-		    //$data['squawk'] = $line[10]; // squawk
1130
-		    //$data['emergency'] = ''; // emergency
1131
-		    //$data['registration'] = $line[2];
1132
-		    //$data['aircraft_icao'] = $line[0];
1133
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1134
-		    $data['format_source'] = 'opensky';
1135
-		    $data['id_source'] = $id_source;
1136
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1137
-		    $SI->add($data);
1138
-		    unset($data);
1120
+			$data = array();
1121
+			$data['hex'] = $line[0]; // hex
1122
+			$data['ident'] = trim($line[1]); // ident
1123
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1124
+			$data['speed'] = round($line[9]*1.94384); // speed
1125
+			$data['heading'] = round($line[10]); // heading
1126
+			$data['latitude'] = $line[6]; // lat
1127
+			$data['longitude'] = $line[5]; // long
1128
+			$data['verticalrate'] = $line[11]; // verticale rate
1129
+			//$data['squawk'] = $line[10]; // squawk
1130
+			//$data['emergency'] = ''; // emergency
1131
+			//$data['registration'] = $line[2];
1132
+			//$data['aircraft_icao'] = $line[0];
1133
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1134
+			$data['format_source'] = 'opensky';
1135
+			$data['id_source'] = $id_source;
1136
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1137
+			$SI->add($data);
1138
+			unset($data);
1139 1139
 		}
1140
-	    }
1141
-	    //$last_exec['planeupdatefaa'] = time();
1142
-	    $last_exec[$id]['last'] = time();
1140
+		}
1141
+		//$last_exec['planeupdatefaa'] = time();
1142
+		$last_exec[$id]['last'] = time();
1143 1143
 	} elseif ($value['format'] === 'aircraftjson' && 
1144
-	    (
1144
+		(
1145 1145
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1146 1146
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1147
-	    )
1147
+		)
1148 1148
 	) {
1149
-	    $buffer = $Common->getData($value['host']);
1150
-	    $all_data = json_decode($buffer,true);
1151
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1149
+		$buffer = $Common->getData($value['host']);
1150
+		$all_data = json_decode($buffer,true);
1151
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1152 1152
 		$reset = 0;
1153 1153
 		foreach ($all_data['aircraft'] as $key => $line) {
1154
-		    $data = array();
1155
-		    // add support for ground vehicule with ~ in front of hex
1156
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1157
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1158
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1159
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1160
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1161
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1162
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1163
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1164
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1165
-		    //$data['emergency'] = ''; // emergency
1166
-		    //$data['registration'] = $line[2];
1167
-		    //$data['aircraft_icao'] = $line[0];
1168
-		    $data['datetime'] = date('Y-m-d H:i:s');
1169
-		    $data['format_source'] = 'aircraftjson';
1170
-		    $data['id_source'] = $id_source;
1171
-		    if (isset($value['name']) && $value['name'] != '') {
1172
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1173
-			    else $data['source_name'] = $value['name'];
1174
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1175
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176
-		    $SI->add($data);
1177
-		    unset($data);
1154
+			$data = array();
1155
+			// add support for ground vehicule with ~ in front of hex
1156
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1157
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1158
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1159
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1160
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1161
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1162
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1163
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1164
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1165
+			//$data['emergency'] = ''; // emergency
1166
+			//$data['registration'] = $line[2];
1167
+			//$data['aircraft_icao'] = $line[0];
1168
+			$data['datetime'] = date('Y-m-d H:i:s');
1169
+			$data['format_source'] = 'aircraftjson';
1170
+			$data['id_source'] = $id_source;
1171
+			if (isset($value['name']) && $value['name'] != '') {
1172
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1173
+				else $data['source_name'] = $value['name'];
1174
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1175
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176
+			$SI->add($data);
1177
+			unset($data);
1178
+		}
1178 1179
 		}
1179
-	    }
1180
-	    //$last_exec['planeupdatefaa'] = time();
1181
-	    $last_exec[$id]['last'] = time();
1180
+		//$last_exec['planeupdatefaa'] = time();
1181
+		$last_exec[$id]['last'] = time();
1182 1182
 	} elseif ($value['format'] === 'planefinderclient' && 
1183
-	    (
1183
+		(
1184 1184
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1185 1185
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1186
-	    )
1186
+		)
1187 1187
 	) {
1188
-	    $buffer = $Common->getData($value['host']);
1189
-	    $all_data = json_decode($buffer,true);
1190
-	    if (isset($all_data['aircraft'])) {
1188
+		$buffer = $Common->getData($value['host']);
1189
+		$all_data = json_decode($buffer,true);
1190
+		if (isset($all_data['aircraft'])) {
1191 1191
 		$reset = 0;
1192 1192
 		foreach ($all_data['aircraft'] as $key => $line) {
1193
-		    $data = array();
1194
-		    $data['hex'] = $key; // hex
1195
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1196
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1197
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1198
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1199
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1200
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1201
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1202
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1203
-		    //$data['emergency'] = ''; // emergency
1204
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1205
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1206
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1207
-		    $data['format_source'] = 'planefinderclient';
1208
-		    $data['id_source'] = $id_source;
1209
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1210
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1211
-		    $SI->add($data);
1212
-		    unset($data);
1193
+			$data = array();
1194
+			$data['hex'] = $key; // hex
1195
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1196
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1197
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1198
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1199
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1200
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1201
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1202
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1203
+			//$data['emergency'] = ''; // emergency
1204
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1205
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1206
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1207
+			$data['format_source'] = 'planefinderclient';
1208
+			$data['id_source'] = $id_source;
1209
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1210
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1211
+			$SI->add($data);
1212
+			unset($data);
1213 1213
 		}
1214
-	    }
1215
-	    $last_exec[$id]['last'] = time();
1214
+		}
1215
+		$last_exec[$id]['last'] = time();
1216 1216
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1217 1217
 	} elseif ($value['format'] === 'fr24json' && 
1218
-	    (
1218
+		(
1219 1219
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1220 1220
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1221
-	    )
1221
+		)
1222 1222
 	) {
1223
-	    //$buffer = $Common->getData($hosts[$id]);
1224
-	    $buffer = $Common->getData($value['host']);
1225
-	    $all_data = json_decode($buffer,true);
1226
-	    if (!empty($all_data)) $reset = 0;
1227
-	    foreach ($all_data as $key => $line) {
1223
+		//$buffer = $Common->getData($hosts[$id]);
1224
+		$buffer = $Common->getData($value['host']);
1225
+		$all_data = json_decode($buffer,true);
1226
+		if (!empty($all_data)) $reset = 0;
1227
+		foreach ($all_data as $key => $line) {
1228 1228
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1229
-		    $data = array();
1230
-		    $data['hex'] = $line[0];
1231
-		    $data['ident'] = $line[16]; //$line[13]
1232
-	    	    $data['altitude'] = $line[4]; // altitude
1233
-	    	    $data['speed'] = $line[5]; // speed
1234
-	    	    $data['heading'] = $line[3]; // heading
1235
-	    	    $data['latitude'] = $line[1]; // lat
1236
-	    	    $data['longitude'] = $line[2]; // long
1237
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1238
-	    	    $data['squawk'] = $line[6]; // squawk
1239
-	    	    $data['aircraft_icao'] = $line[8];
1240
-	    	    $data['registration'] = $line[9];
1241
-		    $data['departure_airport_iata'] = $line[11];
1242
-		    $data['arrival_airport_iata'] = $line[12];
1243
-	    	    $data['emergency'] = ''; // emergency
1244
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1245
-	    	    $data['format_source'] = 'fr24json';
1246
-    		    $data['id_source'] = $id_source;
1247
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1248
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1249
-		    $SI->add($data);
1250
-		    unset($data);
1229
+			$data = array();
1230
+			$data['hex'] = $line[0];
1231
+			$data['ident'] = $line[16]; //$line[13]
1232
+				$data['altitude'] = $line[4]; // altitude
1233
+				$data['speed'] = $line[5]; // speed
1234
+				$data['heading'] = $line[3]; // heading
1235
+				$data['latitude'] = $line[1]; // lat
1236
+				$data['longitude'] = $line[2]; // long
1237
+				$data['verticalrate'] = $line[15]; // verticale rate
1238
+				$data['squawk'] = $line[6]; // squawk
1239
+				$data['aircraft_icao'] = $line[8];
1240
+				$data['registration'] = $line[9];
1241
+			$data['departure_airport_iata'] = $line[11];
1242
+			$data['arrival_airport_iata'] = $line[12];
1243
+				$data['emergency'] = ''; // emergency
1244
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1245
+				$data['format_source'] = 'fr24json';
1246
+				$data['id_source'] = $id_source;
1247
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1248
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1249
+			$SI->add($data);
1250
+			unset($data);
1251
+		}
1251 1252
 		}
1252
-	    }
1253
-	    //$last_exec['fr24json'] = time();
1254
-	    $last_exec[$id]['last'] = time();
1253
+		//$last_exec['fr24json'] = time();
1254
+		$last_exec[$id]['last'] = time();
1255 1255
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1256 1256
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1257
-	    (
1257
+		(
1258 1258
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1259 1259
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1260
-	    )
1260
+		)
1261 1261
 	) {
1262
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1263
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1264
-	    //echo $buffer;
1265
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1266
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1267
-	    $all_data = json_decode($buffer,true);
1268
-	    if (json_last_error() != JSON_ERROR_NONE) {
1262
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1263
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1264
+		//echo $buffer;
1265
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1266
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1267
+		$all_data = json_decode($buffer,true);
1268
+		if (json_last_error() != JSON_ERROR_NONE) {
1269 1269
 		die(json_last_error_msg());
1270
-	    }
1271
-	    if (isset($all_data['mrkrs'])) {
1270
+		}
1271
+		if (isset($all_data['mrkrs'])) {
1272 1272
 		$reset = 0;
1273 1273
 		foreach ($all_data['mrkrs'] as $key => $line) {
1274
-		    if (isset($line['inf'])) {
1274
+			if (isset($line['inf'])) {
1275 1275
 			$data = array();
1276 1276
 			$data['hex'] = $line['inf']['ia'];
1277 1277
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1278
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1279
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1280
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1281
-	    		$data['latitude'] = $line['pt'][0]; // lat
1282
-	    		$data['longitude'] = $line['pt'][1]; // long
1283
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1284
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1285
-	    		//$data['aircraft_icao'] = $line[8];
1286
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1278
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1279
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1280
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1281
+				$data['latitude'] = $line['pt'][0]; // lat
1282
+				$data['longitude'] = $line['pt'][1]; // long
1283
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1284
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1285
+				//$data['aircraft_icao'] = $line[8];
1286
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1287 1287
 			//$data['departure_airport_iata'] = $line[11];
1288 1288
 			//$data['arrival_airport_iata'] = $line[12];
1289
-	    		//$data['emergency'] = ''; // emergency
1289
+				//$data['emergency'] = ''; // emergency
1290 1290
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1291
-	    		$data['format_source'] = 'radarvirtueljson';
1292
-    			$data['id_source'] = $id_source;
1291
+				$data['format_source'] = 'radarvirtueljson';
1292
+				$data['id_source'] = $id_source;
1293 1293
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1294 1294
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1295 1295
 			$SI->add($data);
1296 1296
 			unset($data);
1297
-		    }
1297
+			}
1298 1298
 		}
1299
-	    }
1300
-	    //$last_exec['radarvirtueljson'] = time();
1301
-	    $last_exec[$id]['last'] = time();
1299
+		}
1300
+		//$last_exec['radarvirtueljson'] = time();
1301
+		$last_exec[$id]['last'] = time();
1302 1302
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1303 1303
 	} elseif ($value['format'] === 'pirepsjson' && 
1304
-	    (
1304
+		(
1305 1305
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1306 1306
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1307
-	    )
1307
+		)
1308 1308
 	) {
1309
-	    //$buffer = $Common->getData($hosts[$id]);
1310
-	    $buffer = $Common->getData($value['host'].'?'.time());
1311
-	    $all_data = json_decode(utf8_encode($buffer),true);
1309
+		//$buffer = $Common->getData($hosts[$id]);
1310
+		$buffer = $Common->getData($value['host'].'?'.time());
1311
+		$all_data = json_decode(utf8_encode($buffer),true);
1312 1312
 	    
1313
-	    if (isset($all_data['pireps'])) {
1313
+		if (isset($all_data['pireps'])) {
1314 1314
 		$reset = 0;
1315
-	        foreach ($all_data['pireps'] as $line) {
1316
-		    $data = array();
1317
-		    $data['id'] = $line['id'];
1318
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1319
-		    $data['ident'] = $line['callsign']; // ident
1320
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1321
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1322
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1323
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1324
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1325
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1326
-		    $data['latitude'] = $line['lat']; // lat
1327
-		    $data['longitude'] = $line['lon']; // long
1328
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1329
-		    //$data['squawk'] = $line['squawk']; // squawk
1330
-		    //$data['emergency'] = ''; // emergency
1331
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1332
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1333
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1334
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1335
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1336
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1337
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1338
-		    else $data['info'] = '';
1339
-		    $data['format_source'] = 'pireps';
1340
-    		    $data['id_source'] = $id_source;
1341
-		    $data['datetime'] = date('Y-m-d H:i:s');
1342
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1343
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1344
-		    if ($line['icon'] === 'plane') {
1315
+			foreach ($all_data['pireps'] as $line) {
1316
+			$data = array();
1317
+			$data['id'] = $line['id'];
1318
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1319
+			$data['ident'] = $line['callsign']; // ident
1320
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1321
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1322
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1323
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1324
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1325
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1326
+			$data['latitude'] = $line['lat']; // lat
1327
+			$data['longitude'] = $line['lon']; // long
1328
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1329
+			//$data['squawk'] = $line['squawk']; // squawk
1330
+			//$data['emergency'] = ''; // emergency
1331
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1332
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1333
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1334
+			//$data['arrival_airport_time'] = $line['arrtime'];
1335
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1336
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1337
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1338
+			else $data['info'] = '';
1339
+			$data['format_source'] = 'pireps';
1340
+				$data['id_source'] = $id_source;
1341
+			$data['datetime'] = date('Y-m-d H:i:s');
1342
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1343
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1344
+			if ($line['icon'] === 'plane') {
1345 1345
 			$SI->add($data);
1346
-		    //    print_r($data);
1347
-    		    } elseif ($line['icon'] === 'ct') {
1346
+			//    print_r($data);
1347
+				} elseif ($line['icon'] === 'ct') {
1348 1348
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1349 1349
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1350 1350
 			$typec = substr($data['ident'],-3);
@@ -1359,209 +1359,209 @@  discard block
 block discarded – undo
1359 1359
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1360 1360
 			else $data['type'] = 'Observer';
1361 1361
 			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']);
1362
-		    }
1363
-		    unset($data);
1362
+			}
1363
+			unset($data);
1364 1364
 		}
1365
-	    }
1366
-	    //$last_exec['pirepsjson'] = time();
1367
-	    $last_exec[$id]['last'] = time();
1365
+		}
1366
+		//$last_exec['pirepsjson'] = time();
1367
+		$last_exec[$id]['last'] = time();
1368 1368
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1369 1369
 	} elseif ($value['format'] === 'phpvmacars' && 
1370
-	    (
1370
+		(
1371 1371
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1372 1372
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1373
-	    )
1373
+		)
1374 1374
 	) {
1375
-	    //$buffer = $Common->getData($hosts[$id]);
1376
-	    if ($globalDebug) echo 'Get Data...'."\n";
1377
-	    $buffer = $Common->getData($value['host']);
1378
-	    $all_data = json_decode($buffer,true);
1379
-	    if ($buffer != '' && is_array($all_data)) {
1375
+		//$buffer = $Common->getData($hosts[$id]);
1376
+		if ($globalDebug) echo 'Get Data...'."\n";
1377
+		$buffer = $Common->getData($value['host']);
1378
+		$all_data = json_decode($buffer,true);
1379
+		if ($buffer != '' && is_array($all_data)) {
1380 1380
 		$reset = 0;
1381 1381
 		foreach ($all_data as $line) {
1382
-	    	    $data = array();
1383
-	    	    //$data['id'] = $line['id']; // id not usable
1384
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1385
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1386
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1387
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1388
-	    	    $data['ident'] = $line['flightnum']; // ident
1389
-	    	    $data['altitude'] = $line['alt']; // altitude
1390
-	    	    $data['speed'] = $line['gs']; // speed
1391
-	    	    $data['heading'] = $line['heading']; // heading
1392
-	    	    $data['latitude'] = $line['lat']; // lat
1393
-	    	    $data['longitude'] = $line['lng']; // long
1394
-	    	    $data['verticalrate'] = ''; // verticale rate
1395
-	    	    $data['squawk'] = ''; // squawk
1396
-	    	    $data['emergency'] = ''; // emergency
1397
-	    	    //$data['datetime'] = $line['lastupdate'];
1398
-	    	    //$data['last_update'] = $line['lastupdate'];
1399
-	    	    if (isset($value['timezone'])) {
1400
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1401
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1402
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1403
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1404
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1405
-	    	    $data['departure_airport_time'] = $line['deptime'];
1406
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1407
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1408
-    		    if (isset($line['registration'])) {
1409
-    			$data['registration'] = $line['registration'];
1410
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1411
-    		    } else $data['registration'] = $line['aircraft'];
1412
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1414
-		    if (isset($line['aircraftname'])) {
1382
+				$data = array();
1383
+				//$data['id'] = $line['id']; // id not usable
1384
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1385
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1386
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1387
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1388
+				$data['ident'] = $line['flightnum']; // ident
1389
+				$data['altitude'] = $line['alt']; // altitude
1390
+				$data['speed'] = $line['gs']; // speed
1391
+				$data['heading'] = $line['heading']; // heading
1392
+				$data['latitude'] = $line['lat']; // lat
1393
+				$data['longitude'] = $line['lng']; // long
1394
+				$data['verticalrate'] = ''; // verticale rate
1395
+				$data['squawk'] = ''; // squawk
1396
+				$data['emergency'] = ''; // emergency
1397
+				//$data['datetime'] = $line['lastupdate'];
1398
+				//$data['last_update'] = $line['lastupdate'];
1399
+				if (isset($value['timezone'])) {
1400
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1401
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1402
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1403
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1404
+				$data['departure_airport_icao'] = $line['depicao'];
1405
+				$data['departure_airport_time'] = $line['deptime'];
1406
+				$data['arrival_airport_icao'] = $line['arricao'];
1407
+				$data['arrival_airport_time'] = $line['arrtime'];
1408
+				if (isset($line['registration'])) {
1409
+				$data['registration'] = $line['registration'];
1410
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1411
+				} else $data['registration'] = $line['aircraft'];
1412
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1414
+			if (isset($line['aircraftname'])) {
1415 1415
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1416 1416
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1417
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1418
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1419
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1420
-	    		else {
1421
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1422
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1423
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1424
-	    		}
1425
-	    	    }
1426
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1427
-    		    $data['id_source'] = $id_source;
1428
-	    	    $data['format_source'] = 'phpvmacars';
1429
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1430
-		    $SI->add($data);
1431
-		    unset($data);
1417
+				$aircraft_data = explode('-',$line['aircraftname']);
1418
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1419
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1420
+				else {
1421
+					$aircraft_data = explode(' ',$line['aircraftname']);
1422
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1423
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1424
+				}
1425
+				}
1426
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1427
+				$data['id_source'] = $id_source;
1428
+				$data['format_source'] = 'phpvmacars';
1429
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1430
+			$SI->add($data);
1431
+			unset($data);
1432 1432
 		}
1433 1433
 		if ($globalDebug) echo 'No more data...'."\n";
1434 1434
 		unset($buffer);
1435 1435
 		unset($all_data);
1436
-	    }
1437
-	    //$last_exec['phpvmacars'] = time();
1438
-	    $last_exec[$id]['last'] = time();
1436
+		}
1437
+		//$last_exec['phpvmacars'] = time();
1438
+		$last_exec[$id]['last'] = time();
1439 1439
 	} elseif ($value['format'] === 'vaos' && 
1440
-	    (
1440
+		(
1441 1441
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1442 1442
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1443
-	    )
1443
+		)
1444 1444
 	) {
1445
-	    //$buffer = $Common->getData($hosts[$id]);
1446
-	    if ($globalDebug) echo 'Get Data...'."\n";
1447
-	    $buffer = $Common->getData($value['host']);
1448
-	    $all_data = json_decode($buffer,true);
1449
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1445
+		//$buffer = $Common->getData($hosts[$id]);
1446
+		if ($globalDebug) echo 'Get Data...'."\n";
1447
+		$buffer = $Common->getData($value['host']);
1448
+		$all_data = json_decode($buffer,true);
1449
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1450 1450
 		$reset = 0;
1451 1451
 		foreach ($all_data['ACARSData'] as $line) {
1452
-		    //print_r($line);
1453
-	    	    $data = array();
1454
-	    	    //$data['id'] = $line['id']; // id not usable
1455
-	    	    $data['id'] = $line['id'];
1456
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1458
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1459
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1460
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1461
-	    	    $data['altitude'] = $line['altitude']; // altitude
1462
-	    	    $data['speed'] = $line['groundspeed']; // speed
1463
-	    	    $data['heading'] = $line['heading']; // heading
1464
-	    	    $data['latitude'] = $line['lat']; // lat
1465
-	    	    $data['longitude'] = $line['lon']; // long
1466
-	    	    //$data['verticalrate'] = ''; // verticale rate
1467
-	    	    //$data['squawk'] = ''; // squawk
1468
-	    	    //$data['emergency'] = ''; // emergency
1469
-	    	    if (isset($value['timezone'])) {
1470
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1471
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1472
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1473
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1452
+			//print_r($line);
1453
+				$data = array();
1454
+				//$data['id'] = $line['id']; // id not usable
1455
+				$data['id'] = $line['id'];
1456
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1458
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1459
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1460
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1461
+				$data['altitude'] = $line['altitude']; // altitude
1462
+				$data['speed'] = $line['groundspeed']; // speed
1463
+				$data['heading'] = $line['heading']; // heading
1464
+				$data['latitude'] = $line['lat']; // lat
1465
+				$data['longitude'] = $line['lon']; // long
1466
+				//$data['verticalrate'] = ''; // verticale rate
1467
+				//$data['squawk'] = ''; // squawk
1468
+				//$data['emergency'] = ''; // emergency
1469
+				if (isset($value['timezone'])) {
1470
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1471
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1472
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1473
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1474 1474
 	    	    
1475
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1476
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1477
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1478
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1479
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1475
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1476
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1477
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1478
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1479
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1480 1480
 
1481
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1483
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1481
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1483
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1484 1484
 
1485
-    		    $data['id_source'] = $id_source;
1486
-	    	    $data['format_source'] = 'vaos';
1487
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1488
-		    $SI->add($data);
1489
-		    unset($data);
1485
+				$data['id_source'] = $id_source;
1486
+				$data['format_source'] = 'vaos';
1487
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1488
+			$SI->add($data);
1489
+			unset($data);
1490 1490
 		}
1491 1491
 		if ($globalDebug) echo 'No more data...'."\n";
1492 1492
 		unset($buffer);
1493 1493
 		unset($all_data);
1494
-	    }
1495
-	    //$last_exec['phpvmacars'] = time();
1496
-	    $last_exec[$id]['last'] = time();
1494
+		}
1495
+		//$last_exec['phpvmacars'] = time();
1496
+		$last_exec[$id]['last'] = time();
1497 1497
 	} elseif ($value['format'] === 'vam' && 
1498
-	    (
1498
+		(
1499 1499
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1500 1500
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1501
-	    )
1501
+		)
1502 1502
 	) {
1503
-	    //$buffer = $Common->getData($hosts[$id]);
1504
-	    if ($globalDebug) echo 'Get Data...'."\n";
1505
-	    $buffer = $Common->getData($value['host']);
1506
-	    $all_data = json_decode($buffer,true);
1507
-	    if ($buffer != '' && is_array($all_data)) {
1503
+		//$buffer = $Common->getData($hosts[$id]);
1504
+		if ($globalDebug) echo 'Get Data...'."\n";
1505
+		$buffer = $Common->getData($value['host']);
1506
+		$all_data = json_decode($buffer,true);
1507
+		if ($buffer != '' && is_array($all_data)) {
1508 1508
 		$reset = 0;
1509 1509
 		foreach ($all_data as $line) {
1510
-	    	    $data = array();
1511
-	    	    //$data['id'] = $line['id']; // id not usable
1512
-	    	    $data['id'] = trim($line['flight_id']);
1513
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1514
-	    	    $data['pilot_name'] = $line['pilot_name'];
1515
-	    	    $data['pilot_id'] = $line['pilot_id'];
1516
-	    	    $data['ident'] = trim($line['callsign']); // ident
1517
-	    	    $data['altitude'] = $line['altitude']; // altitude
1518
-	    	    $data['speed'] = $line['gs']; // speed
1519
-	    	    $data['heading'] = $line['heading']; // heading
1520
-	    	    $data['latitude'] = $line['latitude']; // lat
1521
-	    	    $data['longitude'] = $line['longitude']; // long
1522
-	    	    $data['verticalrate'] = ''; // verticale rate
1523
-	    	    $data['squawk'] = ''; // squawk
1524
-	    	    $data['emergency'] = ''; // emergency
1525
-	    	    //$data['datetime'] = $line['lastupdate'];
1526
-	    	    $data['last_update'] = $line['last_update'];
1527
-		    $data['datetime'] = date('Y-m-d H:i:s');
1528
-	    	    $data['departure_airport_icao'] = $line['departure'];
1529
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1530
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1531
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1532
-    		    //$data['registration'] = $line['aircraft'];
1533
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1534
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1535
-    		    $data['id_source'] = $id_source;
1536
-	    	    $data['format_source'] = 'vam';
1537
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1539
-		    $SI->add($data);
1540
-		    unset($data);
1510
+				$data = array();
1511
+				//$data['id'] = $line['id']; // id not usable
1512
+				$data['id'] = trim($line['flight_id']);
1513
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1514
+				$data['pilot_name'] = $line['pilot_name'];
1515
+				$data['pilot_id'] = $line['pilot_id'];
1516
+				$data['ident'] = trim($line['callsign']); // ident
1517
+				$data['altitude'] = $line['altitude']; // altitude
1518
+				$data['speed'] = $line['gs']; // speed
1519
+				$data['heading'] = $line['heading']; // heading
1520
+				$data['latitude'] = $line['latitude']; // lat
1521
+				$data['longitude'] = $line['longitude']; // long
1522
+				$data['verticalrate'] = ''; // verticale rate
1523
+				$data['squawk'] = ''; // squawk
1524
+				$data['emergency'] = ''; // emergency
1525
+				//$data['datetime'] = $line['lastupdate'];
1526
+				$data['last_update'] = $line['last_update'];
1527
+			$data['datetime'] = date('Y-m-d H:i:s');
1528
+				$data['departure_airport_icao'] = $line['departure'];
1529
+				//$data['departure_airport_time'] = $line['departure_time'];
1530
+				$data['arrival_airport_icao'] = $line['arrival'];
1531
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1532
+				//$data['registration'] = $line['aircraft'];
1533
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1534
+				$data['aircraft_icao'] = $line['plane_type'];
1535
+				$data['id_source'] = $id_source;
1536
+				$data['format_source'] = 'vam';
1537
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1539
+			$SI->add($data);
1540
+			unset($data);
1541 1541
 		}
1542 1542
 		if ($globalDebug) echo 'No more data...'."\n";
1543 1543
 		unset($buffer);
1544 1544
 		unset($all_data);
1545
-	    }
1546
-	    //$last_exec['phpvmacars'] = time();
1547
-	    $last_exec[$id]['last'] = time();
1545
+		}
1546
+		//$last_exec['phpvmacars'] = time();
1547
+		$last_exec[$id]['last'] = time();
1548 1548
 	} elseif ($value['format'] === 'blitzortung' && 
1549
-	    (
1549
+		(
1550 1550
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1551 1551
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1552
-	    )
1552
+		)
1553 1553
 	) {
1554
-	    //$buffer = $Common->getData($hosts[$id]);
1555
-	    if ($globalDebug) echo 'Get Data...'."\n";
1556
-	    $buffer = $Common->getData($value['host']);
1557
-	    $all_data = json_decode($buffer,true);
1558
-	    if ($buffer != '') {
1554
+		//$buffer = $Common->getData($hosts[$id]);
1555
+		if ($globalDebug) echo 'Get Data...'."\n";
1556
+		$buffer = $Common->getData($value['host']);
1557
+		$all_data = json_decode($buffer,true);
1558
+		if ($buffer != '') {
1559 1559
 		$Source->deleteLocationBySource('blitzortung');
1560 1560
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1561 1561
 		$buffer = explode('\n',$buffer);
1562 1562
 		foreach ($buffer as $buffer_line) {
1563
-		    $line = json_decode($buffer_line,true);
1564
-		    if (isset($line['time'])) {
1563
+			$line = json_decode($buffer_line,true);
1564
+			if (isset($line['time'])) {
1565 1565
 			$data = array();
1566 1566
 			$data['altitude'] = $line['alt']; // altitude
1567 1567
 			$data['latitude'] = $line['lat']; // lat
@@ -1573,94 +1573,94 @@  discard block
 block discarded – undo
1573 1573
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1574 1574
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1575 1575
 			unset($data);
1576
-		    }
1576
+			}
1577 1577
 		}
1578 1578
 		if ($globalDebug) echo 'No more data...'."\n";
1579 1579
 		unset($buffer);
1580
-	    }
1581
-	    $last_exec[$id]['last'] = time();
1580
+		}
1581
+		$last_exec[$id]['last'] = time();
1582 1582
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1583 1583
 	} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1584
-	    //$last_exec[$id]['last'] = time();
1585
-	    //$read = array( $sockets[$id] );
1586
-	    $read = $sockets;
1587
-	    $write = NULL;
1588
-	    $e = NULL;
1589
-	    $n = socket_select($read, $write, $e, $timeout);
1590
-	    if ($e != NULL) var_dump($e);
1591
-	    if ($n > 0) {
1584
+		//$last_exec[$id]['last'] = time();
1585
+		//$read = array( $sockets[$id] );
1586
+		$read = $sockets;
1587
+		$write = NULL;
1588
+		$e = NULL;
1589
+		$n = socket_select($read, $write, $e, $timeout);
1590
+		if ($e != NULL) var_dump($e);
1591
+		if ($n > 0) {
1592 1592
 		$reset = 0;
1593 1593
 		foreach ($read as $nb => $r) {
1594
-		    //$value = $formats[$nb];
1595
-		    $format = $globalSources[$nb]['format'];
1596
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1594
+			//$value = $formats[$nb];
1595
+			$format = $globalSources[$nb]['format'];
1596
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1597 1597
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1598
-		    } elseif ($format === 'vrstcp') {
1598
+			} elseif ($format === 'vrstcp') {
1599 1599
 			$buffer = @socket_read($r, 6000);
1600
-		    } else {
1600
+			} else {
1601 1601
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1602
-		    }
1603
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1604
-		    //echo $buffer."\n";
1605
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1606
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1607
-		    $error = false;
1608
-		    //$SI::del();
1609
-		    if ($buffer !== FALSE) {
1602
+			}
1603
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1604
+			//echo $buffer."\n";
1605
+			// lets play nice and handle signals such as ctrl-c/kill properly
1606
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1607
+			$error = false;
1608
+			//$SI::del();
1609
+			if ($buffer !== FALSE) {
1610 1610
 			if ($format === 'vrstcp') {
1611
-			    $buffer = explode('},{',$buffer);
1611
+				$buffer = explode('},{',$buffer);
1612 1612
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1613
-		    }
1614
-		    // SBS format is CSV format
1615
-		    if ($buffer !== FALSE && $buffer !== '') {
1613
+			}
1614
+			// SBS format is CSV format
1615
+			if ($buffer !== FALSE && $buffer !== '') {
1616 1616
 			$tt[$format] = 0;
1617 1617
 			if ($format === 'acarssbs3') {
1618
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1619
-			    $ACARS->add(trim($buffer));
1620
-			    $ACARS->deleteLiveAcarsData();
1618
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1619
+				$ACARS->add(trim($buffer));
1620
+				$ACARS->deleteLiveAcarsData();
1621 1621
 			} elseif ($format === 'raw') {
1622
-			    // AVR format
1623
-			    $data = $SBS->parse($buffer);
1624
-			    if (is_array($data)) {
1622
+				// AVR format
1623
+				$data = $SBS->parse($buffer);
1624
+				if (is_array($data)) {
1625 1625
 				$data['datetime'] = date('Y-m-d H:i:s');
1626 1626
 				$data['format_source'] = 'raw';
1627 1627
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1628 1628
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1629 1629
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1630 1630
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1631
-			    }
1631
+				}
1632 1632
 			} elseif ($format === 'ais') {
1633
-			    $ais_data = $AIS->parse_line(trim($buffer));
1634
-			    $data = array();
1635
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1636
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1637
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1638
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1639
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1640
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1641
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1642
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1643
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1644
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1645
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1646
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1647
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1648
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1649
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1633
+				$ais_data = $AIS->parse_line(trim($buffer));
1634
+				$data = array();
1635
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1636
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1637
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1638
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1639
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1640
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1641
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1642
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1643
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1644
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1645
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1646
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1647
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1648
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1649
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1651 1651
 
1652
-			    if (isset($ais_data['timestamp'])) {
1652
+				if (isset($ais_data['timestamp'])) {
1653 1653
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1654
-			    } else {
1654
+				} else {
1655 1655
 				$data['datetime'] = date('Y-m-d H:i:s');
1656
-			    }
1657
-			    $data['format_source'] = 'aisnmea';
1658
-    			    $data['id_source'] = $id_source;
1659
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1660
-			    unset($data);
1661
-                        } elseif ($format === 'flightgearsp') {
1662
-                    	    //echo $buffer."\n";
1663
-                    	    if (strlen($buffer) > 5) {
1656
+				}
1657
+				$data['format_source'] = 'aisnmea';
1658
+					$data['id_source'] = $id_source;
1659
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1660
+				unset($data);
1661
+						} elseif ($format === 'flightgearsp') {
1662
+							//echo $buffer."\n";
1663
+							if (strlen($buffer) > 5) {
1664 1664
 				$line = explode(',',$buffer);
1665 1665
 				$data = array();
1666 1666
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1677,38 +1677,38 @@  discard block
 block discarded – undo
1677 1677
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1678 1678
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1679 1679
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1680
-			    }
1681
-                        } elseif ($format === 'acars') {
1682
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1683
-			    $ACARS->add(trim($buffer));
1684
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1685
-			    $ACARS->deleteLiveAcarsData();
1680
+				}
1681
+						} elseif ($format === 'acars') {
1682
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1683
+				$ACARS->add(trim($buffer));
1684
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1685
+				$ACARS->deleteLiveAcarsData();
1686 1686
 			} elseif ($format === 'flightgearmp') {
1687
-			    if (substr($buffer,0,1) != '#') {
1687
+				if (substr($buffer,0,1) != '#') {
1688 1688
 				$data = array();
1689 1689
 				//echo $buffer."\n";
1690 1690
 				$line = explode(' ',$buffer);
1691 1691
 				if (count($line) === 11) {
1692
-				    $userserver = explode('@',$line[0]);
1693
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1694
-				    $data['ident'] = $userserver[0];
1695
-				    $data['registration'] = $userserver[0];
1696
-				    $data['latitude'] = $line[4];
1697
-				    $data['longitude'] = $line[5];
1698
-				    $data['altitude'] = $line[6];
1699
-				    $data['datetime'] = date('Y-m-d H:i:s');
1700
-				    $aircraft_type = $line[10];
1701
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1702
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1703
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1692
+					$userserver = explode('@',$line[0]);
1693
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1694
+					$data['ident'] = $userserver[0];
1695
+					$data['registration'] = $userserver[0];
1696
+					$data['latitude'] = $line[4];
1697
+					$data['longitude'] = $line[5];
1698
+					$data['altitude'] = $line[6];
1699
+					$data['datetime'] = date('Y-m-d H:i:s');
1700
+					$aircraft_type = $line[10];
1701
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1702
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1703
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1705
+				}
1705 1706
 				}
1706
-			    }
1707 1707
 			} elseif ($format === 'beast') {
1708
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1709
-			    die;
1708
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1709
+				die;
1710 1710
 			} elseif ($format === 'vrstcp') {
1711
-			    foreach($buffer as $all_data) {
1711
+				foreach($buffer as $all_data) {
1712 1712
 				$line = json_decode('{'.$all_data.'}',true);
1713 1713
 				$data = array();
1714 1714
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1728,158 +1728,158 @@  discard block
 block discarded – undo
1728 1728
 				*/
1729 1729
 				$data['datetime'] = date('Y-m-d H:i:s');
1730 1730
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1731
-		    		$data['format_source'] = 'vrstcp';
1731
+					$data['format_source'] = 'vrstcp';
1732 1732
 				$data['id_source'] = $id_source;
1733 1733
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1734 1734
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1735 1735
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1736 1736
 				unset($data);
1737
-			    }
1737
+				}
1738 1738
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1739
-			    $line = explode("\t", $buffer);
1740
-			    for($k = 0; $k < count($line); $k=$k+2) {
1739
+				$line = explode("\t", $buffer);
1740
+				for($k = 0; $k < count($line); $k=$k+2) {
1741 1741
 				$key = $line[$k];
1742
-			        $lined[$key] = $line[$k+1];
1743
-			    }
1744
-    			    if (count($lined) > 3) {
1745
-    				$data['hex'] = $lined['hexid'];
1746
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1747
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1748
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1749
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1750
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1751
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1752
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1753
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1754
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1755
-    				$data['id_source'] = $id_source;
1756
-    				$data['format_source'] = 'tsv';
1757
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1758
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1742
+					$lined[$key] = $line[$k+1];
1743
+				}
1744
+					if (count($lined) > 3) {
1745
+					$data['hex'] = $lined['hexid'];
1746
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1747
+					$data['datetime'] = date('Y-m-d H:i:s');;
1748
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1749
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1750
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1751
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1752
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1753
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1754
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1755
+					$data['id_source'] = $id_source;
1756
+					$data['format_source'] = 'tsv';
1757
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1758
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1759 1759
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1760
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1761
-    				unset($lined);
1762
-    				unset($data);
1763
-    			    } else $error = true;
1760
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1761
+					unset($lined);
1762
+					unset($data);
1763
+					} else $error = true;
1764 1764
 			} elseif ($format === 'aprs' && $use_aprs) {
1765
-			    if ($aprs_connect === 0) {
1765
+				if ($aprs_connect === 0) {
1766 1766
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1767 1767
 				$aprs_connect = 1;
1768
-			    }
1768
+				}
1769 1769
 			    
1770
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1770
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1771 1771
 				$aprs_last_tx = time();
1772 1772
 				$data_aprs = "# Keep alive";
1773 1773
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1774
-			    }
1774
+				}
1775 1775
 			    
1776
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1777
-			    //echo 'APRS data : '.$buffer."\n";
1778
-			    $buffer = str_replace('APRS <- ','',$buffer);
1779
-			    $buffer = str_replace('APRS -> ','',$buffer);
1780
-			    //echo $buffer."\n";
1781
-			    date_default_timezone_set('UTC');
1782
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1776
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1777
+				//echo 'APRS data : '.$buffer."\n";
1778
+				$buffer = str_replace('APRS <- ','',$buffer);
1779
+				$buffer = str_replace('APRS -> ','',$buffer);
1780
+				//echo $buffer."\n";
1781
+				date_default_timezone_set('UTC');
1782
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1783 1783
 				$line = $APRS->parse($buffer);
1784 1784
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1785 1785
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1786
-				    $aprs_last_tx = time();
1787
-				    $data = array();
1788
-				    //print_r($line);
1789
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1790
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1791
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1792
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1793
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1794
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1795
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1796
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1797
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1798
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1799
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1800
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1801
-				    $data['latitude'] = $line['latitude'];
1802
-				    $data['longitude'] = $line['longitude'];
1803
-				    //$data['verticalrate'] = $line[16];
1804
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1805
-				    //else $data['speed'] = 0;
1806
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1807
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1808
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1809
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1786
+					$aprs_last_tx = time();
1787
+					$data = array();
1788
+					//print_r($line);
1789
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1790
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1791
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1792
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1793
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1794
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1795
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1796
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1797
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1798
+					else $data['datetime'] = date('Y-m-d H:i:s');
1799
+					//$data['datetime'] = date('Y-m-d H:i:s');
1800
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1801
+					$data['latitude'] = $line['latitude'];
1802
+					$data['longitude'] = $line['longitude'];
1803
+					//$data['verticalrate'] = $line[16];
1804
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1805
+					//else $data['speed'] = 0;
1806
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1807
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1808
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1809
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1810 1810
 				    
1811
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1812
-				    //else echo 'No heading...'."\n";
1813
-				    //else $data['heading'] = 0;
1814
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1815
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1816
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1817
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1818
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1819
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1820
-    				    $data['id_source'] = $id_source;
1821
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1822
-				    else $data['format_source'] = 'aprs';
1823
-				    $data['source_name'] = $line['source'];
1824
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1825
-				    else $data['source_type'] = 'flarm';
1826
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1827
-				    $currentdate = date('Y-m-d H:i:s');
1828
-				    $aprsdate = strtotime($data['datetime']);
1829
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1830
-				    // Accept data if time <= system time + 20s
1831
-				    //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'])))) {
1832
-				    if (
1811
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1812
+					//else echo 'No heading...'."\n";
1813
+					//else $data['heading'] = 0;
1814
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1815
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1816
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1817
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1818
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1819
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1820
+						$data['id_source'] = $id_source;
1821
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1822
+					else $data['format_source'] = 'aprs';
1823
+					$data['source_name'] = $line['source'];
1824
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1825
+					else $data['source_type'] = 'flarm';
1826
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1827
+					$currentdate = date('Y-m-d H:i:s');
1828
+					$aprsdate = strtotime($data['datetime']);
1829
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1830
+					// Accept data if time <= system time + 20s
1831
+					//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'])))) {
1832
+					if (
1833 1833
 					($data['source_type'] === 'modes') || 
1834 1834
 					isset($line['stealth']) && 
1835 1835
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1836 1836
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1837 1837
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1838 1838
 					$send = $SI->add($data);
1839
-				    } elseif ($data['source_type'] === 'ais') {
1839
+					} elseif ($data['source_type'] === 'ais') {
1840 1840
 					$data['type'] = '';
1841 1841
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1842
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1842
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1843 1843
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1844
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1845
-					    //$line['symbol'] === 'Balloon' ||
1846
-					    $line['symbol'] === 'Glider' || 
1847
-					    $line['symbol'] === 'No. Plane' || 
1848
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1849
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1850
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1851
-					    $send = $SI->add($data);
1852
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1853
-					    $line['symbol'] === 'Yacht (Sail)' || 
1854
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1855
-					    $send = $MI->add($data);
1856
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1857
-					    $line['symbol'] === 'Car' || 
1858
-					    $line['symbol'] === 'Ambulance' || 
1859
-					    $line['symbol'] === 'Van' || 
1860
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1861
-					    $line['symbol'] === 'Motorcycle' || 
1862
-					    $line['symbol'] === 'Tractor' || 
1863
-					    $line['symbol'] === 'Police' || 
1864
-					    $line['symbol'] === 'Bike' || 
1865
-					    $line['symbol'] === 'Jogger' || 
1866
-					    $line['symbol'] === 'Horse' || 
1867
-					    $line['symbol'] === 'Bus' || 
1868
-					    $line['symbol'] === 'Jeep' || 
1869
-					    $line['symbol'] === 'Recreational Vehicle' || 
1870
-					    $line['symbol'] === 'Yacht (Sail)' || 
1871
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1872
-					    $line['symbol'] === 'Firetruck' || 
1873
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1874
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1875
-					    $line['symbol'] === 'SUV' ||
1876
-					    $line['symbol'] === 'Snowmobile' ||
1877
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1878
-				    //} 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') {
1844
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1845
+						//$line['symbol'] === 'Balloon' ||
1846
+						$line['symbol'] === 'Glider' || 
1847
+						$line['symbol'] === 'No. Plane' || 
1848
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1849
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1850
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1851
+						$send = $SI->add($data);
1852
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1853
+						$line['symbol'] === 'Yacht (Sail)' || 
1854
+						$line['symbol'] === 'Ship (Power Boat)')) {
1855
+						$send = $MI->add($data);
1856
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1857
+						$line['symbol'] === 'Car' || 
1858
+						$line['symbol'] === 'Ambulance' || 
1859
+						$line['symbol'] === 'Van' || 
1860
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1861
+						$line['symbol'] === 'Motorcycle' || 
1862
+						$line['symbol'] === 'Tractor' || 
1863
+						$line['symbol'] === 'Police' || 
1864
+						$line['symbol'] === 'Bike' || 
1865
+						$line['symbol'] === 'Jogger' || 
1866
+						$line['symbol'] === 'Horse' || 
1867
+						$line['symbol'] === 'Bus' || 
1868
+						$line['symbol'] === 'Jeep' || 
1869
+						$line['symbol'] === 'Recreational Vehicle' || 
1870
+						$line['symbol'] === 'Yacht (Sail)' || 
1871
+						$line['symbol'] === 'Ship (Power Boat)' || 
1872
+						$line['symbol'] === 'Firetruck' || 
1873
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1874
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1875
+						$line['symbol'] === 'SUV' ||
1876
+						$line['symbol'] === 'Snowmobile' ||
1877
+						$line['symbol'] === 'Mobile Satellite Station')) {
1878
+					//} 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') {
1879 1879
 				//    } 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') {
1880 1880
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1881 1881
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1882
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1882
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1883 1883
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1884 1884
 					$Source->deleteOldLocationByType('gs');
1885 1885
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1887,7 +1887,7 @@  discard block
 block discarded – undo
1887 1887
 					} else {
1888 1888
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1889 1889
 					}
1890
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1890
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1891 1891
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1892 1892
 					if ($globalDebug) echo '# Weather Station added'."\n";
1893 1893
 					$Source->deleteOldLocationByType('wx');
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 					} else {
1898 1898
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1899 1899
 					}
1900
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1900
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1901 1901
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1902 1902
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1903 1903
 					$Source->deleteOldLocationByType('lightning');
@@ -1906,11 +1906,11 @@  discard block
 block discarded – undo
1906 1906
 					} else {
1907 1907
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1908 1908
 					}
1909
-				    } elseif ($globalDebug) {
1910
-				    	echo '/!\ Not added: '.$buffer."\n";
1911
-				    	print_r($line);
1912
-				    }
1913
-				    unset($data);
1909
+					} elseif ($globalDebug) {
1910
+						echo '/!\ Not added: '.$buffer."\n";
1911
+						print_r($line);
1912
+					}
1913
+					unset($data);
1914 1914
 				}
1915 1915
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1916 1916
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1929,12 +1929,12 @@  discard block
 block discarded – undo
1929 1929
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1930 1930
 					$globalSources[$nb]['last_weather_clean'] = time();
1931 1931
 				}
1932
-			    }
1932
+				}
1933 1933
 			} else {
1934
-			    $line = explode(',', $buffer);
1935
-    			    if (count($line) > 20) {
1936
-    			    	$data['hex'] = $line[4];
1937
-    				/*
1934
+				$line = explode(',', $buffer);
1935
+					if (count($line) > 20) {
1936
+						$data['hex'] = $line[4];
1937
+					/*
1938 1938
     				$data['datetime'] = $line[6].' '.$line[7];
1939 1939
     					date_default_timezone_set($globalTimezone);
1940 1940
     					$datetime = new DateTime($data['datetime']);
@@ -1942,31 +1942,31 @@  discard block
 block discarded – undo
1942 1942
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1943 1943
     					date_default_timezone_set('UTC');
1944 1944
     				*/
1945
-    				// Force datetime to current UTC datetime
1946
-    				date_default_timezone_set('UTC');
1947
-    				$data['datetime'] = date('Y-m-d H:i:s');
1948
-    				$data['ident'] = trim($line[10]);
1949
-    				$data['latitude'] = $line[14];
1950
-    				$data['longitude'] = $line[15];
1951
-    				$data['verticalrate'] = $line[16];
1952
-    				$data['emergency'] = $line[20];
1953
-    				$data['speed'] = $line[12];
1954
-    				$data['squawk'] = $line[17];
1955
-    				$data['altitude'] = $line[11];
1956
-    				$data['heading'] = $line[13];
1957
-    				$data['ground'] = $line[21];
1958
-    				$data['emergency'] = $line[19];
1959
-    				$data['format_source'] = 'sbs';
1945
+					// Force datetime to current UTC datetime
1946
+					date_default_timezone_set('UTC');
1947
+					$data['datetime'] = date('Y-m-d H:i:s');
1948
+					$data['ident'] = trim($line[10]);
1949
+					$data['latitude'] = $line[14];
1950
+					$data['longitude'] = $line[15];
1951
+					$data['verticalrate'] = $line[16];
1952
+					$data['emergency'] = $line[20];
1953
+					$data['speed'] = $line[12];
1954
+					$data['squawk'] = $line[17];
1955
+					$data['altitude'] = $line[11];
1956
+					$data['heading'] = $line[13];
1957
+					$data['ground'] = $line[21];
1958
+					$data['emergency'] = $line[19];
1959
+					$data['format_source'] = 'sbs';
1960 1960
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1961 1961
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1962
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1962
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1963 1963
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1964
-    				$data['id_source'] = $id_source;
1965
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1966
-    				else $error = true;
1967
-    				unset($data);
1968
-    			    } else $error = true;
1969
-			    if ($error) {
1964
+					$data['id_source'] = $id_source;
1965
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1966
+					else $error = true;
1967
+					unset($data);
1968
+					} else $error = true;
1969
+				if ($error) {
1970 1970
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1971 1971
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1972 1972
 				} else {
@@ -1982,13 +1982,13 @@  discard block
 block discarded – undo
1982 1982
 					connect_all($sourceer);
1983 1983
 					$sourceer = array();
1984 1984
 				}
1985
-			    }
1985
+				}
1986 1986
 			}
1987 1987
 			// Sleep for xxx microseconds
1988 1988
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1989
-		    } else {
1989
+			} else {
1990 1990
 			if ($format === 'flightgearmp') {
1991
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1991
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1992 1992
 				//@socket_close($r);
1993 1993
 				sleep($globalMinFetch);
1994 1994
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1997,9 +1997,9 @@  discard block
 block discarded – undo
1997 1997
 				break;
1998 1998
 				
1999 1999
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2000
-			    if (isset($tt[$format])) $tt[$format]++;
2001
-			    else $tt[$format] = 0;
2002
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
2000
+				if (isset($tt[$format])) $tt[$format]++;
2001
+				else $tt[$format] = 0;
2002
+				if ($tt[$format] > 30 || $buffer === FALSE) {
2003 2003
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2004 2004
 				//@socket_close($r);
2005 2005
 				sleep(2);
@@ -2010,24 +2010,24 @@  discard block
 block discarded – undo
2010 2010
 				//connect_all($globalSources);
2011 2011
 				$tt[$format]=0;
2012 2012
 				break;
2013
-			    } 
2014
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2013
+				} 
2014
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2015
+			}
2015 2016
 			}
2016
-		    }
2017 2017
 		}
2018
-	    } else {
2018
+		} else {
2019 2019
 		$error = socket_strerror(socket_last_error());
2020 2020
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2021 2021
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2022 2022
 			if (isset($globalDebug)) echo "Restarting...\n";
2023 2023
 			// Restart the script if possible
2024 2024
 			if (is_array($sockets)) {
2025
-			    if ($globalDebug) echo "Shutdown all sockets...";
2025
+				if ($globalDebug) echo "Shutdown all sockets...";
2026 2026
 			    
2027
-			    foreach ($sockets as $sock) {
2027
+				foreach ($sockets as $sock) {
2028 2028
 				@socket_shutdown($sock,2);
2029 2029
 				@socket_close($sock);
2030
-			    }
2030
+				}
2031 2031
 			    
2032 2032
 			}
2033 2033
 			if ($globalDebug) echo "Waiting...";
@@ -2042,15 +2042,15 @@  discard block
 block discarded – undo
2042 2042
 			if ($globalDebug) echo "Restart all connections...";
2043 2043
 			connect_all($globalSources);
2044 2044
 		}
2045
-	    }
2045
+		}
2046 2046
 	}
2047 2047
 	if ($globalDaemon === false) {
2048
-	    if ($globalDebug) echo 'Check all...'."\n";
2049
-	    if (isset($SI)) $SI->checkAll();
2050
-	    if (isset($TI)) $TI->checkAll();
2051
-	    if (isset($MI)) $MI->checkAll();
2048
+		if ($globalDebug) echo 'Check all...'."\n";
2049
+		if (isset($SI)) $SI->checkAll();
2050
+		if (isset($TI)) $TI->checkAll();
2051
+		if (isset($MI)) $MI->checkAll();
2052
+	}
2052 2053
 	}
2053
-    }
2054 2054
 }
2055 2055
 
2056 2056
 ?>
Please login to merge, or discard this patch.
Spacing   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$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'));
57
+$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'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106 106
     if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
107
+    $SI = new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
111 111
     $SI->connect();
112 112
 */
113
-} else $SI=new SpotterImport($Connection->db);
113
+} else $SI = new SpotterImport($Connection->db);
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     $MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127
-$SBS=new SBS();
127
+$SBS = new SBS();
128 128
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
129
-	$ACARS=new ACARS($Connection->db,true);
130
-	$Source=new Source($Connection->db);
129
+	$ACARS = new ACARS($Connection->db, true);
130
+	$Source = new Source($Connection->db);
131 131
 }
132
-$Common=new Common();
132
+$Common = new Common();
133 133
 date_default_timezone_set('UTC');
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
137
+    pcntl_signal(SIGINT, function() {
138 138
         global $sockets;
139 139
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140 140
         die("Bye!\n");
@@ -150,40 +150,40 @@  discard block
 block discarded – undo
150 150
 
151 151
 function connect_all($hosts) {
152 152
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
153
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
154 154
     $reset++;
155 155
     if ($globalDebug) echo 'Connect to all...'."\n";
156 156
     foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
160
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
+            if (preg_match('/deltadb.txt$/i', $host)) {
162 162
         	//$formats[$id] = 'deltadbtxt';
163 163
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 164
         	//$last_exec['deltadbtxt'] = 0;
165 165
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
166
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
167 167
         	//$formats[$id] = 'vatsimtxt';
168 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 169
         	//$last_exec['vatsimtxt'] = 0;
170 170
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
171
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
172 172
         	//$formats[$id] = 'aircraftlistjson';
173 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 174
         	//$last_exec['aircraftlistjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
176
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftjson';
178 178
         	$globalSources[$id]['format'] = 'aircraftjson';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraft$/i',$host)) {
181
+    	    } else if (preg_match('/aircraft$/i', $host)) {
182 182
         	//$formats[$id] = 'planefinderclient';
183 183
         	$globalSources[$id]['format'] = 'planefinderclient';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
-    	    } else if (preg_match('/opensky/i',$host)) {
186
+    	    } else if (preg_match('/opensky/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftlistjson';
188 188
         	$globalSources[$id]['format'] = 'opensky';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         	    exit(0);
201 201
         	}
202 202
     	    */
203
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
203
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
204 204
         	//$formats[$id] = 'planeupdatefaa';
205 205
         	$globalSources[$id]['format'] = 'planeupdatefaa';
206 206
         	//$last_exec['planeupdatefaa'] = 0;
@@ -209,37 +209,37 @@  discard block
 block discarded – undo
209 209
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210 210
         	    exit(0);
211 211
         	}
212
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
212
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
213 213
         	//$formats[$id] = 'phpvmacars';
214 214
         	$globalSources[$id]['format'] = 'phpvmacars';
215 215
         	//$last_exec['phpvmacars'] = 0;
216 216
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
217
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
218 218
         	//$formats[$id] = 'phpvmacars';
219 219
         	$globalSources[$id]['format'] = 'vaos';
220 220
         	//$last_exec['phpvmacars'] = 0;
221 221
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
222
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'vam';
225 225
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
-            } else if (preg_match('/whazzup/i',$host)) {
226
+            } else if (preg_match('/whazzup/i', $host)) {
227 227
         	//$formats[$id] = 'whazzup';
228 228
         	$globalSources[$id]['format'] = 'whazzup';
229 229
         	//$last_exec['whazzup'] = 0;
230 230
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
-            } else if (preg_match('/blitzortung/i',$host)) {
231
+            } else if (preg_match('/blitzortung/i', $host)) {
232 232
         	$globalSources[$id]['format'] = 'blitzortung';
233 233
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
-            } else if (preg_match('/airwhere/i',$host)) {
234
+            } else if (preg_match('/airwhere/i', $host)) {
235 235
         	$globalSources[$id]['format'] = 'airwhere';
236 236
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
-            } else if (preg_match('/recentpireps/i',$host)) {
237
+            } else if (preg_match('/recentpireps/i', $host)) {
238 238
         	//$formats[$id] = 'pirepsjson';
239 239
         	$globalSources[$id]['format'] = 'pirepsjson';
240 240
         	//$last_exec['pirepsjson'] = 0;
241 241
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
242
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
243 243
         	//$formats[$id] = 'fr24json';
244 244
         	$globalSources[$id]['format'] = 'fr24json';
245 245
         	//$last_exec['fr24json'] = 0;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249 249
         	    exit(0);
250 250
         	}
251
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
251
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
252 252
         	//$formats[$id] = 'fr24json';
253 253
         	$globalSources[$id]['format'] = 'myshiptracking';
254 254
         	//$last_exec['fr24json'] = 0;
@@ -258,22 +258,22 @@  discard block
 block discarded – undo
258 258
         	    exit(0);
259 259
         	}
260 260
             //} else if (preg_match('/10001/',$host)) {
261
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
261
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262 262
         	//$formats[$id] = 'tsv';
263 263
         	$globalSources[$id]['format'] = 'tsv';
264 264
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265 265
             }
266
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
266
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267 267
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
268
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
269 269
     		    if ($idf !== false) {
270 270
     			$httpfeeds[$id] = $idf;
271 271
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272 272
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273 273
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274 274
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276
-	    $hostport = explode(':',$host);
275
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
276
+	    $hostport = explode(':', $host);
277 277
 	    if (isset($hostport[1])) {
278 278
 		$port = $hostport[1];
279 279
 		$hostn = $hostport[0];
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 	    }
284 284
 	    $Common = new Common();
285 285
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
286
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
286
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
287 287
     	    } else {
288
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
288
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
289 289
 	    }
290 290
 	    if ($s) {
291 291
     	        $sockets[$id] = $s;
292 292
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
293
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
293
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
294 294
 			//$formats[$id] = 'aprs';
295 295
 			$globalSources[$id]['format'] = 'aprs';
296 296
 			//$aprs_connect = 0;
297 297
 			//$use_aprs = true;
298
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
298
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
299 299
 			$globalSources[$id]['format'] = 'vrstcp';
300 300
     		    } elseif ($port == '10001') {
301 301
         		//$formats[$id] = 'tsv';
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
337 337
 else $timeout = 20;
338 338
 $errno = '';
339
-$errstr='';
339
+$errstr = '';
340 340
 
341 341
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
342 342
 /* Initiate connections to all the hosts simultaneously */
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 //connect_all($globalSources);
345 345
 
346 346
 if (isset($globalProxy) && $globalProxy) {
347
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
347
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
348 348
 } else {
349 349
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
350 350
 }
@@ -374,16 +374,16 @@  discard block
 block discarded – undo
374 374
 
375 375
 if ($use_aprs) {
376 376
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
377
-	$APRS=new APRS();
377
+	$APRS = new APRS();
378 378
 	$aprs_connect = 0;
379 379
 	$aprs_keep = 120;
380 380
 	$aprs_last_tx = time();
381 381
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
382
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
382
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
383 383
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
384
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
384
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
385 385
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
386
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
386
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
387 387
 	if ($aprs_full) $aprs_filter = '';
388 388
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
389 389
 	else $aprs_pass = '-1';
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
 sleep(1);
398 398
 if ($globalDebug) echo "SCAN MODE \n\n";
399 399
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
400
-$endtime = time()+$globalCronEnd;
400
+$endtime = time() + $globalCronEnd;
401 401
 $i = 1;
402 402
 $tt = array();
403 403
 // Delete all ATC
404 404
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
405
-	$ATC=new ATC($Connection->db);
405
+	$ATC = new ATC($Connection->db);
406 406
 }
407 407
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
408 408
 	$ATC->deleteAll();
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 while ($i > 0) {
413 413
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
414 414
 
415
-    if (!$globalDaemon) $i = $endtime-time();
415
+    if (!$globalDaemon) $i = $endtime - time();
416 416
     // Delete old ATC
417 417
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
418 418
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	}
427 427
 	if ($max < $globalMinFetch) {
428 428
 	    if ($globalDebug) echo 'Sleeping...'."\n";
429
-	    sleep($globalMinFetch-$max+2);
429
+	    sleep($globalMinFetch - $max + 2);
430 430
 	}
431 431
     }
432 432
 
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	    //$buffer = $Common->getData($hosts[$id]);
446 446
 	    $buffer = $Common->getData($value['host']);
447 447
 	    if ($buffer != '') $reset = 0;
448
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
-	    $buffer = explode('\n',$buffer);
448
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
449
+	    $buffer = explode('\n', $buffer);
450 450
 	    foreach ($buffer as $line) {
451 451
     		if ($line != '' && count($line) > 7) {
452 452
     		    $line = explode(',', $line);
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 	    )
480 480
 	) {
481 481
 	    date_default_timezone_set('CET');
482
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
483 483
 	    date_default_timezone_set('UTC');
484 484
 	    if ($buffer != '') $reset = 0;
485
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
-	    $buffer = explode('\n',$buffer);
485
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
486
+	    $buffer = explode('\n', $buffer);
487 487
 	    foreach ($buffer as $line) {
488 488
 		if ($line != '') {
489 489
 		    //echo "'".$line."'\n";
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 		    $ais_data = $AIS->parse_line(trim($line));
492 492
 		    $data = array();
493 493
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
495 495
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496 496
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497 497
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504 504
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
505 505
 		    if (isset($ais_data['timestamp'])) {
506
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
506
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
507 507
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
508 508
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
509 509
 			    $add = true;
@@ -526,21 +526,21 @@  discard block
 block discarded – undo
526 526
 	    $w = $e = null;
527 527
 	    
528 528
 	    if (isset($arr[$id])) {
529
-		$nn = stream_select($arr,$w,$e,$timeout);
529
+		$nn = stream_select($arr, $w, $e, $timeout);
530 530
 		if ($nn > 0) {
531 531
 		    foreach ($httpfeeds as $feed) {
532
-			$buffer = stream_get_line($feed,2000,"\n");
532
+			$buffer = stream_get_line($feed, 2000, "\n");
533 533
 			if ($buffer === FALSE) {
534 534
 			    connect_all($globalSources);
535 535
 			}
536
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
537
-			$buffer = explode('\n',$buffer);
536
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
537
+			$buffer = explode('\n', $buffer);
538 538
 			foreach ($buffer as $line) {
539 539
 			    if ($line != '') {
540 540
 				$ais_data = $AIS->parse_line(trim($line));
541 541
 				$data = array();
542 542
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
543
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
543
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
544 544
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
545 545
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
546 546
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -552,9 +552,9 @@  discard block
 block discarded – undo
552 552
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
553 553
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
554 554
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
555
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
555
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
556 556
 				if (isset($ais_data['timestamp'])) {
557
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
558 558
 				} else {
559 559
 				    $data['datetime'] = date('Y-m-d H:i:s');
560 560
 				}
@@ -586,10 +586,10 @@  discard block
 block discarded – undo
586 586
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
587 587
 	    )
588 588
 	) {
589
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
589
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
590 590
 	    if ($buffer != '') {
591 591
 		//echo $buffer;
592
-		$all_data = json_decode($buffer,true);
592
+		$all_data = json_decode($buffer, true);
593 593
 		//print_r($all_data);
594 594
 		if (isset($all_data[0]['DATA'])) {
595 595
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 			    $data['ident'] = $line['NAME'];
599 599
 			    $data['mmsi'] = $line['MMSI'];
600 600
 			    if (strlen($data['mmsi']) > 9) {
601
-				$data['mmsi'] = substr($data['mmsi'],-9);
601
+				$data['mmsi'] = substr($data['mmsi'], -9);
602 602
 			    }
603 603
 			    $data['speed'] = $line['SOG'];
604 604
 			    $data['heading'] = $line['COG'];
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 			    //$data['type_id'] = $line['TYPE'];
609 609
 			    $data['imo'] = $line['IMO'];
610 610
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
612
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
611
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
612
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
613 613
 			    $data['format_source'] = 'myshiptracking';
614 614
 			    $data['id_source'] = $id_source;
615 615
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -626,16 +626,16 @@  discard block
 block discarded – undo
626 626
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
627 627
 	    )
628 628
 	) {
629
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
629
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
630 630
 	    if ($buffer != '') {
631
-		$all_data = json_decode($buffer,true);
631
+		$all_data = json_decode($buffer, true);
632 632
 		if (isset($all_data[0]['mmsi'])) {
633 633
 		    foreach ($all_data as $line) {
634 634
 			if ($line != '') {
635 635
 			    $data = array();
636 636
 			    $data['ident'] = $line['shipname'];
637 637
 			    $data['callsign'] = $line['callsign'];
638
-			    $data['mmsi'] = substr($line['mmsi'],-9);
638
+			    $data['mmsi'] = substr($line['mmsi'], -9);
639 639
 			    $data['speed'] = $line['sog'];
640 640
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
641 641
 			    $data['latitude'] = $line['latitude'];
@@ -662,14 +662,14 @@  discard block
 block discarded – undo
662 662
 	) {
663 663
 	    $buffer = $Common->getData($value['host']);
664 664
 	    if ($buffer != '') {
665
-		$all_data = json_decode($buffer,true);
665
+		$all_data = json_decode($buffer, true);
666 666
 		if (isset($all_data['features'][0]['id'])) {
667 667
 		    foreach ($all_data['features'] as $line) {
668 668
 			print_r($line);
669 669
 			$data = array();
670 670
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
671 671
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
672
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
672
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
673 673
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
674 674
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
675 675
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -696,31 +696,31 @@  discard block
 block discarded – undo
696 696
 	    )
697 697
 	) {
698 698
 	    if ($globalDebug) echo 'download...';
699
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
700 700
 	    if ($globalDebug) echo 'done !'."\n";
701 701
 	    // FIXME: Need more work
702 702
 	    if ($buffer != '') $reset = 0;
703
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704
-	    $buffer = explode('\n',$buffer);
703
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
704
+	    $buffer = explode('\n', $buffer);
705 705
 	    foreach ($buffer as $line) {
706 706
 		if ($line != '') {
707 707
 		    $data = array();
708 708
 		    //echo $line."\n";
709
-		    $data['mmsi'] = (int)substr($line,0,9);
710
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
711
-		    $data['status_id'] = substr($line,21,2);
712
-		    $data['type_id'] = substr($line,24,3);
713
-		    $data['latitude'] = substr($line,29,9);
714
-		    $data['longitude'] = substr($line,41,9);
715
-		    $data['speed'] = round(substr($line,51,5));
709
+		    $data['mmsi'] = (int) substr($line, 0, 9);
710
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
711
+		    $data['status_id'] = substr($line, 21, 2);
712
+		    $data['type_id'] = substr($line, 24, 3);
713
+		    $data['latitude'] = substr($line, 29, 9);
714
+		    $data['longitude'] = substr($line, 41, 9);
715
+		    $data['speed'] = round(substr($line, 51, 5));
716 716
 		    //$data['course'] = substr($line,57,5);
717
-		    $data['heading'] = round(substr($line,63,3));
717
+		    $data['heading'] = round(substr($line, 63, 3));
718 718
 		    //$data['draft'] = substr($line,67,4);
719 719
 		    //$data['length'] = substr($line,72,3);
720 720
 		    //$data['beam'] = substr($line,76,2);
721
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
721
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
722 722
 		    //$data['callsign'] = trim(substr($line,100,7);
723
-		    $data['arrival_code'] = substr($line,108,20);
723
+		    $data['arrival_code'] = substr($line, 108, 20);
724 724
 		    //$data['etaDate'] = substr($line,129,5);
725 725
 		    //$data['etaTime'] = substr($line,135,5);
726 726
 		    $data['format_source'] = 'shipplotter';
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 	    )
741 741
 	) {
742 742
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
743
-		$authsailaway = $Common->getData('https://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);
743
+		$authsailaway = $Common->getData('https://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);
744 744
 		//echo $authsailaway;
745 745
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
746 746
 		if (isset($setcookie[1][0])) {
@@ -749,18 +749,18 @@  discard block
 block discarded – undo
749 749
 	    }
750 750
 
751 751
 	    if ($globalDebug) echo '! Download... ';
752
-	    for ($i =0; $i <= 1; $i++) {
752
+	    for ($i = 0; $i <= 1; $i++) {
753 753
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
754 754
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
755 755
 	    if ($globalDebug) echo 'done'."\n";
756 756
 	    if ($buffer != '') {
757
-		$all_data = json_decode($buffer,true);
757
+		$all_data = json_decode($buffer, true);
758 758
 		if (isset($all_data['missions'])) {
759 759
 			foreach ($all_data['missions'] as $mission) {
760 760
 				$mission_user = $mission['usrname'];
761
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
762
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
763
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
761
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
762
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
763
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
764 764
 					else $racebuffer = '';
765 765
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
766 766
 				} else {
@@ -768,19 +768,19 @@  discard block
 block discarded – undo
768 768
 					$racebuffer = '';
769 769
 				}
770 770
 				if ($racebuffer != '') {
771
-					$race_data = json_decode($racebuffer,true);
771
+					$race_data = json_decode($racebuffer, true);
772 772
 					//print_r($race_data);
773 773
 					unset($racebuffer);
774 774
 					if (isset($race_data['mission'])) {
775 775
 					    $datar = array();
776 776
 					    $datar['id'] = $mission['misnr'];
777 777
 					    $datar['desc'] = $race_data['mission']['misdescr'];
778
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
779
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
778
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
779
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
780 780
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
781 781
 					    $markers = array();
782 782
 					    foreach ($race_data['mission']['course'] as $course) {
783
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
783
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
784 784
 					    }
785 785
 					    $datar['markers'] = json_encode($markers);
786 786
 					    //print_r($datar);
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 					}
789 789
 				}
790 790
 				if ($bufferm != '') {
791
-					$mission_data = json_decode($bufferm,true);
791
+					$mission_data = json_decode($bufferm, true);
792 792
 					unset($bufferm);
793 793
 					if (isset($mission_data['leaderboard'][0]['results'])) {
794 794
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
802 802
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
803 803
 								$data['datetime'] = date('Y-m-d H:i:s');
804
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
804
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
805 805
 								$data['last_update'] = date('Y-m-d H:i:s');
806 806
 								$data['status'] = $sail['status'];
807 807
 								$data['type'] = $sail['btptype'];
@@ -812,16 +812,16 @@  discard block
 block discarded – undo
812 812
 									$data['longitude'] = $pos['longitude'];
813 813
 								}
814 814
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
815
-									$resultdescr = explode(',',$sail['resultdescr']);
815
+									$resultdescr = explode(',', $sail['resultdescr']);
816 816
 									if (count($resultdescr) > 2) {
817
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
818
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
817
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
818
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
819 819
 										if (isset($resultdescr[3])) {
820
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
820
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
821 821
 										}
822 822
 									}
823 823
 								}
824
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
824
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
825 825
 								$data['captain_id'] = $sail['usrnr'];
826 826
 								$data['captain_name'] = $sail['usrname'];
827 827
 								$data['race_id'] = $sail['misnr'];
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 	) {
869 869
 	    //$buffer = $Common->getData($hosts[$id]);
870 870
 	    $buffer = $Common->getData($value['host']);
871
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
872
-	    $buffer = explode('\n',$buffer);
871
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
872
+	    $buffer = explode('\n', $buffer);
873 873
 	    $reset = 0;
874 874
 	    foreach ($buffer as $line) {
875 875
     		if ($line != '') {
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
881 881
 			$data['pilot_id'] = $line[1];
882 882
 			$data['pilot_name'] = $line[2];
883
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
883
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
884 884
 			$data['ident'] = $line[0]; // ident
885 885
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
886 886
 			$data['speed'] = $line[8]; // speed
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
897 897
 			//if (isset($line[37])) $data['last_update'] = $line[37];
898 898
 		        $data['departure_airport_icao'] = $line[11];
899
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
899
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
900 900
 		        $data['arrival_airport_icao'] = $line[13];
901 901
 			$data['frequency'] = $line[4];
902 902
 			$data['type'] = $line[18];
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
     			$data['id_source'] = $id_source;
906 906
 	    		//$data['arrival_airport_time'] = ;
907 907
 	    		if ($line[9] != '') {
908
-	    		    $aircraft_data = explode('/',$line[9]);
908
+	    		    $aircraft_data = explode('/', $line[9]);
909 909
 	    		    if (isset($aircraft_data[1])) {
910 910
 	    			$data['aircraft_icao'] = $aircraft_data[1];
911 911
 	    		    }
@@ -920,9 +920,9 @@  discard block
 block discarded – undo
920 920
     			if ($line[3] === 'PILOT') $SI->add($data);
921 921
 			elseif ($line[3] === 'ATC') {
922 922
 				//print_r($data);
923
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
924
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
925
-				$typec = substr($data['ident'],-3);
923
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
924
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
925
+				$typec = substr($data['ident'], -3);
926 926
 				if ($typec === 'APP') $data['type'] = 'Approach';
927 927
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
928 928
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
935 935
 				if (!isset($data['source_name'])) $data['source_name'] = '';
936 936
 				if (isset($ATC)) {
937
-					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']);
938
-					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']);
937
+					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']);
938
+					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']);
939 939
 				}
940 940
 			}
941 941
     			unset($data);
@@ -951,24 +951,24 @@  discard block
 block discarded – undo
951 951
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
952 952
     	    )
953 953
     	) {
954
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
954
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
955 955
 	    if ($buffer != '') {
956 956
 		$all_data = simplexml_load_string($buffer);
957
-		foreach($all_data->children() as $childdata) {
957
+		foreach ($all_data->children() as $childdata) {
958 958
 			$data = array();
959 959
 			$line = $childdata;
960 960
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
961
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
962
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
963
-			$data['latitude'] = (float)$line['pktLatitude'];
964
-			$data['longitude'] = (float)$line['pktLongitude'];
965
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
966
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
967
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
961
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
962
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
963
+			$data['latitude'] = (float) $line['pktLatitude'];
964
+			$data['longitude'] = (float) $line['pktLongitude'];
965
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
966
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
967
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
968 968
 			$data['altitude_relative'] = 'AMSL';
969
-			$data['pilot_id'] = (int)$line['pktPilotID'];
969
+			$data['pilot_id'] = (int) $line['pktPilotID'];
970 970
 			$data['aircraft_icao'] = 'PARAGLIDER';
971
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
971
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
972 972
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
973 973
 			$data['format_source'] = $value['format'];
974 974
 			$SI->add($data);
@@ -976,22 +976,22 @@  discard block
 block discarded – undo
976 976
 		}
977 977
 	    }
978 978
 	    $Source->deleteOldLocationByType('gs');
979
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
979
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
980 980
 	    if ($buffer != '') {
981 981
 		$all_data = simplexml_load_string($buffer);
982
-		foreach($all_data->children() as $childdata) {
982
+		foreach ($all_data->children() as $childdata) {
983 983
 			$data = array();
984 984
 			$line = $childdata;
985
-			$data['id'] = (int)$line['gsID'];
986
-			$data['latitude'] = (float)$line['gsLatitude'];
987
-			$data['longitude'] = (float)$line['gsLongitude'];
988
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
985
+			$data['id'] = (int) $line['gsID'];
986
+			$data['latitude'] = (float) $line['gsLatitude'];
987
+			$data['longitude'] = (float) $line['gsLongitude'];
988
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
989 989
 			$data['altitude_relative'] = 'AMSL';
990
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
990
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
991 991
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
992
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
992
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
993 993
 			} else {
994
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
994
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
995 995
 			}
996 996
 			unset($data);
997 997
 		}
@@ -1009,9 +1009,9 @@  discard block
 block discarded – undo
1009 1009
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1010 1010
 	    )
1011 1011
 	) {
1012
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1012
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1013 1013
 	    if ($buffer != '') {
1014
-	        $all_data = json_decode($buffer,true);
1014
+	        $all_data = json_decode($buffer, true);
1015 1015
 		if (isset($all_data['acList'])) {
1016 1016
 		    $reset = 0;
1017 1017
 		    foreach ($all_data['acList'] as $line) {
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1028 1028
 			$data['emergency'] = ''; // emergency
1029 1029
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1030
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1030
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1031 1031
 			else $data['datetime'] = date('Y-m-d H:i:s');
1032 1032
 			//$data['datetime'] = date('Y-m-d H:i:s');
1033 1033
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1053 1053
 			$data['squawk'] = $line['squawk']; // squawk
1054 1054
 			$data['emergency'] = ''; // emergency
1055
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1055
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1056 1056
 			else $data['datetime'] = date('Y-m-d H:i:s');
1057 1057
 			$data['format_source'] = 'aircraftlistjson';
1058 1058
 			$data['id_source'] = $id_source;
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
     	    )
1074 1074
     	) {
1075 1075
 	    $buffer = $Common->getData($value['host']);
1076
-	    $all_data = json_decode($buffer,true);
1076
+	    $all_data = json_decode($buffer, true);
1077 1077
 	    if (isset($all_data['planes'])) {
1078 1078
 		$reset = 0;
1079 1079
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1090,12 +1090,12 @@  discard block
 block discarded – undo
1090 1090
 		    $data['emergency'] = ''; // emergency
1091 1091
 		    $data['registration'] = $line[2];
1092 1092
 		    $data['aircraft_icao'] = $line[0];
1093
-		    $deparr = explode('-',$line[1]);
1093
+		    $deparr = explode('-', $line[1]);
1094 1094
 		    if (count($deparr) === 2) {
1095 1095
 			$data['departure_airport_icao'] = $deparr[0];
1096 1096
 			$data['arrival_airport_icao'] = $deparr[1];
1097 1097
 		    }
1098
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1098
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1099 1099
 	    	    $data['format_source'] = 'planeupdatefaa';
1100 1100
     		    $data['id_source'] = $id_source;
1101 1101
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 	    )
1114 1114
 	) {
1115 1115
 	    $buffer = $Common->getData($value['host']);
1116
-	    $all_data = json_decode($buffer,true);
1116
+	    $all_data = json_decode($buffer, true);
1117 1117
 	    if (isset($all_data['states'])) {
1118 1118
 		$reset = 0;
1119 1119
 		foreach ($all_data['states'] as $key => $line) {
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 		    //$data['emergency'] = ''; // emergency
1131 1131
 		    //$data['registration'] = $line[2];
1132 1132
 		    //$data['aircraft_icao'] = $line[0];
1133
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1133
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1134 1134
 		    $data['format_source'] = 'opensky';
1135 1135
 		    $data['id_source'] = $id_source;
1136 1136
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1147,8 +1147,8 @@  discard block
 block discarded – undo
1147 1147
 	    )
1148 1148
 	) {
1149 1149
 	    $buffer = $Common->getData($value['host']);
1150
-	    $all_data = json_decode($buffer,true);
1151
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1150
+	    $all_data = json_decode($buffer, true);
1151
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1152 1152
 		$reset = 0;
1153 1153
 		foreach ($all_data['aircraft'] as $key => $line) {
1154 1154
 		    $data = array();
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 	    )
1187 1187
 	) {
1188 1188
 	    $buffer = $Common->getData($value['host']);
1189
-	    $all_data = json_decode($buffer,true);
1189
+	    $all_data = json_decode($buffer, true);
1190 1190
 	    if (isset($all_data['aircraft'])) {
1191 1191
 		$reset = 0;
1192 1192
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
 		    //$data['emergency'] = ''; // emergency
1204 1204
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1205 1205
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1206
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1206
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1207 1207
 		    $data['format_source'] = 'planefinderclient';
1208 1208
 		    $data['id_source'] = $id_source;
1209 1209
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 	) {
1223 1223
 	    //$buffer = $Common->getData($hosts[$id]);
1224 1224
 	    $buffer = $Common->getData($value['host']);
1225
-	    $all_data = json_decode($buffer,true);
1225
+	    $all_data = json_decode($buffer, true);
1226 1226
 	    if (!empty($all_data)) $reset = 0;
1227 1227
 	    foreach ($all_data as $key => $line) {
1228 1228
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1260,11 +1260,11 @@  discard block
 block discarded – undo
1260 1260
 	    )
1261 1261
 	) {
1262 1262
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1263
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1263
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1264 1264
 	    //echo $buffer;
1265
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1266
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1267
-	    $all_data = json_decode($buffer,true);
1265
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1266
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1267
+	    $all_data = json_decode($buffer, true);
1268 1268
 	    if (json_last_error() != JSON_ERROR_NONE) {
1269 1269
 		die(json_last_error_msg());
1270 1270
 	    }
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
 			//$data['departure_airport_iata'] = $line[11];
1288 1288
 			//$data['arrival_airport_iata'] = $line[12];
1289 1289
 	    		//$data['emergency'] = ''; // emergency
1290
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1290
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1291 1291
 	    		$data['format_source'] = 'radarvirtueljson';
1292 1292
     			$data['id_source'] = $id_source;
1293 1293
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1308,14 +1308,14 @@  discard block
 block discarded – undo
1308 1308
 	) {
1309 1309
 	    //$buffer = $Common->getData($hosts[$id]);
1310 1310
 	    $buffer = $Common->getData($value['host'].'?'.time());
1311
-	    $all_data = json_decode(utf8_encode($buffer),true);
1311
+	    $all_data = json_decode(utf8_encode($buffer), true);
1312 1312
 	    
1313 1313
 	    if (isset($all_data['pireps'])) {
1314 1314
 		$reset = 0;
1315 1315
 	        foreach ($all_data['pireps'] as $line) {
1316 1316
 		    $data = array();
1317 1317
 		    $data['id'] = $line['id'];
1318
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1318
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1319 1319
 		    $data['ident'] = $line['callsign']; // ident
1320 1320
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1321 1321
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1345,9 +1345,9 @@  discard block
 block discarded – undo
1345 1345
 			$SI->add($data);
1346 1346
 		    //    print_r($data);
1347 1347
     		    } elseif ($line['icon'] === 'ct') {
1348
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1349
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1350
-			$typec = substr($data['ident'],-3);
1348
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1349
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1350
+			$typec = substr($data['ident'], -3);
1351 1351
 			$data['type'] = '';
1352 1352
 			if ($typec === 'APP') $data['type'] = 'Approach';
1353 1353
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1359 1359
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1360 1360
 			else $data['type'] = 'Observer';
1361
-			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']);
1361
+			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']);
1362 1362
 		    }
1363 1363
 		    unset($data);
1364 1364
 		}
@@ -1375,14 +1375,14 @@  discard block
 block discarded – undo
1375 1375
 	    //$buffer = $Common->getData($hosts[$id]);
1376 1376
 	    if ($globalDebug) echo 'Get Data...'."\n";
1377 1377
 	    $buffer = $Common->getData($value['host']);
1378
-	    $all_data = json_decode($buffer,true);
1378
+	    $all_data = json_decode($buffer, true);
1379 1379
 	    if ($buffer != '' && is_array($all_data)) {
1380 1380
 		$reset = 0;
1381 1381
 		foreach ($all_data as $line) {
1382 1382
 	    	    $data = array();
1383 1383
 	    	    //$data['id'] = $line['id']; // id not usable
1384 1384
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1385
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1385
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1386 1386
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1387 1387
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1388 1388
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 	    	    //$data['datetime'] = $line['lastupdate'];
1398 1398
 	    	    //$data['last_update'] = $line['lastupdate'];
1399 1399
 	    	    if (isset($value['timezone'])) {
1400
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1400
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1401 1401
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1402 1402
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1403 1403
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1413,14 +1413,14 @@  discard block
 block discarded – undo
1413 1413
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1414 1414
 		    if (isset($line['aircraftname'])) {
1415 1415
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1416
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1417
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1416
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1417
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1418 1418
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1419 1419
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1420 1420
 	    		else {
1421
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1422
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1423
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1421
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1422
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1423
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1424 1424
 	    		}
1425 1425
 	    	    }
1426 1426
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
 	    //$buffer = $Common->getData($hosts[$id]);
1446 1446
 	    if ($globalDebug) echo 'Get Data...'."\n";
1447 1447
 	    $buffer = $Common->getData($value['host']);
1448
-	    $all_data = json_decode($buffer,true);
1448
+	    $all_data = json_decode($buffer, true);
1449 1449
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1450 1450
 		$reset = 0;
1451 1451
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457 1457
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1458 1458
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1459
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1459
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1460 1460
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1461 1461
 	    	    $data['altitude'] = $line['altitude']; // altitude
1462 1462
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
 	    	    //$data['squawk'] = ''; // squawk
1468 1468
 	    	    //$data['emergency'] = ''; // emergency
1469 1469
 	    	    if (isset($value['timezone'])) {
1470
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1470
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1471 1471
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1472 1472
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1473 1473
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1503,14 +1503,14 @@  discard block
 block discarded – undo
1503 1503
 	    //$buffer = $Common->getData($hosts[$id]);
1504 1504
 	    if ($globalDebug) echo 'Get Data...'."\n";
1505 1505
 	    $buffer = $Common->getData($value['host']);
1506
-	    $all_data = json_decode($buffer,true);
1506
+	    $all_data = json_decode($buffer, true);
1507 1507
 	    if ($buffer != '' && is_array($all_data)) {
1508 1508
 		$reset = 0;
1509 1509
 		foreach ($all_data as $line) {
1510 1510
 	    	    $data = array();
1511 1511
 	    	    //$data['id'] = $line['id']; // id not usable
1512 1512
 	    	    $data['id'] = trim($line['flight_id']);
1513
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1513
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1514 1514
 	    	    $data['pilot_name'] = $line['pilot_name'];
1515 1515
 	    	    $data['pilot_id'] = $line['pilot_id'];
1516 1516
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1554,24 +1554,24 @@  discard block
 block discarded – undo
1554 1554
 	    //$buffer = $Common->getData($hosts[$id]);
1555 1555
 	    if ($globalDebug) echo 'Get Data...'."\n";
1556 1556
 	    $buffer = $Common->getData($value['host']);
1557
-	    $all_data = json_decode($buffer,true);
1557
+	    $all_data = json_decode($buffer, true);
1558 1558
 	    if ($buffer != '') {
1559 1559
 		$Source->deleteLocationBySource('blitzortung');
1560
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1561
-		$buffer = explode('\n',$buffer);
1560
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1561
+		$buffer = explode('\n', $buffer);
1562 1562
 		foreach ($buffer as $buffer_line) {
1563
-		    $line = json_decode($buffer_line,true);
1563
+		    $line = json_decode($buffer_line, true);
1564 1564
 		    if (isset($line['time'])) {
1565 1565
 			$data = array();
1566 1566
 			$data['altitude'] = $line['alt']; // altitude
1567 1567
 			$data['latitude'] = $line['lat']; // lat
1568 1568
 			$data['longitude'] = $line['lon']; // long
1569
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1569
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1570 1570
 			$data['id_source'] = $id_source;
1571 1571
 			$data['format_source'] = 'blitzortung';
1572 1572
 			$SI->add($data);
1573 1573
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1574
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1574
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1575 1575
 			unset($data);
1576 1576
 		    }
1577 1577
 		}
@@ -1594,11 +1594,11 @@  discard block
 block discarded – undo
1594 1594
 		    //$value = $formats[$nb];
1595 1595
 		    $format = $globalSources[$nb]['format'];
1596 1596
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1597
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1597
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1598 1598
 		    } elseif ($format === 'vrstcp') {
1599 1599
 			$buffer = @socket_read($r, 6000);
1600 1600
 		    } else {
1601
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1601
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1602 1602
 		    }
1603 1603
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1604 1604
 		    //echo $buffer."\n";
@@ -1608,8 +1608,8 @@  discard block
 block discarded – undo
1608 1608
 		    //$SI::del();
1609 1609
 		    if ($buffer !== FALSE) {
1610 1610
 			if ($format === 'vrstcp') {
1611
-			    $buffer = explode('},{',$buffer);
1612
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1611
+			    $buffer = explode('},{', $buffer);
1612
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1613 1613
 		    }
1614 1614
 		    // SBS format is CSV format
1615 1615
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
 			    $ais_data = $AIS->parse_line(trim($buffer));
1634 1634
 			    $data = array();
1635 1635
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1636
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1636
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1637 1637
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1638 1638
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1639 1639
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1644,13 +1644,13 @@  discard block
 block discarded – undo
1644 1644
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1645 1645
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1646 1646
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1647
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1647
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1648 1648
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1649 1649
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650 1650
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1651 1651
 
1652 1652
 			    if (isset($ais_data['timestamp'])) {
1653
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1653
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1654 1654
 			    } else {
1655 1655
 				$data['datetime'] = date('Y-m-d H:i:s');
1656 1656
 			    }
@@ -1661,10 +1661,10 @@  discard block
 block discarded – undo
1661 1661
                         } elseif ($format === 'flightgearsp') {
1662 1662
                     	    //echo $buffer."\n";
1663 1663
                     	    if (strlen($buffer) > 5) {
1664
-				$line = explode(',',$buffer);
1664
+				$line = explode(',', $buffer);
1665 1665
 				$data = array();
1666 1666
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1667
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1667
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1668 1668
 				$data['ident'] = $line[6];
1669 1669
 				$data['aircraft_name'] = $line[7];
1670 1670
 				$data['longitude'] = $line[1];
@@ -1681,16 +1681,16 @@  discard block
 block discarded – undo
1681 1681
                         } elseif ($format === 'acars') {
1682 1682
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1683 1683
 			    $ACARS->add(trim($buffer));
1684
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1684
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1685 1685
 			    $ACARS->deleteLiveAcarsData();
1686 1686
 			} elseif ($format === 'flightgearmp') {
1687
-			    if (substr($buffer,0,1) != '#') {
1687
+			    if (substr($buffer, 0, 1) != '#') {
1688 1688
 				$data = array();
1689 1689
 				//echo $buffer."\n";
1690
-				$line = explode(' ',$buffer);
1690
+				$line = explode(' ', $buffer);
1691 1691
 				if (count($line) === 11) {
1692
-				    $userserver = explode('@',$line[0]);
1693
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1692
+				    $userserver = explode('@', $line[0]);
1693
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1694 1694
 				    $data['ident'] = $userserver[0];
1695 1695
 				    $data['registration'] = $userserver[0];
1696 1696
 				    $data['latitude'] = $line[4];
@@ -1698,8 +1698,8 @@  discard block
 block discarded – undo
1698 1698
 				    $data['altitude'] = $line[6];
1699 1699
 				    $data['datetime'] = date('Y-m-d H:i:s');
1700 1700
 				    $aircraft_type = $line[10];
1701
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1702
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1701
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1702
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1703 1703
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704 1704
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1705 1705
 				}
@@ -1708,8 +1708,8 @@  discard block
 block discarded – undo
1708 1708
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1709 1709
 			    die;
1710 1710
 			} elseif ($format === 'vrstcp') {
1711
-			    foreach($buffer as $all_data) {
1712
-				$line = json_decode('{'.$all_data.'}',true);
1711
+			    foreach ($buffer as $all_data) {
1712
+				$line = json_decode('{'.$all_data.'}', true);
1713 1713
 				$data = array();
1714 1714
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1715 1715
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1735,16 +1735,16 @@  discard block
 block discarded – undo
1735 1735
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1736 1736
 				unset($data);
1737 1737
 			    }
1738
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1738
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1739 1739
 			    $line = explode("\t", $buffer);
1740
-			    for($k = 0; $k < count($line); $k=$k+2) {
1740
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1741 1741
 				$key = $line[$k];
1742
-			        $lined[$key] = $line[$k+1];
1742
+			        $lined[$key] = $line[$k + 1];
1743 1743
 			    }
1744 1744
     			    if (count($lined) > 3) {
1745 1745
     				$data['hex'] = $lined['hexid'];
1746 1746
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1747
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1747
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1748 1748
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1749 1749
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1750 1750
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1763,23 +1763,23 @@  discard block
 block discarded – undo
1763 1763
     			    } else $error = true;
1764 1764
 			} elseif ($format === 'aprs' && $use_aprs) {
1765 1765
 			    if ($aprs_connect === 0) {
1766
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1766
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1767 1767
 				$aprs_connect = 1;
1768 1768
 			    }
1769 1769
 			    
1770
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1770
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1771 1771
 				$aprs_last_tx = time();
1772 1772
 				$data_aprs = "# Keep alive";
1773
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1773
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1774 1774
 			    }
1775 1775
 			    
1776 1776
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1777 1777
 			    //echo 'APRS data : '.$buffer."\n";
1778
-			    $buffer = str_replace('APRS <- ','',$buffer);
1779
-			    $buffer = str_replace('APRS -> ','',$buffer);
1778
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1779
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1780 1780
 			    //echo $buffer."\n";
1781 1781
 			    date_default_timezone_set('UTC');
1782
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1782
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1783 1783
 				$line = $APRS->parse($buffer);
1784 1784
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1785 1785
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1795 1795
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1796 1796
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1797
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1797
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1798 1798
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1799 1799
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1800 1800
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1882,29 +1882,29 @@  discard block
 block discarded – undo
1882 1882
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1883 1883
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1884 1884
 					$Source->deleteOldLocationByType('gs');
1885
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1886
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1885
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1886
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1887 1887
 					} else {
1888
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1888
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1889 1889
 					}
1890 1890
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1891 1891
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1892 1892
 					if ($globalDebug) echo '# Weather Station added'."\n";
1893 1893
 					$Source->deleteOldLocationByType('wx');
1894 1894
 					$weather_data = json_encode($line);
1895
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1896
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1895
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1896
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1897 1897
 					} else {
1898
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1898
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1899 1899
 					}
1900 1900
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1901 1901
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1902 1902
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1903 1903
 					$Source->deleteOldLocationByType('lightning');
1904
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1905
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1904
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1905
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1906 1906
 					} else {
1907
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1907
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1908 1908
 					}
1909 1909
 				    } elseif ($globalDebug) {
1910 1910
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 				    unset($data);
1914 1914
 				}
1915 1915
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1916
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1916
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1917 1917
 				}
1918 1918
 				/*
1919 1919
 				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')) {
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
 				*/
1923 1923
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1924 1924
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1925
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1925
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1926 1926
 					$Source->deleteOldLocationByType('lightning');
1927 1927
 					$Source->deleteOldLocationByType('wx');
1928 1928
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2008,7 +2008,7 @@  discard block
 block discarded – undo
2008 2008
 				connect_all($sourceee);
2009 2009
 				$sourceee = array();
2010 2010
 				//connect_all($globalSources);
2011
-				$tt[$format]=0;
2011
+				$tt[$format] = 0;
2012 2012
 				break;
2013 2013
 			    } 
2014 2014
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2018,14 +2018,14 @@  discard block
 block discarded – undo
2018 2018
 	    } else {
2019 2019
 		$error = socket_strerror(socket_last_error());
2020 2020
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2021
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2021
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2022 2022
 			if (isset($globalDebug)) echo "Restarting...\n";
2023 2023
 			// Restart the script if possible
2024 2024
 			if (is_array($sockets)) {
2025 2025
 			    if ($globalDebug) echo "Shutdown all sockets...";
2026 2026
 			    
2027 2027
 			    foreach ($sockets as $sock) {
2028
-				@socket_shutdown($sock,2);
2028
+				@socket_shutdown($sock, 2);
2029 2029
 				@socket_close($sock);
2030 2030
 			    }
2031 2031
 			    
Please login to merge, or discard this patch.
Braces   +1215 added lines, -408 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,32 +211,44 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftjson';
178 233
         	$globalSources[$id]['format'] = 'aircraftjson';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraft.json source (".$host.")...\n";
237
+        	}
181 238
     	    } else if (preg_match('/aircraft$/i',$host)) {
182 239
         	//$formats[$id] = 'planefinderclient';
183 240
         	$globalSources[$id]['format'] = 'planefinderclient';
184 241
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to planefinderclient source (".$host.")...\n";
244
+        	}
186 245
     	    } else if (preg_match('/opensky/i',$host)) {
187 246
         	//$formats[$id] = 'aircraftlistjson';
188 247
         	$globalSources[$id]['format'] = 'opensky';
189 248
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to opensky source (".$host.")...\n";
251
+        	}
191 252
     	    /*
192 253
     	    // Disabled for now, site change source format
193 254
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -204,7 +265,9 @@  discard block
 block discarded – undo
204 265
         	//$formats[$id] = 'planeupdatefaa';
205 266
         	$globalSources[$id]['format'] = 'planeupdatefaa';
206 267
         	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
270
+        	}
208 271
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209 272
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210 273
         	    exit(0);
@@ -213,37 +276,53 @@  discard block
 block discarded – undo
213 276
         	//$formats[$id] = 'phpvmacars';
214 277
         	$globalSources[$id]['format'] = 'phpvmacars';
215 278
         	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
279
+        	if ($globalDebug) {
280
+        		echo "Connect to phpvmacars source (".$host.")...\n";
281
+        	}
217 282
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218 283
         	//$formats[$id] = 'phpvmacars';
219 284
         	$globalSources[$id]['format'] = 'vaos';
220 285
         	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
286
+        	if ($globalDebug) {
287
+        		echo "Connect to vaos source (".$host.")...\n";
288
+        	}
222 289
             } else if (preg_match('/VAM-json.php$/i',$host)) {
223 290
         	//$formats[$id] = 'phpvmacars';
224 291
         	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
292
+        	if ($globalDebug) {
293
+        		echo "Connect to Vam source (".$host.")...\n";
294
+        	}
226 295
             } else if (preg_match('/whazzup/i',$host)) {
227 296
         	//$formats[$id] = 'whazzup';
228 297
         	$globalSources[$id]['format'] = 'whazzup';
229 298
         	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
299
+        	if ($globalDebug) {
300
+        		echo "Connect to whazzup source (".$host.")...\n";
301
+        	}
231 302
             } else if (preg_match('/blitzortung/i',$host)) {
232 303
         	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
304
+        	if ($globalDebug) {
305
+        		echo "Connect to blitzortung source (".$host.")...\n";
306
+        	}
234 307
             } else if (preg_match('/airwhere/i',$host)) {
235 308
         	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
309
+        	if ($globalDebug) {
310
+        		echo "Connect to airwhere source (".$host.")...\n";
311
+        	}
237 312
             } else if (preg_match('/recentpireps/i',$host)) {
238 313
         	//$formats[$id] = 'pirepsjson';
239 314
         	$globalSources[$id]['format'] = 'pirepsjson';
240 315
         	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to pirepsjson source (".$host.")...\n";
318
+        	}
242 319
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243 320
         	//$formats[$id] = 'fr24json';
244 321
         	$globalSources[$id]['format'] = 'fr24json';
245 322
         	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
323
+        	if ($globalDebug) {
324
+        		echo "Connect to fr24 source (".$host.")...\n";
325
+        	}
247 326
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248 327
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249 328
         	    exit(0);
@@ -252,7 +331,9 @@  discard block
 block discarded – undo
252 331
         	//$formats[$id] = 'fr24json';
253 332
         	$globalSources[$id]['format'] = 'myshiptracking';
254 333
         	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
334
+        	if ($globalDebug) {
335
+        		echo "Connect to myshiptracking source (".$host.")...\n";
336
+        	}
256 337
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257 338
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 339
         	    exit(0);
@@ -261,17 +342,26 @@  discard block
 block discarded – undo
261 342
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262 343
         	//$formats[$id] = 'tsv';
263 344
         	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
345
+        	if ($globalDebug) {
346
+        		echo "Connect to tsv source (".$host.")...\n";
347
+        	}
265 348
             }
266 349
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267 350
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268 351
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269 352
     		    if ($idf !== false) {
270 353
     			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
354
+        		if ($globalDebug) {
355
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
356
+        		}
357
+    		    } elseif ($globalDebug) {
358
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
359
+    		    }
360
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
361
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
362
+    		} elseif ($globalDebug) {
363
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
364
+    		}
275 365
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276 366
 	    $hostport = explode(':',$host);
277 367
 	    if (isset($hostport[1])) {
@@ -311,19 +401,27 @@  discard block
 block discarded – undo
311 401
         		//$formats[$id] = 'beast';
312 402
         		$globalSources[$id]['format'] = 'beast';
313 403
 		    //} else $formats[$id] = 'sbs';
314
-		    } else $globalSources[$id]['format'] = 'sbs';
404
+		    } else {
405
+		    	$globalSources[$id]['format'] = 'sbs';
406
+		    }
315 407
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
316 408
 		}
317
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
409
+		if ($globalDebug) {
410
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
411
+		}
318 412
             } else {
319
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
413
+		if ($globalDebug) {
414
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
415
+		}
320 416
 		sleep(10);
321 417
 		connect_all($hosts);
322 418
     	    }
323 419
         }
324 420
     }
325 421
 }
326
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
422
+if (!isset($globalMinFetch)) {
423
+	$globalMinFetch = 15;
424
+}
327 425
 
328 426
 // Initialize all
329 427
 $status = array();
@@ -332,13 +430,19 @@  discard block
 block discarded – undo
332 430
 $formats = array();
333 431
 $last_exec = array();
334 432
 $time = time();
335
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
336
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
337
-else $timeout = 20;
433
+if (isset($globalSourcesTimeout)) {
434
+	$timeout = $globalSourcesTimeOut;
435
+} else if (isset($globalSBS1TimeOut)) {
436
+	$timeout = $globalSBS1TimeOut;
437
+} else {
438
+	$timeout = 20;
439
+}
338 440
 $errno = '';
339 441
 $errstr='';
340 442
 
341
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
443
+if (!isset($globalDaemon)) {
444
+	$globalDaemon = TRUE;
445
+}
342 446
 /* Initiate connections to all the hosts simultaneously */
343 447
 //connect_all($hosts);
344 448
 //connect_all($globalSources);
@@ -367,7 +471,9 @@  discard block
 block discarded – undo
367 471
     if (isset($source['format']) && $source['format'] == 'aprs') {
368 472
 	$aprs_connect = 0;
369 473
 	$use_aprs = true;
370
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
474
+	if (isset($source['port']) && $source['port'] == '10152') {
475
+		$aprs_full = true;
476
+	}
371 477
 	break;
372 478
     }
373 479
 }
@@ -378,25 +484,46 @@  discard block
 block discarded – undo
378 484
 	$aprs_connect = 0;
379 485
 	$aprs_keep = 120;
380 486
 	$aprs_last_tx = time();
381
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
382
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
383
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
384
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
385
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
386
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
387
-	if ($aprs_full) $aprs_filter = '';
388
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
389
-	else $aprs_pass = '-1';
487
+	if (isset($globalAPRSversion)) {
488
+		$aprs_version = $globalAPRSversion;
489
+	} else {
490
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
491
+	}
492
+	if (isset($globalAPRSssid)) {
493
+		$aprs_ssid = $globalAPRSssid;
494
+	} else {
495
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
496
+	}
497
+	if (isset($globalAPRSfilter)) {
498
+		$aprs_filter = $globalAPRSfilter;
499
+	} else {
500
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
501
+	}
502
+	if ($aprs_full) {
503
+		$aprs_filter = '';
504
+	}
505
+	if (isset($globalAPRSpass)) {
506
+		$aprs_pass = $globalAPRSpass;
507
+	} else {
508
+		$aprs_pass = '-1';
509
+	}
390 510
 
391
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
392
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
393
-}
511
+	if ($aprs_filter != '') {
512
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
513
+	} else {
514
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
515
+	}
516
+	}
394 517
 
395 518
 // connected - lets do some work
396 519
 //if ($globalDebug) echo "Connected!\n";
397 520
 sleep(1);
398
-if ($globalDebug) echo "SCAN MODE \n\n";
399
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
521
+if ($globalDebug) {
522
+	echo "SCAN MODE \n\n";
523
+}
524
+if (!isset($globalCronEnd)) {
525
+	$globalCronEnd = 60;
526
+}
400 527
 $endtime = time()+$globalCronEnd;
401 528
 $i = 1;
402 529
 $tt = array();
@@ -410,22 +537,32 @@  discard block
 block discarded – undo
410 537
 
411 538
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
412 539
 while ($i > 0) {
413
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
540
+    if (function_exists('pcntl_fork')) {
541
+    	pcntl_signal_dispatch();
542
+    }
414 543
 
415
-    if (!$globalDaemon) $i = $endtime-time();
544
+    if (!$globalDaemon) {
545
+    	$i = $endtime-time();
546
+    }
416 547
     // Delete old ATC
417 548
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
418
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
549
+	if ($globalDebug) {
550
+		echo 'Delete old ATC...'."\n";
551
+	}
419 552
         $ATC->deleteOldATC();
420 553
     }
421 554
     
422 555
     if (count($last_exec) == count($globalSources)) {
423 556
 	$max = $globalMinFetch;
424 557
 	foreach ($last_exec as $last) {
425
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
558
+	    if ((time() - $last['last']) < $max) {
559
+	    	$max = time() - $last['last'];
560
+	    }
426 561
 	}
427 562
 	if ($max < $globalMinFetch) {
428
-	    if ($globalDebug) echo 'Sleeping...'."\n";
563
+	    if ($globalDebug) {
564
+	    	echo 'Sleeping...'."\n";
565
+	    }
429 566
 	    sleep($globalMinFetch-$max+2);
430 567
 	}
431 568
     }
@@ -435,7 +572,9 @@  discard block
 block discarded – undo
435 572
     foreach ($globalSources as $id => $value) {
436 573
 	date_default_timezone_set('UTC');
437 574
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
438
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
575
+	if (!isset($last_exec[$id]['last'])) {
576
+		$last_exec[$id]['last'] = 0;
577
+	}
439 578
 	if ($value['format'] === 'deltadbtxt' && 
440 579
 	    (
441 580
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -444,7 +583,9 @@  discard block
 block discarded – undo
444 583
 	) {
445 584
 	    //$buffer = $Common->getData($hosts[$id]);
446 585
 	    $buffer = $Common->getData($value['host']);
447
-	    if ($buffer != '') $reset = 0;
586
+	    if ($buffer != '') {
587
+	    	$reset = 0;
588
+	    }
448 589
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449 590
 	    $buffer = explode('\n',$buffer);
450 591
 	    foreach ($buffer as $line) {
@@ -453,20 +594,41 @@  discard block
 block discarded – undo
453 594
 	            $data = array();
454 595
 	            $data['hex'] = $line[1]; // hex
455 596
 	            $data['ident'] = $line[2]; // ident
456
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
597
+	            if (isset($line[3])) {
598
+	            	$data['altitude'] = $line[3];
599
+	            }
600
+	            // altitude
601
+	            if (isset($line[4])) {
602
+	            	$data['speed'] = $line[4];
603
+	            }
604
+	            // speed
605
+	            if (isset($line[5])) {
606
+	            	$data['heading'] = $line[5];
607
+	            }
608
+	            // heading
609
+	            if (isset($line[6])) {
610
+	            	$data['latitude'] = $line[6];
611
+	            }
612
+	            // lat
613
+	            if (isset($line[7])) {
614
+	            	$data['longitude'] = $line[7];
615
+	            }
616
+	            // long
461 617
 	            $data['verticalrate'] = ''; // vertical rate
462 618
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463 619
 	            $data['emergency'] = ''; // emergency
464 620
 		    $data['datetime'] = date('Y-m-d H:i:s');
465 621
 		    $data['format_source'] = 'deltadbtxt';
466 622
     		    $data['id_source'] = $id_source;
467
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
623
+		    if (isset($value['name']) && $value['name'] != '') {
624
+		    	$data['source_name'] = $value['name'];
625
+		    }
626
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
627
+		    	$data['noarchive'] = true;
628
+		    }
629
+		    if (isset($value['sourcestats'])) {
630
+		    	$data['sourcestats'] = $value['sourcestats'];
631
+		    }
470 632
     		    $SI->add($data);
471 633
 		    unset($data);
472 634
     		}
@@ -481,7 +643,9 @@  discard block
 block discarded – undo
481 643
 	    date_default_timezone_set('CET');
482 644
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483 645
 	    date_default_timezone_set('UTC');
484
-	    if ($buffer != '') $reset = 0;
646
+	    if ($buffer != '') {
647
+	    	$reset = 0;
648
+	    }
485 649
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486 650
 	    $buffer = explode('\n',$buffer);
487 651
 	    foreach ($buffer as $line) {
@@ -490,18 +654,42 @@  discard block
 block discarded – undo
490 654
 		    $add = false;
491 655
 		    $ais_data = $AIS->parse_line(trim($line));
492 656
 		    $data = array();
493
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
657
+		    if (isset($ais_data['ident'])) {
658
+		    	$data['ident'] = $ais_data['ident'];
659
+		    }
660
+		    if (isset($ais_data['mmsi'])) {
661
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
662
+		    }
663
+		    if (isset($ais_data['speed'])) {
664
+		    	$data['speed'] = $ais_data['speed'];
665
+		    }
666
+		    if (isset($ais_data['heading'])) {
667
+		    	$data['heading'] = $ais_data['heading'];
668
+		    }
669
+		    if (isset($ais_data['latitude'])) {
670
+		    	$data['latitude'] = $ais_data['latitude'];
671
+		    }
672
+		    if (isset($ais_data['longitude'])) {
673
+		    	$data['longitude'] = $ais_data['longitude'];
674
+		    }
675
+		    if (isset($ais_data['status'])) {
676
+		    	$data['status'] = $ais_data['status'];
677
+		    }
678
+		    if (isset($ais_data['statusid'])) {
679
+		    	$data['status_id'] = $ais_data['statusid'];
680
+		    }
681
+		    if (isset($ais_data['type'])) {
682
+		    	$data['type'] = $ais_data['type'];
683
+		    }
684
+		    if (isset($ais_data['typeid'])) {
685
+		    	$data['type_id'] = $ais_data['typeid'];
686
+		    }
687
+		    if (isset($ais_data['imo'])) {
688
+		    	$data['imo'] = $ais_data['imo'];
689
+		    }
690
+		    if (isset($ais_data['callsign'])) {
691
+		    	$data['callsign'] = $ais_data['callsign'];
692
+		    }
505 693
 		    if (isset($ais_data['timestamp'])) {
506 694
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
507 695
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -515,8 +703,12 @@  discard block
 block discarded – undo
515 703
 		    $data['format_source'] = 'aisnmeatxt';
516 704
     		    $data['id_source'] = $id_source;
517 705
 		    //print_r($data);
518
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
706
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
707
+		    	$data['noarchive'] = true;
708
+		    }
709
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
710
+		    	$MI->add($data);
711
+		    }
520 712
 		    unset($data);
521 713
 		}
522 714
     	    }
@@ -539,20 +731,48 @@  discard block
 block discarded – undo
539 731
 			    if ($line != '') {
540 732
 				$ais_data = $AIS->parse_line(trim($line));
541 733
 				$data = array();
542
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
543
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
544
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
545
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
546
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
547
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
548
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
549
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
550
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
551
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
552
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
553
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
554
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
555
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
734
+				if (isset($ais_data['ident'])) {
735
+					$data['ident'] = $ais_data['ident'];
736
+				}
737
+				if (isset($ais_data['mmsi'])) {
738
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
739
+				}
740
+				if (isset($ais_data['speed'])) {
741
+					$data['speed'] = $ais_data['speed'];
742
+				}
743
+				if (isset($ais_data['heading'])) {
744
+					$data['heading'] = $ais_data['heading'];
745
+				}
746
+				if (isset($ais_data['latitude'])) {
747
+					$data['latitude'] = $ais_data['latitude'];
748
+				}
749
+				if (isset($ais_data['longitude'])) {
750
+					$data['longitude'] = $ais_data['longitude'];
751
+				}
752
+				if (isset($ais_data['status'])) {
753
+					$data['status'] = $ais_data['status'];
754
+				}
755
+				if (isset($ais_data['statusid'])) {
756
+					$data['status_id'] = $ais_data['statusid'];
757
+				}
758
+				if (isset($ais_data['type'])) {
759
+					$data['type'] = $ais_data['type'];
760
+				}
761
+				if (isset($ais_data['typeid'])) {
762
+					$data['type_id'] = $ais_data['typeid'];
763
+				}
764
+				if (isset($ais_data['imo'])) {
765
+					$data['imo'] = $ais_data['imo'];
766
+				}
767
+				if (isset($ais_data['callsign'])) {
768
+					$data['callsign'] = $ais_data['callsign'];
769
+				}
770
+				if (isset($ais_data['destination'])) {
771
+					$data['arrival_code'] = $ais_data['destination'];
772
+				}
773
+				if (isset($ais_data['eta_ts'])) {
774
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
775
+				}
556 776
 				if (isset($ais_data['timestamp'])) {
557 777
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558 778
 				} else {
@@ -560,18 +780,27 @@  discard block
 block discarded – undo
560 780
 				}
561 781
 				$data['format_source'] = 'aisnmeahttp';
562 782
 				$data['id_source'] = $id_source;
563
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
564
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
783
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
784
+					$data['noarchive'] = true;
785
+				}
786
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
787
+					$MI->add($data);
788
+				}
565 789
 				unset($data);
566 790
 			    }
567 791
 			}
568 792
 		    }
569 793
 		} else {
570 794
 		    $format = $value['format'];
571
-		    if (isset($tt[$format])) $tt[$format]++;
572
-		    else $tt[$format] = 0;
795
+		    if (isset($tt[$format])) {
796
+		    	$tt[$format]++;
797
+		    } else {
798
+		    	$tt[$format] = 0;
799
+		    }
573 800
 		    if ($tt[$format] > 30) {
574
-			if ($globalDebug) echo 'Reconnect...'."\n";
801
+			if ($globalDebug) {
802
+				echo 'Reconnect...'."\n";
803
+			}
575 804
 			sleep(2);
576 805
 			//$sourceeen[] = $value;
577 806
 			//connect_all($sourceeen);
@@ -607,12 +836,18 @@  discard block
 block discarded – undo
607 836
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608 837
 			    //$data['type_id'] = $line['TYPE'];
609 838
 			    $data['imo'] = $line['IMO'];
610
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
839
+			    if ($line['DEST'] != '') {
840
+			    	$data['arrival_code'] = $line['DEST'];
841
+			    }
842
+			    if ($line['ARV'] != '') {
843
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
844
+			    }
612 845
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613 846
 			    $data['format_source'] = 'myshiptracking';
614 847
 			    $data['id_source'] = $id_source;
615
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
848
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
849
+			    	$data['noarchive'] = true;
850
+			    }
616 851
 			    $MI->add($data);
617 852
 			    unset($data);
618 853
 			}
@@ -637,7 +872,9 @@  discard block
 block discarded – undo
637 872
 			    $data['callsign'] = $line['callsign'];
638 873
 			    $data['mmsi'] = substr($line['mmsi'],-9);
639 874
 			    $data['speed'] = $line['sog'];
640
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
875
+			    if ($line['heading'] != '511') {
876
+			    	$data['heading'] = $line['heading'];
877
+			    }
641 878
 			    $data['latitude'] = $line['latitude'];
642 879
 			    $data['longitude'] = $line['longitude'];
643 880
 			    $data['type_id'] = $line['shiptype'];
@@ -645,7 +882,9 @@  discard block
 block discarded – undo
645 882
 			    $data['datetime'] = $line['time'];
646 883
 			    $data['format_source'] = 'boatbeaconapp';
647 884
 			    $data['id_source'] = $id_source;
648
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
885
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
886
+			    	$data['noarchive'] = true;
887
+			    }
649 888
 			    $MI->add($data);
650 889
 			    unset($data);
651 890
 			}
@@ -667,22 +906,44 @@  discard block
 block discarded – undo
667 906
 		    foreach ($all_data['features'] as $line) {
668 907
 			print_r($line);
669 908
 			$data = array();
670
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
671
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
672
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
673
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
674
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
675
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
909
+			if (isset($line['properties']['name'])) {
910
+				$data['ident'] = $line['properties']['name'];
911
+			}
912
+			if (isset($line['properties']['callsign'])) {
913
+				$data['callsign'] = $line['properties']['callsign'];
914
+			}
915
+			if (isset($line['properties']['mmsi'])) {
916
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
917
+			}
918
+			if (isset($line['properties']['imo'])) {
919
+				$data['imo'] = $line['properties']['imo'];
920
+			}
921
+			if (isset($line['properties']['speed'])) {
922
+				$data['speed'] = $line['properties']['speed'];
923
+			}
924
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
925
+				$data['heading'] = $line['properties']['heading'];
926
+			}
676 927
 			$data['latitude'] = $line['geometry']['coordinates'][1];
677 928
 			$data['longitude'] = $line['geometry']['coordinates'][0];
678
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
679
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
680
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
929
+			if (isset($line['properties']['vesselType'])) {
930
+				$data['type'] = $line['properties']['vesselType'];
931
+			}
932
+			if (isset($line['properties']['destination'])) {
933
+				$data['arrival_code'] = $line['properties']['destination'];
934
+			}
935
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
936
+				$data['arrival_date'] = $line['properties']['eta'];
937
+			}
681 938
 			$data['format_source'] = 'boatnerd';
682 939
 			$data['id_source'] = $id_source;
683 940
 			$data['datetime'] = date('Y-m-d H:i:s');
684
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
685
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
941
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
942
+				$data['noarchive'] = true;
943
+			}
944
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
945
+				$MI->add($data);
946
+			}
686 947
 			unset($data);
687 948
 		    }
688 949
 		}
@@ -695,11 +956,17 @@  discard block
 block discarded – undo
695 956
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
696 957
 	    )
697 958
 	) {
698
-	    if ($globalDebug) echo 'download...';
959
+	    if ($globalDebug) {
960
+	    	echo 'download...';
961
+	    }
699 962
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
-	    if ($globalDebug) echo 'done !'."\n";
963
+	    if ($globalDebug) {
964
+	    	echo 'done !'."\n";
965
+	    }
701 966
 	    // FIXME: Need more work
702
-	    if ($buffer != '') $reset = 0;
967
+	    if ($buffer != '') {
968
+	    	$reset = 0;
969
+	    }
703 970
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704 971
 	    $buffer = explode('\n',$buffer);
705 972
 	    foreach ($buffer as $line) {
@@ -725,7 +992,9 @@  discard block
 block discarded – undo
725 992
 		    //$data['etaTime'] = substr($line,135,5);
726 993
 		    $data['format_source'] = 'shipplotter';
727 994
     		    $data['id_source'] = $id_source;
728
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
995
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
996
+		    	$data['noarchive'] = true;
997
+		    }
729 998
 		    //print_r($data);
730 999
 		    //echo 'Add...'."\n";
731 1000
 		    $MI->add($data);
@@ -748,11 +1017,17 @@  discard block
 block discarded – undo
748 1017
 		}
749 1018
 	    }
750 1019
 
751
-	    if ($globalDebug) echo '! Download... ';
1020
+	    if ($globalDebug) {
1021
+	    	echo '! Download... ';
1022
+	    }
752 1023
 	    for ($i =0; $i <= 1; $i++) {
753
-		if ($globalDebug) echo 'Racetype: '.$i.' ';
1024
+		if ($globalDebug) {
1025
+			echo 'Racetype: '.$i.' ';
1026
+		}
754 1027
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
755
-	    if ($globalDebug) echo 'done'."\n";
1028
+	    if ($globalDebug) {
1029
+	    	echo 'done'."\n";
1030
+	    }
756 1031
 	    if ($buffer != '') {
757 1032
 		$all_data = json_decode($buffer,true);
758 1033
 		if (isset($all_data['missions'])) {
@@ -760,8 +1035,11 @@  discard block
 block discarded – undo
760 1035
 				$mission_user = $mission['usrname'];
761 1036
 				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
762 1037
 				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
763
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
764
-					else $racebuffer = '';
1038
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
1039
+						$racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
1040
+					} else {
1041
+						$racebuffer = '';
1042
+					}
765 1043
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
766 1044
 				} else {
767 1045
 					$bufferm = '';
@@ -825,7 +1103,9 @@  discard block
 block discarded – undo
825 1103
 								$data['captain_id'] = $sail['usrnr'];
826 1104
 								$data['captain_name'] = $sail['usrname'];
827 1105
 								$data['race_id'] = $sail['misnr'];
828
-								if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank'];
1106
+								if ($sail['rank'] != 'DNF') {
1107
+									$data['race_rank'] = $sail['rank'];
1108
+								}
829 1109
 								$data['race_time'] = $sail['racetime'];
830 1110
 								if ($mission_user != '') {
831 1111
 									$data['race_name'] = $mission_name.' ('.$mission_user.')';
@@ -835,7 +1115,9 @@  discard block
 block discarded – undo
835 1115
 								//$data['callsign'] = trim(substr($line,100,7);
836 1116
 								$data['format_source'] = 'sailaway';
837 1117
 								$data['id_source'] = $id_source;
838
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1118
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1119
+									$data['noarchive'] = true;
1120
+								}
839 1121
 								//print_r($data);
840 1122
 								//echo 'Add...'."\n";
841 1123
 								$MI->add($data);
@@ -876,16 +1158,28 @@  discard block
 block discarded – undo
876 1158
     		    $line = explode(':', $line);
877 1159
     		    if (count($line) > 30 && $line[0] != 'callsign') {
878 1160
 			$data = array();
879
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
880
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1161
+			if (isset($line[37]) && $line[37] != '') {
1162
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1163
+			} else {
1164
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1165
+			}
881 1166
 			$data['pilot_id'] = $line[1];
882 1167
 			$data['pilot_name'] = $line[2];
883 1168
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
884 1169
 			$data['ident'] = $line[0]; // ident
885
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1170
+			if ($line[7] != '' && $line[7] != 0) {
1171
+				$data['altitude'] = $line[7];
1172
+			}
1173
+			// altitude
886 1174
 			$data['speed'] = $line[8]; // speed
887
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
888
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1175
+			if (isset($line[45])) {
1176
+				$data['heading'] = $line[45];
1177
+			}
1178
+			// heading
1179
+			elseif (isset($line[38])) {
1180
+				$data['heading'] = $line[38];
1181
+			}
1182
+			// heading
889 1183
 			$data['latitude'] = $line[5]; // lat
890 1184
 	        	$data['longitude'] = $line[6]; // long
891 1185
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -901,7 +1195,9 @@  discard block
 block discarded – undo
901 1195
 			$data['frequency'] = $line[4];
902 1196
 			$data['type'] = $line[18];
903 1197
 			$data['range'] = $line[19];
904
-			if (isset($line[35])) $data['info'] = $line[35];
1198
+			if (isset($line[35])) {
1199
+				$data['info'] = $line[35];
1200
+			}
905 1201
     			$data['id_source'] = $id_source;
906 1202
 	    		//$data['arrival_airport_time'] = ;
907 1203
 	    		if ($line[9] != '') {
@@ -915,27 +1211,47 @@  discard block
 block discarded – undo
915 1211
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
916 1212
 	    		*/
917 1213
 	    		$data['format_source'] = $value['format'];
918
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
-    			if ($line[3] === 'PILOT') $SI->add($data);
921
-			elseif ($line[3] === 'ATC') {
1214
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1215
+				$data['noarchive'] = true;
1216
+			}
1217
+			if (isset($value['name']) && $value['name'] != '') {
1218
+				$data['source_name'] = $value['name'];
1219
+			}
1220
+    			if ($line[3] === 'PILOT') {
1221
+    				$SI->add($data);
1222
+    			} elseif ($line[3] === 'ATC') {
922 1223
 				//print_r($data);
923 1224
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
924 1225
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
925 1226
 				$typec = substr($data['ident'],-3);
926
-				if ($typec === 'APP') $data['type'] = 'Approach';
927
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
928
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
929
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
930
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
931
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
932
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
933
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
934
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
935
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1227
+				if ($typec === 'APP') {
1228
+					$data['type'] = 'Approach';
1229
+				} elseif ($typec === 'TWR') {
1230
+					$data['type'] = 'Tower';
1231
+				} elseif ($typec === 'OBS') {
1232
+					$data['type'] = 'Observer';
1233
+				} elseif ($typec === 'GND') {
1234
+					$data['type'] = 'Ground';
1235
+				} elseif ($typec === 'DEL') {
1236
+					$data['type'] = 'Delivery';
1237
+				} elseif ($typec === 'DEP') {
1238
+					$data['type'] = 'Departure';
1239
+				} elseif ($typec === 'FSS') {
1240
+					$data['type'] = 'Flight Service Station';
1241
+				} elseif ($typec === 'CTR') {
1242
+					$data['type'] = 'Control Radar or Centre';
1243
+				} elseif ($data['type'] === '') {
1244
+					$data['type'] = 'Observer';
1245
+				}
1246
+				if (!isset($data['source_name'])) {
1247
+					$data['source_name'] = '';
1248
+				}
936 1249
 				if (isset($ATC)) {
937
-					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']);
938
-					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']);
1250
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1251
+						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']);
1252
+					} else {
1253
+						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']);
1254
+					}
939 1255
 				}
940 1256
 			}
941 1257
     			unset($data);
@@ -962,14 +1278,20 @@  discard block
 block discarded – undo
962 1278
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
963 1279
 			$data['latitude'] = (float)$line['pktLatitude'];
964 1280
 			$data['longitude'] = (float)$line['pktLongitude'];
965
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
966
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1281
+			if ((float)$line['pktTrack'] != 0) {
1282
+				$data['heading'] = (float)$line['pktTrack'];
1283
+			}
1284
+			if ((int)$line['pktSpeed'] != 0) {
1285
+				$data['speed'] = (int)$line['pktSpeed'];
1286
+			}
967 1287
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
968 1288
 			$data['altitude_relative'] = 'AMSL';
969 1289
 			$data['pilot_id'] = (int)$line['pktPilotID'];
970 1290
 			$data['aircraft_icao'] = 'PARAGLIDER';
971 1291
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
972
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1292
+			if (isset($pilot_data[4])) {
1293
+				$data['pilot_name'] = $pilot_data[4];
1294
+			}
973 1295
 			$data['format_source'] = $value['format'];
974 1296
 			$SI->add($data);
975 1297
 			unset($data);
@@ -1017,25 +1339,59 @@  discard block
 block discarded – undo
1017 1339
 		    foreach ($all_data['acList'] as $line) {
1018 1340
 			$data = array();
1019 1341
 			$data['hex'] = $line['Icao']; // hex
1020
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1021
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1022
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1023
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1024
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1025
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1342
+			if (isset($line['Call'])) {
1343
+				$data['ident'] = $line['Call'];
1344
+			}
1345
+			// ident
1346
+			if (isset($line['Alt'])) {
1347
+				$data['altitude'] = $line['Alt'];
1348
+			}
1349
+			// altitude
1350
+			if (isset($line['Spd'])) {
1351
+				$data['speed'] = $line['Spd'];
1352
+			}
1353
+			// speed
1354
+			if (isset($line['Trak'])) {
1355
+				$data['heading'] = $line['Trak'];
1356
+			}
1357
+			// heading
1358
+			if (isset($line['Lat'])) {
1359
+				$data['latitude'] = $line['Lat'];
1360
+			}
1361
+			// lat
1362
+			if (isset($line['Long'])) {
1363
+				$data['longitude'] = $line['Long'];
1364
+			}
1365
+			// long
1026 1366
 			//$data['verticalrate'] = $line['']; // verticale rate
1027
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1367
+			if (isset($line['Sqk'])) {
1368
+				$data['squawk'] = $line['Sqk'];
1369
+			}
1370
+			// squawk
1028 1371
 			$data['emergency'] = ''; // emergency
1029
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1030
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1031
-			else $data['datetime'] = date('Y-m-d H:i:s');
1372
+			if (isset($line['Reg'])) {
1373
+				$data['registration'] = $line['Reg'];
1374
+			}
1375
+			if (isset($line['PosTime'])) {
1376
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1377
+			} else {
1378
+				$data['datetime'] = date('Y-m-d H:i:s');
1379
+			}
1032 1380
 			//$data['datetime'] = date('Y-m-d H:i:s');
1033
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1381
+			if (isset($line['Type'])) {
1382
+				$data['aircraft_icao'] = $line['Type'];
1383
+			}
1034 1384
 			$data['format_source'] = 'aircraftlistjson';
1035 1385
 			$data['id_source'] = $id_source;
1036
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1037
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1038
-			if (isset($data['latitude'])) $SI->add($data);
1386
+			if (isset($value['name']) && $value['name'] != '') {
1387
+				$data['source_name'] = $value['name'];
1388
+			}
1389
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1390
+				$data['noarchive'] = true;
1391
+			}
1392
+			if (isset($data['latitude'])) {
1393
+				$SI->add($data);
1394
+			}
1039 1395
 			unset($data);
1040 1396
 		    }
1041 1397
 		} elseif (is_array($all_data)) {
@@ -1052,17 +1408,26 @@  discard block
 block discarded – undo
1052 1408
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1053 1409
 			$data['squawk'] = $line['squawk']; // squawk
1054 1410
 			$data['emergency'] = ''; // emergency
1055
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1056
-			else $data['datetime'] = date('Y-m-d H:i:s');
1411
+			if (isset($line['PosTime'])) {
1412
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1413
+			} else {
1414
+				$data['datetime'] = date('Y-m-d H:i:s');
1415
+			}
1057 1416
 			$data['format_source'] = 'aircraftlistjson';
1058 1417
 			$data['id_source'] = $id_source;
1059
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1060
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1418
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1419
+				$data['noarchive'] = true;
1420
+			}
1421
+			if (isset($value['name']) && $value['name'] != '') {
1422
+				$data['source_name'] = $value['name'];
1423
+			}
1061 1424
 			$SI->add($data);
1062 1425
 			unset($data);
1063 1426
 		    }
1064 1427
 		}
1065
-	    } elseif ($globalDebug) echo 'No data'."\n";
1428
+	    } elseif ($globalDebug) {
1429
+	    	echo 'No data'."\n";
1430
+	    }
1066 1431
     	    //$last_exec['aircraftlistjson'] = time();
1067 1432
     	    $last_exec[$id]['last'] = time();
1068 1433
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1098,8 +1463,12 @@  discard block
 block discarded – undo
1098 1463
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1099 1464
 	    	    $data['format_source'] = 'planeupdatefaa';
1100 1465
     		    $data['id_source'] = $id_source;
1101
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1102
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1466
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1467
+		    	$data['noarchive'] = true;
1468
+		    }
1469
+		    if (isset($value['name']) && $value['name'] != '') {
1470
+		    	$data['source_name'] = $value['name'];
1471
+		    }
1103 1472
 		    $SI->add($data);
1104 1473
 		    unset($data);
1105 1474
 		}
@@ -1133,7 +1502,9 @@  discard block
 block discarded – undo
1133 1502
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1134 1503
 		    $data['format_source'] = 'opensky';
1135 1504
 		    $data['id_source'] = $id_source;
1136
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1505
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1506
+		    	$data['noarchive'] = true;
1507
+		    }
1137 1508
 		    $SI->add($data);
1138 1509
 		    unset($data);
1139 1510
 		}
@@ -1153,15 +1524,42 @@  discard block
 block discarded – undo
1153 1524
 		foreach ($all_data['aircraft'] as $key => $line) {
1154 1525
 		    $data = array();
1155 1526
 		    // add support for ground vehicule with ~ in front of hex
1156
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1157
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1158
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1159
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1160
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1161
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1162
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1163
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1164
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1527
+		    if (isset($line['hex'])) {
1528
+		    	$data['hex'] = $line['hex'];
1529
+		    }
1530
+		    // hex
1531
+		    if (isset($line['flight'])) {
1532
+		    	$data['ident'] = trim($line['flight']);
1533
+		    }
1534
+		    // ident
1535
+		    if (isset($line['altitude'])) {
1536
+		    	$data['altitude'] = $line['altitude'];
1537
+		    }
1538
+		    // altitude
1539
+		    if (isset($line['speed'])) {
1540
+		    	$data['speed'] = $line['speed'];
1541
+		    }
1542
+		    // speed
1543
+		    if (isset($line['track'])) {
1544
+		    	$data['heading'] = $line['track'];
1545
+		    }
1546
+		    // heading
1547
+		    if (isset($line['lat'])) {
1548
+		    	$data['latitude'] = $line['lat'];
1549
+		    }
1550
+		    // lat
1551
+		    if (isset($line['lon'])) {
1552
+		    	$data['longitude'] = $line['lon'];
1553
+		    }
1554
+		    // long
1555
+		    if (isset($line['vert_rate'])) {
1556
+		    	$data['verticalrate'] = $line['vert_rate'];
1557
+		    }
1558
+		    // verticale rate
1559
+		    if (isset($line['squawk'])) {
1560
+		    	$data['squawk'] = $line['squawk'];
1561
+		    }
1562
+		    // squawk
1165 1563
 		    //$data['emergency'] = ''; // emergency
1166 1564
 		    //$data['registration'] = $line[2];
1167 1565
 		    //$data['aircraft_icao'] = $line[0];
@@ -1169,10 +1567,17 @@  discard block
 block discarded – undo
1169 1567
 		    $data['format_source'] = 'aircraftjson';
1170 1568
 		    $data['id_source'] = $id_source;
1171 1569
 		    if (isset($value['name']) && $value['name'] != '') {
1172
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1173
-			    else $data['source_name'] = $value['name'];
1174
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1175
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1570
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1571
+			    	$data['source_name'] = $value['name'].'_MLAT';
1572
+			    } else {
1573
+			    	$data['source_name'] = $value['name'];
1574
+			    }
1575
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1576
+		    	$data['source_name'] = 'MLAT';
1577
+		    }
1578
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1579
+		    	$data['noarchive'] = true;
1580
+		    }
1176 1581
 		    $SI->add($data);
1177 1582
 		    unset($data);
1178 1583
 		}
@@ -1192,22 +1597,54 @@  discard block
 block discarded – undo
1192 1597
 		foreach ($all_data['aircraft'] as $key => $line) {
1193 1598
 		    $data = array();
1194 1599
 		    $data['hex'] = $key; // hex
1195
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1196
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1197
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1198
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1199
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1200
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1201
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1202
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1600
+		    if (isset($line['callsign'])) {
1601
+		    	$data['ident'] = trim($line['callsign']);
1602
+		    }
1603
+		    // ident
1604
+		    if (isset($line['altitude'])) {
1605
+		    	$data['altitude'] = $line['altitude'];
1606
+		    }
1607
+		    // altitude
1608
+		    if (isset($line['speed'])) {
1609
+		    	$data['speed'] = $line['speed'];
1610
+		    }
1611
+		    // speed
1612
+		    if (isset($line['heading'])) {
1613
+		    	$data['heading'] = $line['heading'];
1614
+		    }
1615
+		    // heading
1616
+		    if (isset($line['lat'])) {
1617
+		    	$data['latitude'] = $line['lat'];
1618
+		    }
1619
+		    // lat
1620
+		    if (isset($line['lon'])) {
1621
+		    	$data['longitude'] = $line['lon'];
1622
+		    }
1623
+		    // long
1624
+		    if (isset($line['vert_rate'])) {
1625
+		    	$data['verticalrate'] = $line['vert_rate'];
1626
+		    }
1627
+		    // verticale rate
1628
+		    if (isset($line['squawk'])) {
1629
+		    	$data['squawk'] = $line['squawk'];
1630
+		    }
1631
+		    // squawk
1203 1632
 		    //$data['emergency'] = ''; // emergency
1204
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1205
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1633
+		    if (isset($line['reg'])) {
1634
+		    	$data['registration'] = $line['reg'];
1635
+		    }
1636
+		    if (isset($line['type'])) {
1637
+		    	$data['aircraft_icao'] = $line['type'];
1638
+		    }
1206 1639
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1207 1640
 		    $data['format_source'] = 'planefinderclient';
1208 1641
 		    $data['id_source'] = $id_source;
1209
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1210
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1642
+		    if (isset($value['name']) && $value['name'] != '') {
1643
+		    	$data['source_name'] = $value['name'];
1644
+		    }
1645
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1646
+		    	$data['noarchive'] = true;
1647
+		    }
1211 1648
 		    $SI->add($data);
1212 1649
 		    unset($data);
1213 1650
 		}
@@ -1223,7 +1660,9 @@  discard block
 block discarded – undo
1223 1660
 	    //$buffer = $Common->getData($hosts[$id]);
1224 1661
 	    $buffer = $Common->getData($value['host']);
1225 1662
 	    $all_data = json_decode($buffer,true);
1226
-	    if (!empty($all_data)) $reset = 0;
1663
+	    if (!empty($all_data)) {
1664
+	    	$reset = 0;
1665
+	    }
1227 1666
 	    foreach ($all_data as $key => $line) {
1228 1667
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1229 1668
 		    $data = array();
@@ -1244,8 +1683,12 @@  discard block
 block discarded – undo
1244 1683
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1245 1684
 	    	    $data['format_source'] = 'fr24json';
1246 1685
     		    $data['id_source'] = $id_source;
1247
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1248
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1686
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1687
+		    	$data['noarchive'] = true;
1688
+		    }
1689
+		    if (isset($value['name']) && $value['name'] != '') {
1690
+		    	$data['source_name'] = $value['name'];
1691
+		    }
1249 1692
 		    $SI->add($data);
1250 1693
 		    unset($data);
1251 1694
 		}
@@ -1274,24 +1717,42 @@  discard block
 block discarded – undo
1274 1717
 		    if (isset($line['inf'])) {
1275 1718
 			$data = array();
1276 1719
 			$data['hex'] = $line['inf']['ia'];
1277
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1720
+			if (isset($line['inf']['cs'])) {
1721
+				$data['ident'] = $line['inf']['cs'];
1722
+			}
1723
+			//$line[13]
1278 1724
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1279
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1280
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1725
+	    		if (isset($line['inf']['gs'])) {
1726
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1727
+	    		}
1728
+	    		// speed
1729
+	    		if (isset($line['inf']['tr'])) {
1730
+	    			$data['heading'] = $line['inf']['tr'];
1731
+	    		}
1732
+	    		// heading
1281 1733
 	    		$data['latitude'] = $line['pt'][0]; // lat
1282 1734
 	    		$data['longitude'] = $line['pt'][1]; // long
1283 1735
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1284
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1736
+	    		if (isset($line['inf']['sq'])) {
1737
+	    			$data['squawk'] = $line['inf']['sq'];
1738
+	    		}
1739
+	    		// squawk
1285 1740
 	    		//$data['aircraft_icao'] = $line[8];
1286
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1741
+	    		if (isset($line['inf']['rc'])) {
1742
+	    			$data['registration'] = $line['inf']['rc'];
1743
+	    		}
1287 1744
 			//$data['departure_airport_iata'] = $line[11];
1288 1745
 			//$data['arrival_airport_iata'] = $line[12];
1289 1746
 	    		//$data['emergency'] = ''; // emergency
1290 1747
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1291 1748
 	    		$data['format_source'] = 'radarvirtueljson';
1292 1749
     			$data['id_source'] = $id_source;
1293
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1294
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1750
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1751
+				$data['noarchive'] = true;
1752
+			}
1753
+			if (isset($value['name']) && $value['name'] != '') {
1754
+				$data['source_name'] = $value['name'];
1755
+			}
1295 1756
 			$SI->add($data);
1296 1757
 			unset($data);
1297 1758
 		    }
@@ -1317,30 +1778,65 @@  discard block
 block discarded – undo
1317 1778
 		    $data['id'] = $line['id'];
1318 1779
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1319 1780
 		    $data['ident'] = $line['callsign']; // ident
1320
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1321
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1322
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1323
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1324
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1325
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1781
+		    if (isset($line['pilotid'])) {
1782
+		    	$data['pilot_id'] = $line['pilotid'];
1783
+		    }
1784
+		    // pilot id
1785
+		    if (isset($line['name'])) {
1786
+		    	$data['pilot_name'] = $line['name'];
1787
+		    }
1788
+		    // pilot name
1789
+		    if (isset($line['alt'])) {
1790
+		    	$data['altitude'] = $line['alt'];
1791
+		    }
1792
+		    // altitude
1793
+		    if (isset($line['gs'])) {
1794
+		    	$data['speed'] = $line['gs'];
1795
+		    }
1796
+		    // speed
1797
+		    if (isset($line['heading'])) {
1798
+		    	$data['heading'] = $line['heading'];
1799
+		    }
1800
+		    // heading
1801
+		    if (isset($line['route'])) {
1802
+		    	$data['waypoints'] = $line['route'];
1803
+		    }
1804
+		    // route
1326 1805
 		    $data['latitude'] = $line['lat']; // lat
1327 1806
 		    $data['longitude'] = $line['lon']; // long
1328 1807
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1329 1808
 		    //$data['squawk'] = $line['squawk']; // squawk
1330 1809
 		    //$data['emergency'] = ''; // emergency
1331
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1332
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1333
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1810
+		    if (isset($line['depicao'])) {
1811
+		    	$data['departure_airport_icao'] = $line['depicao'];
1812
+		    }
1813
+		    if (isset($line['deptime'])) {
1814
+		    	$data['departure_airport_time'] = $line['deptime'];
1815
+		    }
1816
+		    if (isset($line['arricao'])) {
1817
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1818
+		    }
1334 1819
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1335
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1336
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1337
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1338
-		    else $data['info'] = '';
1820
+		    if (isset($line['aircraft'])) {
1821
+		    	$data['aircraft_icao'] = $line['aircraft'];
1822
+		    }
1823
+		    if (isset($line['transponder'])) {
1824
+		    	$data['squawk'] = $line['transponder'];
1825
+		    }
1826
+		    if (isset($line['atis'])) {
1827
+		    	$data['info'] = $line['atis'];
1828
+		    } else {
1829
+		    	$data['info'] = '';
1830
+		    }
1339 1831
 		    $data['format_source'] = 'pireps';
1340 1832
     		    $data['id_source'] = $id_source;
1341 1833
 		    $data['datetime'] = date('Y-m-d H:i:s');
1342
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1343
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1834
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1835
+		    	$data['noarchive'] = true;
1836
+		    }
1837
+		    if (isset($value['name']) && $value['name'] != '') {
1838
+		    	$data['source_name'] = $value['name'];
1839
+		    }
1344 1840
 		    if ($line['icon'] === 'plane') {
1345 1841
 			$SI->add($data);
1346 1842
 		    //    print_r($data);
@@ -1349,16 +1845,28 @@  discard block
 block discarded – undo
1349 1845
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1350 1846
 			$typec = substr($data['ident'],-3);
1351 1847
 			$data['type'] = '';
1352
-			if ($typec === 'APP') $data['type'] = 'Approach';
1353
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1354
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1355
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1356
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1357
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1358
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1359
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1360
-			else $data['type'] = 'Observer';
1361
-			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']);
1848
+			if ($typec === 'APP') {
1849
+				$data['type'] = 'Approach';
1850
+			} elseif ($typec === 'TWR') {
1851
+				$data['type'] = 'Tower';
1852
+			} elseif ($typec === 'OBS') {
1853
+				$data['type'] = 'Observer';
1854
+			} elseif ($typec === 'GND') {
1855
+				$data['type'] = 'Ground';
1856
+			} elseif ($typec === 'DEL') {
1857
+				$data['type'] = 'Delivery';
1858
+			} elseif ($typec === 'DEP') {
1859
+				$data['type'] = 'Departure';
1860
+			} elseif ($typec === 'FSS') {
1861
+				$data['type'] = 'Flight Service Station';
1862
+			} elseif ($typec === 'CTR') {
1863
+				$data['type'] = 'Control Radar or Centre';
1864
+			} else {
1865
+				$data['type'] = 'Observer';
1866
+			}
1867
+			if (isset($ATC)) {
1868
+				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']);
1869
+			}
1362 1870
 		    }
1363 1871
 		    unset($data);
1364 1872
 		}
@@ -1373,7 +1881,9 @@  discard block
 block discarded – undo
1373 1881
 	    )
1374 1882
 	) {
1375 1883
 	    //$buffer = $Common->getData($hosts[$id]);
1376
-	    if ($globalDebug) echo 'Get Data...'."\n";
1884
+	    if ($globalDebug) {
1885
+	    	echo 'Get Data...'."\n";
1886
+	    }
1377 1887
 	    $buffer = $Common->getData($value['host']);
1378 1888
 	    $all_data = json_decode($buffer,true);
1379 1889
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1381,10 +1891,16 @@  discard block
 block discarded – undo
1381 1891
 		foreach ($all_data as $line) {
1382 1892
 	    	    $data = array();
1383 1893
 	    	    //$data['id'] = $line['id']; // id not usable
1384
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1894
+	    	    if (isset($line['pilotid'])) {
1895
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1896
+	    	    }
1385 1897
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1386
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1387
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1898
+	    	    if (isset($line['pilotname'])) {
1899
+	    	    	$data['pilot_name'] = $line['pilotname'];
1900
+	    	    }
1901
+	    	    if (isset($line['pilotid'])) {
1902
+	    	    	$data['pilot_id'] = $line['pilotid'];
1903
+	    	    }
1388 1904
 	    	    $data['ident'] = $line['flightnum']; // ident
1389 1905
 	    	    $data['altitude'] = $line['alt']; // altitude
1390 1906
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1400,7 +1916,9 @@  discard block
 block discarded – undo
1400 1916
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1401 1917
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1402 1918
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1403
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1919
+	    	    } else {
1920
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1921
+	    	    }
1404 1922
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1405 1923
 	    	    $data['departure_airport_time'] = $line['deptime'];
1406 1924
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1408,29 +1926,47 @@  discard block
 block discarded – undo
1408 1926
     		    if (isset($line['registration'])) {
1409 1927
     			$data['registration'] = $line['registration'];
1410 1928
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1411
-    		    } else $data['registration'] = $line['aircraft'];
1412
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1929
+    		    } else {
1930
+    		    	$data['registration'] = $line['aircraft'];
1931
+    		    }
1932
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1933
+		    	$data['noarchive'] = true;
1934
+		    }
1935
+		    if (isset($line['route'])) {
1936
+		    	$data['waypoints'] = $line['route'];
1937
+		    }
1938
+		    // route
1414 1939
 		    if (isset($line['aircraftname'])) {
1415 1940
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1416 1941
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1417 1942
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1418
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1419
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1420
-	    		else {
1943
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1944
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1945
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1946
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1947
+	    		} else {
1421 1948
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1422
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1423
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1949
+	    		    if (isset($aircraft_data[1])) {
1950
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1951
+	    		    } else {
1952
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1953
+	    		    }
1424 1954
 	    		}
1425 1955
 	    	    }
1426
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1956
+    		    if (isset($line['route'])) {
1957
+    		    	$data['waypoints'] = $line['route'];
1958
+    		    }
1427 1959
     		    $data['id_source'] = $id_source;
1428 1960
 	    	    $data['format_source'] = 'phpvmacars';
1429
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1961
+		    if (isset($value['name']) && $value['name'] != '') {
1962
+		    	$data['source_name'] = $value['name'];
1963
+		    }
1430 1964
 		    $SI->add($data);
1431 1965
 		    unset($data);
1432 1966
 		}
1433
-		if ($globalDebug) echo 'No more data...'."\n";
1967
+		if ($globalDebug) {
1968
+			echo 'No more data...'."\n";
1969
+		}
1434 1970
 		unset($buffer);
1435 1971
 		unset($all_data);
1436 1972
 	    }
@@ -1443,7 +1979,9 @@  discard block
 block discarded – undo
1443 1979
 	    )
1444 1980
 	) {
1445 1981
 	    //$buffer = $Common->getData($hosts[$id]);
1446
-	    if ($globalDebug) echo 'Get Data...'."\n";
1982
+	    if ($globalDebug) {
1983
+	    	echo 'Get Data...'."\n";
1984
+	    }
1447 1985
 	    $buffer = $Common->getData($value['host']);
1448 1986
 	    $all_data = json_decode($buffer,true);
1449 1987
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1454,10 +1992,16 @@  discard block
 block discarded – undo
1454 1992
 	    	    //$data['id'] = $line['id']; // id not usable
1455 1993
 	    	    $data['id'] = $line['id'];
1456 1994
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1458
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1995
+	    	    if (isset($line['user']['username'])) {
1996
+	    	    	$data['pilot_name'] = $line['user']['username'];
1997
+	    	    }
1998
+	    	    if (isset($line['user_id'])) {
1999
+	    	    	$data['pilot_id'] = $line['user_id'];
2000
+	    	    }
1459 2001
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1460
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2002
+	    	    if (is_numeric($data['ident'])) {
2003
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2004
+	    	    }
1461 2005
 	    	    $data['altitude'] = $line['altitude']; // altitude
1462 2006
 	    	    $data['speed'] = $line['groundspeed']; // speed
1463 2007
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1470,7 +2014,9 @@  discard block
 block discarded – undo
1470 2014
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1471 2015
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1472 2016
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1473
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2017
+	    	    } else {
2018
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2019
+	    	    }
1474 2020
 	    	    
1475 2021
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1476 2022
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1478,17 +2024,26 @@  discard block
 block discarded – undo
1478 2024
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1479 2025
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1480 2026
 
1481
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2027
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2028
+		    	$data['noarchive'] = true;
2029
+		    }
2030
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2031
+		    	$data['waypoints'] = $line['bid']['route'];
2032
+		    }
2033
+		    // route
1483 2034
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1484 2035
 
1485 2036
     		    $data['id_source'] = $id_source;
1486 2037
 	    	    $data['format_source'] = 'vaos';
1487
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2038
+		    if (isset($value['name']) && $value['name'] != '') {
2039
+		    	$data['source_name'] = $value['name'];
2040
+		    }
1488 2041
 		    $SI->add($data);
1489 2042
 		    unset($data);
1490 2043
 		}
1491
-		if ($globalDebug) echo 'No more data...'."\n";
2044
+		if ($globalDebug) {
2045
+			echo 'No more data...'."\n";
2046
+		}
1492 2047
 		unset($buffer);
1493 2048
 		unset($all_data);
1494 2049
 	    }
@@ -1501,7 +2056,9 @@  discard block
 block discarded – undo
1501 2056
 	    )
1502 2057
 	) {
1503 2058
 	    //$buffer = $Common->getData($hosts[$id]);
1504
-	    if ($globalDebug) echo 'Get Data...'."\n";
2059
+	    if ($globalDebug) {
2060
+	    	echo 'Get Data...'."\n";
2061
+	    }
1505 2062
 	    $buffer = $Common->getData($value['host']);
1506 2063
 	    $all_data = json_decode($buffer,true);
1507 2064
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1530,16 +2087,25 @@  discard block
 block discarded – undo
1530 2087
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1531 2088
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1532 2089
     		    //$data['registration'] = $line['aircraft'];
1533
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2090
+		    if (isset($line['route'])) {
2091
+		    	$data['waypoints'] = $line['route'];
2092
+		    }
2093
+		    // route
1534 2094
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1535 2095
     		    $data['id_source'] = $id_source;
1536 2096
 	    	    $data['format_source'] = 'vam';
1537
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2097
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2098
+		    	$data['noarchive'] = true;
2099
+		    }
2100
+		    if (isset($value['name']) && $value['name'] != '') {
2101
+		    	$data['source_name'] = $value['name'];
2102
+		    }
1539 2103
 		    $SI->add($data);
1540 2104
 		    unset($data);
1541 2105
 		}
1542
-		if ($globalDebug) echo 'No more data...'."\n";
2106
+		if ($globalDebug) {
2107
+			echo 'No more data...'."\n";
2108
+		}
1543 2109
 		unset($buffer);
1544 2110
 		unset($all_data);
1545 2111
 	    }
@@ -1552,7 +2118,9 @@  discard block
 block discarded – undo
1552 2118
 	    )
1553 2119
 	) {
1554 2120
 	    //$buffer = $Common->getData($hosts[$id]);
1555
-	    if ($globalDebug) echo 'Get Data...'."\n";
2121
+	    if ($globalDebug) {
2122
+	    	echo 'Get Data...'."\n";
2123
+	    }
1556 2124
 	    $buffer = $Common->getData($value['host']);
1557 2125
 	    $all_data = json_decode($buffer,true);
1558 2126
 	    if ($buffer != '') {
@@ -1570,12 +2138,16 @@  discard block
 block discarded – undo
1570 2138
 			$data['id_source'] = $id_source;
1571 2139
 			$data['format_source'] = 'blitzortung';
1572 2140
 			$SI->add($data);
1573
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2141
+			if ($globalDebug) {
2142
+				echo '☈ Lightning added'."\n";
2143
+			}
1574 2144
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1575 2145
 			unset($data);
1576 2146
 		    }
1577 2147
 		}
1578
-		if ($globalDebug) echo 'No more data...'."\n";
2148
+		if ($globalDebug) {
2149
+			echo 'No more data...'."\n";
2150
+		}
1579 2151
 		unset($buffer);
1580 2152
 	    }
1581 2153
 	    $last_exec[$id]['last'] = time();
@@ -1587,7 +2159,9 @@  discard block
 block discarded – undo
1587 2159
 	    $write = NULL;
1588 2160
 	    $e = NULL;
1589 2161
 	    $n = socket_select($read, $write, $e, $timeout);
1590
-	    if ($e != NULL) var_dump($e);
2162
+	    if ($e != NULL) {
2163
+	    	var_dump($e);
2164
+	    }
1591 2165
 	    if ($n > 0) {
1592 2166
 		$reset = 0;
1593 2167
 		foreach ($read as $nb => $r) {
@@ -1609,13 +2183,17 @@  discard block
 block discarded – undo
1609 2183
 		    if ($buffer !== FALSE) {
1610 2184
 			if ($format === 'vrstcp') {
1611 2185
 			    $buffer = explode('},{',$buffer);
1612
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2186
+			} else {
2187
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2188
+			}
1613 2189
 		    }
1614 2190
 		    // SBS format is CSV format
1615 2191
 		    if ($buffer !== FALSE && $buffer !== '') {
1616 2192
 			$tt[$format] = 0;
1617 2193
 			if ($format === 'acarssbs3') {
1618
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2194
+			    if ($globalDebug) {
2195
+			    	echo 'ACARS : '.$buffer."\n";
2196
+			    }
1619 2197
 			    $ACARS->add(trim($buffer));
1620 2198
 			    $ACARS->deleteLiveAcarsData();
1621 2199
 			} elseif ($format === 'raw') {
@@ -1624,30 +2202,70 @@  discard block
 block discarded – undo
1624 2202
 			    if (is_array($data)) {
1625 2203
 				$data['datetime'] = date('Y-m-d H:i:s');
1626 2204
 				$data['format_source'] = 'raw';
1627
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1628
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1629
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1630
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2205
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2206
+					$data['source_name'] = $globalSources[$nb]['name'];
2207
+				}
2208
+				if (isset($globalSources[$nb]['sourcestats'])) {
2209
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2210
+				}
2211
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2212
+					$data['noarchive'] = true;
2213
+				}
2214
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2215
+					$SI->add($data);
2216
+				}
1631 2217
 			    }
1632 2218
 			} elseif ($format === 'ais') {
1633 2219
 			    $ais_data = $AIS->parse_line(trim($buffer));
1634 2220
 			    $data = array();
1635
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1636
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1637
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1638
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1639
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1640
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1641
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1642
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1643
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1644
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1645
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1646
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1647
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1648
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1649
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2221
+			    if (isset($ais_data['ident'])) {
2222
+			    	$data['ident'] = $ais_data['ident'];
2223
+			    }
2224
+			    if (isset($ais_data['mmsi'])) {
2225
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2226
+			    }
2227
+			    if (isset($ais_data['speed'])) {
2228
+			    	$data['speed'] = $ais_data['speed'];
2229
+			    }
2230
+			    if (isset($ais_data['heading'])) {
2231
+			    	$data['heading'] = $ais_data['heading'];
2232
+			    }
2233
+			    if (isset($ais_data['latitude'])) {
2234
+			    	$data['latitude'] = $ais_data['latitude'];
2235
+			    }
2236
+			    if (isset($ais_data['longitude'])) {
2237
+			    	$data['longitude'] = $ais_data['longitude'];
2238
+			    }
2239
+			    if (isset($ais_data['status'])) {
2240
+			    	$data['status'] = $ais_data['status'];
2241
+			    }
2242
+			    if (isset($ais_data['statusid'])) {
2243
+			    	$data['status_id'] = $ais_data['statusid'];
2244
+			    }
2245
+			    if (isset($ais_data['type'])) {
2246
+			    	$data['type'] = $ais_data['type'];
2247
+			    }
2248
+			    if (isset($ais_data['imo'])) {
2249
+			    	$data['imo'] = $ais_data['imo'];
2250
+			    }
2251
+			    if (isset($ais_data['callsign'])) {
2252
+			    	$data['callsign'] = $ais_data['callsign'];
2253
+			    }
2254
+			    if (isset($ais_data['destination'])) {
2255
+			    	$data['arrival_code'] = $ais_data['destination'];
2256
+			    }
2257
+			    if (isset($ais_data['eta_ts'])) {
2258
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2259
+			    }
2260
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2261
+			    	$data['noarchive'] = true;
2262
+			    }
2263
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2264
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2265
+			    }
2266
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2267
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2268
+			    }
1651 2269
 
1652 2270
 			    if (isset($ais_data['timestamp'])) {
1653 2271
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1656,7 +2274,9 @@  discard block
 block discarded – undo
1656 2274
 			    }
1657 2275
 			    $data['format_source'] = 'aisnmea';
1658 2276
     			    $data['id_source'] = $id_source;
1659
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2277
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2278
+			    	$MI->add($data);
2279
+			    }
1660 2280
 			    unset($data);
1661 2281
                         } elseif ($format === 'flightgearsp') {
1662 2282
                     	    //echo $buffer."\n";
@@ -1674,12 +2294,18 @@  discard block
 block discarded – undo
1674 2294
 				$data['speed'] = round($line[5]*1.94384);
1675 2295
 				$data['datetime'] = date('Y-m-d H:i:s');
1676 2296
 				$data['format_source'] = 'flightgearsp';
1677
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1678
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2297
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2298
+					$data['noarchive'] = true;
2299
+				}
2300
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2301
+					$SI->add($data);
2302
+				}
1679 2303
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1680 2304
 			    }
1681 2305
                         } elseif ($format === 'acars') {
1682
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2306
+                    	    if ($globalDebug) {
2307
+                    	    	echo 'ACARS : '.$buffer."\n";
2308
+                    	    }
1683 2309
 			    $ACARS->add(trim($buffer));
1684 2310
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1685 2311
 			    $ACARS->deleteLiveAcarsData();
@@ -1700,8 +2326,12 @@  discard block
 block discarded – undo
1700 2326
 				    $aircraft_type = $line[10];
1701 2327
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1702 2328
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1703
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2329
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2330
+				    	$data['noarchive'] = true;
2331
+				    }
2332
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2333
+				    	$SI->add($data);
2334
+				    }
1705 2335
 				}
1706 2336
 			    }
1707 2337
 			} elseif ($format === 'beast') {
@@ -1711,28 +2341,62 @@  discard block
 block discarded – undo
1711 2341
 			    foreach($buffer as $all_data) {
1712 2342
 				$line = json_decode('{'.$all_data.'}',true);
1713 2343
 				$data = array();
1714
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1715
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1716
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1717
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1718
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1719
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1720
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2344
+				if (isset($line['Icao'])) {
2345
+					$data['hex'] = $line['Icao'];
2346
+				}
2347
+				// hex
2348
+				if (isset($line['Call'])) {
2349
+					$data['ident'] = $line['Call'];
2350
+				}
2351
+				// ident
2352
+				if (isset($line['Alt'])) {
2353
+					$data['altitude'] = $line['Alt'];
2354
+				}
2355
+				// altitude
2356
+				if (isset($line['Spd'])) {
2357
+					$data['speed'] = $line['Spd'];
2358
+				}
2359
+				// speed
2360
+				if (isset($line['Trak'])) {
2361
+					$data['heading'] = $line['Trak'];
2362
+				}
2363
+				// heading
2364
+				if (isset($line['Lat'])) {
2365
+					$data['latitude'] = $line['Lat'];
2366
+				}
2367
+				// lat
2368
+				if (isset($line['Long'])) {
2369
+					$data['longitude'] = $line['Long'];
2370
+				}
2371
+				// long
1721 2372
 				//$data['verticalrate'] = $line['']; // verticale rate
1722
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2373
+				if (isset($line['Sqk'])) {
2374
+					$data['squawk'] = $line['Sqk'];
2375
+				}
2376
+				// squawk
1723 2377
 				$data['emergency'] = ''; // emergency
1724
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2378
+				if (isset($line['Reg'])) {
2379
+					$data['registration'] = $line['Reg'];
2380
+				}
1725 2381
 				/*
1726 2382
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1727 2383
 				else $data['datetime'] = date('Y-m-d H:i:s');
1728 2384
 				*/
1729 2385
 				$data['datetime'] = date('Y-m-d H:i:s');
1730
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2386
+				if (isset($line['Type'])) {
2387
+					$data['aircraft_icao'] = $line['Type'];
2388
+				}
1731 2389
 		    		$data['format_source'] = 'vrstcp';
1732 2390
 				$data['id_source'] = $id_source;
1733
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1734
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1735
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2391
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2392
+					$data['noarchive'] = true;
2393
+				}
2394
+				if (isset($value['name']) && $value['name'] != '') {
2395
+					$data['source_name'] = $value['name'];
2396
+				}
2397
+				if (isset($data['latitude']) && isset($data['hex'])) {
2398
+					$SI->add($data);
2399
+				}
1736 2400
 				unset($data);
1737 2401
 			    }
1738 2402
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1745,22 +2409,46 @@  discard block
 block discarded – undo
1745 2409
     				$data['hex'] = $lined['hexid'];
1746 2410
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1747 2411
     				$data['datetime'] = date('Y-m-d H:i:s');;
1748
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1749
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1750
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1751
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1752
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1753
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1754
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2412
+    				if (isset($lined['ident'])) {
2413
+    					$data['ident'] = $lined['ident'];
2414
+    				}
2415
+    				if (isset($lined['lat'])) {
2416
+    					$data['latitude'] = $lined['lat'];
2417
+    				}
2418
+    				if (isset($lined['lon'])) {
2419
+    					$data['longitude'] = $lined['lon'];
2420
+    				}
2421
+    				if (isset($lined['speed'])) {
2422
+    					$data['speed'] = $lined['speed'];
2423
+    				}
2424
+    				if (isset($lined['squawk'])) {
2425
+    					$data['squawk'] = $lined['squawk'];
2426
+    				}
2427
+    				if (isset($lined['alt'])) {
2428
+    					$data['altitude'] = $lined['alt'];
2429
+    				}
2430
+    				if (isset($lined['heading'])) {
2431
+    					$data['heading'] = $lined['heading'];
2432
+    				}
1755 2433
     				$data['id_source'] = $id_source;
1756 2434
     				$data['format_source'] = 'tsv';
1757
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1758
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1759
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1760
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2435
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2436
+    					$data['source_name'] = $globalSources[$nb]['name'];
2437
+    				}
2438
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2439
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2440
+    				}
2441
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2442
+					$data['noarchive'] = true;
2443
+				}
2444
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2445
+    					$SI->add($data);
2446
+    				}
1761 2447
     				unset($lined);
1762 2448
     				unset($data);
1763
-    			    } else $error = true;
2449
+    			    } else {
2450
+    			    	$error = true;
2451
+    			    }
1764 2452
 			} elseif ($format === 'aprs' && $use_aprs) {
1765 2453
 			    if ($aprs_connect === 0) {
1766 2454
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1786,47 +2474,96 @@  discard block
 block discarded – undo
1786 2474
 				    $aprs_last_tx = time();
1787 2475
 				    $data = array();
1788 2476
 				    //print_r($line);
1789
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1790
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1791
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1792
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1793
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1794
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1795
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1796
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1797
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1798
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2477
+				    if (isset($line['address'])) {
2478
+				    	$data['hex'] = $line['address'];
2479
+				    }
2480
+				    if (isset($line['mmsi'])) {
2481
+				    	$data['mmsi'] = $line['mmsi'];
2482
+				    }
2483
+				    if (isset($line['imo'])) {
2484
+				    	$data['imo'] = $line['imo'];
2485
+				    }
2486
+				    if (isset($line['squawk'])) {
2487
+				    	$data['squawk'] = $line['squawk'];
2488
+				    }
2489
+				    if (isset($line['arrival_code'])) {
2490
+				    	$data['arrival_code'] = $line['arrival_code'];
2491
+				    }
2492
+				    if (isset($line['arrival_date'])) {
2493
+				    	$data['arrival_date'] = $line['arrival_date'];
2494
+				    }
2495
+				    if (isset($line['typeid'])) {
2496
+				    	$data['type_id'] = $line['typeid'];
2497
+				    }
2498
+				    if (isset($line['statusid'])) {
2499
+				    	$data['status_id'] = $line['statusid'];
2500
+				    }
2501
+				    if (isset($line['timestamp'])) {
2502
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2503
+				    } else {
2504
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2505
+				    }
1799 2506
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1800
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2507
+				    if (isset($line['ident'])) {
2508
+				    	$data['ident'] = $line['ident'];
2509
+				    }
1801 2510
 				    $data['latitude'] = $line['latitude'];
1802 2511
 				    $data['longitude'] = $line['longitude'];
1803 2512
 				    //$data['verticalrate'] = $line[16];
1804
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2513
+				    if (isset($line['speed'])) {
2514
+				    	$data['speed'] = $line['speed'];
2515
+				    }
1805 2516
 				    //else $data['speed'] = 0;
1806
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1807
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1808
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2517
+				    if (isset($line['altitude'])) {
2518
+				    	$data['altitude'] = $line['altitude'];
2519
+				    }
2520
+				    if (isset($line['comment'])) {
2521
+				    	$data['comment'] = $line['comment'];
2522
+				    }
2523
+				    if (isset($line['symbol'])) {
2524
+				    	$data['type'] = $line['symbol'];
2525
+				    }
1809 2526
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1810 2527
 				    
1811
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2528
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2529
+				    	$data['heading'] = $line['heading'];
2530
+				    }
1812 2531
 				    //else echo 'No heading...'."\n";
1813 2532
 				    //else $data['heading'] = 0;
1814
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2533
+				    if (isset($line['stealth'])) {
2534
+				    	$data['aircraft_type'] = $line['stealth'];
2535
+				    }
1815 2536
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1816
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1817
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1818
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1819
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2537
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2538
+				    	$data['noarchive'] = true;
2539
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2540
+				    	$data['noarchive'] = false;
2541
+				    }
2542
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2543
+				    	$data['noarchive'] = true;
2544
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2545
+				    	$data['noarchive'] = false;
2546
+				    }
1820 2547
     				    $data['id_source'] = $id_source;
1821
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1822
-				    else $data['format_source'] = 'aprs';
2548
+    				    if (isset($line['format_source'])) {
2549
+    				    	$data['format_source'] = $line['format_source'];
2550
+    				    } else {
2551
+				    	$data['format_source'] = 'aprs';
2552
+				    }
1823 2553
 				    $data['source_name'] = $line['source'];
1824
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1825
-				    else $data['source_type'] = 'flarm';
1826
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2554
+				    if (isset($line['source_type'])) {
2555
+				    	$data['source_type'] = $line['source_type'];
2556
+				    } else {
2557
+				    	$data['source_type'] = 'flarm';
2558
+				    }
2559
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2560
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2561
+    				    }
1827 2562
 				    $currentdate = date('Y-m-d H:i:s');
1828 2563
 				    $aprsdate = strtotime($data['datetime']);
1829
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2564
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2565
+				    	$data['altitude_relative'] = 'AMSL';
2566
+				    }
1830 2567
 				    // Accept data if time <= system time + 20s
1831 2568
 				    //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'])))) {
1832 2569
 				    if (
@@ -1838,7 +2575,9 @@  discard block
 block discarded – undo
1838 2575
 					$send = $SI->add($data);
1839 2576
 				    } elseif ($data['source_type'] === 'ais') {
1840 2577
 					$data['type'] = '';
1841
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2578
+					if (isset($globalMarine) && $globalMarine) {
2579
+						$send = $MI->add($data);
2580
+					}
1842 2581
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1843 2582
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1844 2583
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1846,8 +2585,12 @@  discard block
 block discarded – undo
1846 2585
 					    $line['symbol'] === 'Glider' || 
1847 2586
 					    $line['symbol'] === 'No. Plane' || 
1848 2587
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1849
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1850
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2588
+					    if ($line['symbol'] === 'Ballon') {
2589
+					    	$data['aircraft_icao'] = 'BALL';
2590
+					    }
2591
+					    if ($line['symbol'] === 'Glider') {
2592
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2593
+					    }
1851 2594
 					    $send = $SI->add($data);
1852 2595
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1853 2596
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1878,9 +2621,13 @@  discard block
 block discarded – undo
1878 2621
 				    //} 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') {
1879 2622
 				//    } 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') {
1880 2623
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1881
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2624
+					if (isset($globalTracker) && $globalTracker) {
2625
+						$send = $TI->add($data);
2626
+					}
1882 2627
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1883
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2628
+					if (!isset($data['altitude'])) {
2629
+						$data['altitude'] = 0;
2630
+					}
1884 2631
 					$Source->deleteOldLocationByType('gs');
1885 2632
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1886 2633
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1889,7 +2636,9 @@  discard block
 block discarded – undo
1889 2636
 					}
1890 2637
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1891 2638
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1892
-					if ($globalDebug) echo '# Weather Station added'."\n";
2639
+					if ($globalDebug) {
2640
+						echo '# Weather Station added'."\n";
2641
+					}
1893 2642
 					$Source->deleteOldLocationByType('wx');
1894 2643
 					$weather_data = json_encode($line);
1895 2644
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1899,7 +2648,9 @@  discard block
 block discarded – undo
1899 2648
 					}
1900 2649
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1901 2650
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1902
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2651
+					if ($globalDebug) {
2652
+						echo '☈ Lightning added'."\n";
2653
+					}
1903 2654
 					$Source->deleteOldLocationByType('lightning');
1904 2655
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1905 2656
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1911,8 +2662,7 @@  discard block
 block discarded – undo
1911 2662
 				    	print_r($line);
1912 2663
 				    }
1913 2664
 				    unset($data);
1914
-				}
1915
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2665
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1916 2666
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1917 2667
 				}
1918 2668
 				/*
@@ -1921,7 +2671,9 @@  discard block
 block discarded – undo
1921 2671
 				}
1922 2672
 				*/
1923 2673
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1924
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2674
+				elseif ($line === true && $globalDebug) {
2675
+					echo '!! Failed : '.$buffer."!!\n";
2676
+				}
1925 2677
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1926 2678
 					$Source->deleteOldLocationByType('lightning');
1927 2679
 					$Source->deleteOldLocationByType('wx');
@@ -1957,27 +2709,47 @@  discard block
 block discarded – undo
1957 2709
     				$data['ground'] = $line[21];
1958 2710
     				$data['emergency'] = $line[19];
1959 2711
     				$data['format_source'] = 'sbs';
1960
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1961
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1962
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1963
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2712
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2713
+					$data['source_name'] = $globalSources[$nb]['name'];
2714
+				} elseif ($line[0] == 'MLAT') {
2715
+					$data['source_name'] = 'MLAT';
2716
+				}
2717
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2718
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2719
+    				}
2720
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2721
+					$data['noarchive'] = true;
2722
+				}
1964 2723
     				$data['id_source'] = $id_source;
1965
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1966
-    				else $error = true;
2724
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2725
+    					$send = $SI->add($data);
2726
+    				} else {
2727
+    					$error = true;
2728
+    				}
1967 2729
     				unset($data);
1968
-    			    } else $error = true;
2730
+    			    } else {
2731
+    			    	$error = true;
2732
+    			    }
1969 2733
 			    if ($error) {
1970 2734
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1971
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2735
+					if ($globalDebug) {
2736
+						echo "Not a message. Ignoring... \n";
2737
+					}
1972 2738
 				} else {
1973
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2739
+					if ($globalDebug) {
2740
+						echo "Wrong line format. Ignoring... \n";
2741
+					}
1974 2742
 					if ($globalDebug) {
1975 2743
 						echo $buffer;
1976 2744
 						//print_r($line);
1977 2745
 					}
1978 2746
 					//socket_close($r);
1979
-					if ($globalDebug) echo "Reconnect after an error...\n";
1980
-					if ($format === 'aprs') $aprs_connect = 0;
2747
+					if ($globalDebug) {
2748
+						echo "Reconnect after an error...\n";
2749
+					}
2750
+					if ($format === 'aprs') {
2751
+						$aprs_connect = 0;
2752
+					}
1981 2753
 					$sourceer[$nb] = $globalSources[$nb];
1982 2754
 					connect_all($sourceer);
1983 2755
 					$sourceer = array();
@@ -1985,10 +2757,14 @@  discard block
 block discarded – undo
1985 2757
 			    }
1986 2758
 			}
1987 2759
 			// Sleep for xxx microseconds
1988
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2760
+			if (isset($globalSBSSleep)) {
2761
+				usleep($globalSBSSleep);
2762
+			}
1989 2763
 		    } else {
1990 2764
 			if ($format === 'flightgearmp') {
1991
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2765
+			    	if ($globalDebug) {
2766
+			    		echo "Reconnect FlightGear MP...";
2767
+			    	}
1992 2768
 				//@socket_close($r);
1993 2769
 				sleep($globalMinFetch);
1994 2770
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1997,10 +2773,15 @@  discard block
 block discarded – undo
1997 2773
 				break;
1998 2774
 				
1999 2775
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2000
-			    if (isset($tt[$format])) $tt[$format]++;
2001
-			    else $tt[$format] = 0;
2776
+			    if (isset($tt[$format])) {
2777
+			    	$tt[$format]++;
2778
+			    } else {
2779
+			    	$tt[$format] = 0;
2780
+			    }
2002 2781
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2003
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2782
+				if ($globalDebug) {
2783
+					echo "ERROR : Reconnect ".$format."...";
2784
+				}
2004 2785
 				//@socket_close($r);
2005 2786
 				sleep(2);
2006 2787
 				$aprs_connect = 0;
@@ -2018,11 +2799,17 @@  discard block
 block discarded – undo
2018 2799
 	    } else {
2019 2800
 		$error = socket_strerror(socket_last_error());
2020 2801
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2021
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2022
-			if (isset($globalDebug)) echo "Restarting...\n";
2802
+			if ($globalDebug) {
2803
+				echo "ERROR : socket_select give this error ".$error . "\n";
2804
+			}
2805
+			if (isset($globalDebug)) {
2806
+				echo "Restarting...\n";
2807
+			}
2023 2808
 			// Restart the script if possible
2024 2809
 			if (is_array($sockets)) {
2025
-			    if ($globalDebug) echo "Shutdown all sockets...";
2810
+			    if ($globalDebug) {
2811
+			    	echo "Shutdown all sockets...";
2812
+			    }
2026 2813
 			    
2027 2814
 			    foreach ($sockets as $sock) {
2028 2815
 				@socket_shutdown($sock,2);
@@ -2030,25 +2817,45 @@  discard block
 block discarded – undo
2030 2817
 			    }
2031 2818
 			    
2032 2819
 			}
2033
-			if ($globalDebug) echo "Waiting...";
2820
+			if ($globalDebug) {
2821
+				echo "Waiting...";
2822
+			}
2034 2823
 			sleep(2);
2035 2824
 			$time = time();
2036 2825
 			//connect_all($hosts);
2037 2826
 			$aprs_connect = 0;
2038
-			if ($reset%5 === 0) sleep(20);
2039
-			if ($reset%10 === 0) sleep(100);
2040
-			if ($reset%20 === 0) sleep(200);
2041
-			if ($reset > 100) exit('Too many attempts...');
2042
-			if ($globalDebug) echo "Restart all connections...";
2827
+			if ($reset%5 === 0) {
2828
+				sleep(20);
2829
+			}
2830
+			if ($reset%10 === 0) {
2831
+				sleep(100);
2832
+			}
2833
+			if ($reset%20 === 0) {
2834
+				sleep(200);
2835
+			}
2836
+			if ($reset > 100) {
2837
+				exit('Too many attempts...');
2838
+			}
2839
+			if ($globalDebug) {
2840
+				echo "Restart all connections...";
2841
+			}
2043 2842
 			connect_all($globalSources);
2044 2843
 		}
2045 2844
 	    }
2046 2845
 	}
2047 2846
 	if ($globalDaemon === false) {
2048
-	    if ($globalDebug) echo 'Check all...'."\n";
2049
-	    if (isset($SI)) $SI->checkAll();
2050
-	    if (isset($TI)) $TI->checkAll();
2051
-	    if (isset($MI)) $MI->checkAll();
2847
+	    if ($globalDebug) {
2848
+	    	echo 'Check all...'."\n";
2849
+	    }
2850
+	    if (isset($SI)) {
2851
+	    	$SI->checkAll();
2852
+	    }
2853
+	    if (isset($TI)) {
2854
+	    	$TI->checkAll();
2855
+	    }
2856
+	    if (isset($MI)) {
2857
+	    	$MI->checkAll();
2858
+	    }
2052 2859
 	}
2053 2860
     }
2054 2861
 }
Please login to merge, or discard this patch.