Completed
Push — master ( 0cc343...db65f2 )
by Yannick
28:09
created
scripts/daemon-spotter.php 3 patches
Indentation   +1104 added lines, -1104 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
-	    }
622
-	    $last_exec[$id]['last'] = time();
621
+		}
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,67 +684,67 @@  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 ($globalDebug) echo '! Download... ';
743
-	    for ($i =0; $i <= 1; $i++) {
744
-		    if ($globalDebug) echo 'Racetype: '.$i."\n";
745
-	    $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
746
-	    if ($globalDebug) echo 'done'."\n";
747
-	    if ($buffer != '') {
742
+		if ($globalDebug) echo '! Download... ';
743
+		for ($i =0; $i <= 1; $i++) {
744
+			if ($globalDebug) echo 'Racetype: '.$i."\n";
745
+		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
746
+		if ($globalDebug) echo 'done'."\n";
747
+		if ($buffer != '') {
748 748
 		$all_data = json_decode($buffer,true);
749 749
 		if (isset($all_data['missions'])) {
750 750
 			foreach ($all_data['missions'] as $mission) {
@@ -794,34 +794,34 @@  discard block
 block discarded – undo
794 794
 				}
795 795
 			}
796 796
 		}
797
-	    }
798
-	    }
799
-    	    $last_exec[$id]['last'] = time();
797
+		}
798
+		}
799
+			$last_exec[$id]['last'] = time();
800 800
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
801 801
 	} elseif (
802
-	    (
802
+		(
803 803
 		$value['format'] === 'whazzup' && 
804 804
 		(
805
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
806
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
805
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
806
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
807 807
 		)
808
-	    ) || (
808
+		) || (
809 809
 		$value['format'] === 'vatsimtxt' && 
810 810
 		(
811
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
812
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
811
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
812
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
813
+		)
813 814
 		)
814
-	    )
815 815
 	) {
816
-	    //$buffer = $Common->getData($hosts[$id]);
817
-	    $buffer = $Common->getData($value['host']);
818
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
819
-	    $buffer = explode('\n',$buffer);
820
-	    $reset = 0;
821
-	    foreach ($buffer as $line) {
822
-    		if ($line != '') {
823
-    		    $line = explode(':', $line);
824
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
816
+		//$buffer = $Common->getData($hosts[$id]);
817
+		$buffer = $Common->getData($value['host']);
818
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
819
+		$buffer = explode('\n',$buffer);
820
+		$reset = 0;
821
+		foreach ($buffer as $line) {
822
+			if ($line != '') {
823
+				$line = explode(':', $line);
824
+				if (count($line) > 30 && $line[0] != 'callsign') {
825 825
 			$data = array();
826 826
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
827 827
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -834,37 +834,37 @@  discard block
 block discarded – undo
834 834
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
835 835
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
836 836
 			$data['latitude'] = $line[5]; // lat
837
-	        	$data['longitude'] = $line[6]; // long
838
-	        	$data['verticalrate'] = ''; // vertical rate
839
-	        	$data['squawk'] = ''; // squawk
840
-	        	$data['emergency'] = ''; // emergency
841
-	        	$data['waypoints'] = $line[30];
837
+				$data['longitude'] = $line[6]; // long
838
+				$data['verticalrate'] = ''; // vertical rate
839
+				$data['squawk'] = ''; // squawk
840
+				$data['emergency'] = ''; // emergency
841
+				$data['waypoints'] = $line[30];
842 842
 			$data['datetime'] = date('Y-m-d H:i:s');
843 843
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
844 844
 			//if (isset($line[37])) $data['last_update'] = $line[37];
845
-		        $data['departure_airport_icao'] = $line[11];
846
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
847
-		        $data['arrival_airport_icao'] = $line[13];
845
+				$data['departure_airport_icao'] = $line[11];
846
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
847
+				$data['arrival_airport_icao'] = $line[13];
848 848
 			$data['frequency'] = $line[4];
849 849
 			$data['type'] = $line[18];
850 850
 			$data['range'] = $line[19];
851 851
 			if (isset($line[35])) $data['info'] = $line[35];
852
-    			$data['id_source'] = $id_source;
853
-	    		//$data['arrival_airport_time'] = ;
854
-	    		if ($line[9] != '') {
855
-	    		    $aircraft_data = explode('/',$line[9]);
856
-	    		    if (isset($aircraft_data[1])) {
857
-	    			$data['aircraft_icao'] = $aircraft_data[1];
858
-	    		    }
859
-        		}
860
-	    		/*
852
+				$data['id_source'] = $id_source;
853
+				//$data['arrival_airport_time'] = ;
854
+				if ($line[9] != '') {
855
+					$aircraft_data = explode('/',$line[9]);
856
+					if (isset($aircraft_data[1])) {
857
+					$data['aircraft_icao'] = $aircraft_data[1];
858
+					}
859
+				}
860
+				/*
861 861
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
862 862
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
863 863
 	    		*/
864
-	    		$data['format_source'] = $value['format'];
864
+				$data['format_source'] = $value['format'];
865 865
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
866 866
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
867
-    			if ($line[3] === 'PILOT') $SI->add($data);
867
+				if ($line[3] === 'PILOT') $SI->add($data);
868 868
 			elseif ($line[3] === 'ATC') {
869 869
 				//print_r($data);
870 870
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -885,21 +885,21 @@  discard block
 block discarded – undo
885 885
 					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']);
886 886
 				}
887 887
 			}
888
-    			unset($data);
889
-    		    }
890
-    		}
891
-    	    }
892
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
893
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
894
-    	    $last_exec[$id]['last'] = time();
895
-    	} elseif ($value['format'] === 'airwhere' && 
896
-    	    (
897
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
898
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
899
-    	    )
900
-    	) {
901
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
902
-	    if ($buffer != '') {
888
+				unset($data);
889
+				}
890
+			}
891
+			}
892
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
893
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
894
+			$last_exec[$id]['last'] = time();
895
+		} elseif ($value['format'] === 'airwhere' && 
896
+			(
897
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
898
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
899
+			)
900
+		) {
901
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
902
+		if ($buffer != '') {
903 903
 		$all_data = simplexml_load_string($buffer);
904 904
 		foreach($all_data->children() as $childdata) {
905 905
 			$data = array();
@@ -921,10 +921,10 @@  discard block
 block discarded – undo
921 921
 			$SI->add($data);
922 922
 			unset($data);
923 923
 		}
924
-	    }
925
-	    $Source->deleteOldLocationByType('gs');
926
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
927
-	    if ($buffer != '') {
924
+		}
925
+		$Source->deleteOldLocationByType('gs');
926
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
927
+		if ($buffer != '') {
928 928
 		$all_data = simplexml_load_string($buffer);
929 929
 		foreach($all_data->children() as $childdata) {
930 930
 			$data = array();
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
 			}
943 943
 			unset($data);
944 944
 		}
945
-	    }
946
-	    $last_exec[$id]['last'] = time();
945
+		}
946
+		$last_exec[$id]['last'] = time();
947 947
 	/*
948 948
 	} if ($value['format'] === 'aircraftlistjson') {
949 949
 	    print_r($globalSources);
@@ -951,17 +951,17 @@  discard block
 block discarded – undo
951 951
 	    echo $globalMinFetch;
952 952
 	*/
953 953
 	} elseif ($value['format'] === 'aircraftlistjson' && 
954
-	    (
954
+		(
955 955
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
956 956
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
957
-	    )
957
+		)
958 958
 	) {
959
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
960
-	    if ($buffer != '') {
961
-	        $all_data = json_decode($buffer,true);
959
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
960
+		if ($buffer != '') {
961
+			$all_data = json_decode($buffer,true);
962 962
 		if (isset($all_data['acList'])) {
963
-		    $reset = 0;
964
-		    foreach ($all_data['acList'] as $line) {
963
+			$reset = 0;
964
+			foreach ($all_data['acList'] as $line) {
965 965
 			$data = array();
966 966
 			$data['hex'] = $line['Icao']; // hex
967 967
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -984,10 +984,10 @@  discard block
 block discarded – undo
984 984
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
985 985
 			if (isset($data['latitude'])) $SI->add($data);
986 986
 			unset($data);
987
-		    }
987
+			}
988 988
 		} elseif (is_array($all_data)) {
989
-		    $reset = 0;
990
-		    foreach ($all_data as $line) {
989
+			$reset = 0;
990
+			foreach ($all_data as $line) {
991 991
 			$data = array();
992 992
 			$data['hex'] = $line['hex']; // hex
993 993
 			$data['ident'] = $line['flight']; // ident
@@ -1007,291 +1007,291 @@  discard block
 block discarded – undo
1007 1007
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1008 1008
 			$SI->add($data);
1009 1009
 			unset($data);
1010
-		    }
1010
+			}
1011 1011
 		}
1012
-	    } elseif ($globalDebug) echo 'No data'."\n";
1013
-    	    //$last_exec['aircraftlistjson'] = time();
1014
-    	    $last_exec[$id]['last'] = time();
1015
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1016
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1017
-    	    (
1018
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1019
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1020
-    	    )
1021
-    	) {
1022
-	    $buffer = $Common->getData($value['host']);
1023
-	    $all_data = json_decode($buffer,true);
1024
-	    if (isset($all_data['planes'])) {
1012
+		} elseif ($globalDebug) echo 'No data'."\n";
1013
+			//$last_exec['aircraftlistjson'] = time();
1014
+			$last_exec[$id]['last'] = time();
1015
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1016
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1017
+			(
1018
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1019
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1020
+			)
1021
+		) {
1022
+		$buffer = $Common->getData($value['host']);
1023
+		$all_data = json_decode($buffer,true);
1024
+		if (isset($all_data['planes'])) {
1025 1025
 		$reset = 0;
1026 1026
 		foreach ($all_data['planes'] as $key => $line) {
1027
-		    $data = array();
1028
-		    $data['hex'] = $key; // hex
1029
-		    $data['ident'] = $line[3]; // ident
1030
-		    $data['altitude'] = $line[6]; // altitude
1031
-		    $data['speed'] = $line[8]; // speed
1032
-		    $data['heading'] = $line[7]; // heading
1033
-		    $data['latitude'] = $line[4]; // lat
1034
-		    $data['longitude'] = $line[5]; // long
1035
-		    //$data['verticalrate'] = $line[]; // verticale rate
1036
-		    $data['squawk'] = $line[10]; // squawk
1037
-		    $data['emergency'] = ''; // emergency
1038
-		    $data['registration'] = $line[2];
1039
-		    $data['aircraft_icao'] = $line[0];
1040
-		    $deparr = explode('-',$line[1]);
1041
-		    if (count($deparr) === 2) {
1027
+			$data = array();
1028
+			$data['hex'] = $key; // hex
1029
+			$data['ident'] = $line[3]; // ident
1030
+			$data['altitude'] = $line[6]; // altitude
1031
+			$data['speed'] = $line[8]; // speed
1032
+			$data['heading'] = $line[7]; // heading
1033
+			$data['latitude'] = $line[4]; // lat
1034
+			$data['longitude'] = $line[5]; // long
1035
+			//$data['verticalrate'] = $line[]; // verticale rate
1036
+			$data['squawk'] = $line[10]; // squawk
1037
+			$data['emergency'] = ''; // emergency
1038
+			$data['registration'] = $line[2];
1039
+			$data['aircraft_icao'] = $line[0];
1040
+			$deparr = explode('-',$line[1]);
1041
+			if (count($deparr) === 2) {
1042 1042
 			$data['departure_airport_icao'] = $deparr[0];
1043 1043
 			$data['arrival_airport_icao'] = $deparr[1];
1044
-		    }
1045
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1046
-	    	    $data['format_source'] = 'planeupdatefaa';
1047
-    		    $data['id_source'] = $id_source;
1048
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1049
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1050
-		    $SI->add($data);
1051
-		    unset($data);
1044
+			}
1045
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1046
+				$data['format_source'] = 'planeupdatefaa';
1047
+				$data['id_source'] = $id_source;
1048
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1049
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1050
+			$SI->add($data);
1051
+			unset($data);
1052 1052
 		}
1053
-	    }
1054
-	    //$last_exec['planeupdatefaa'] = time();
1055
-	    $last_exec[$id]['last'] = time();
1053
+		}
1054
+		//$last_exec['planeupdatefaa'] = time();
1055
+		$last_exec[$id]['last'] = time();
1056 1056
 	} elseif ($value['format'] === 'opensky' && 
1057
-	    (
1057
+		(
1058 1058
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1059 1059
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1060
-	    )
1060
+		)
1061 1061
 	) {
1062
-	    $buffer = $Common->getData($value['host']);
1063
-	    $all_data = json_decode($buffer,true);
1064
-	    if (isset($all_data['states'])) {
1062
+		$buffer = $Common->getData($value['host']);
1063
+		$all_data = json_decode($buffer,true);
1064
+		if (isset($all_data['states'])) {
1065 1065
 		$reset = 0;
1066 1066
 		foreach ($all_data['states'] as $key => $line) {
1067
-		    $data = array();
1068
-		    $data['hex'] = $line[0]; // hex
1069
-		    $data['ident'] = trim($line[1]); // ident
1070
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1071
-		    $data['speed'] = round($line[9]*1.94384); // speed
1072
-		    $data['heading'] = round($line[10]); // heading
1073
-		    $data['latitude'] = $line[6]; // lat
1074
-		    $data['longitude'] = $line[5]; // long
1075
-		    $data['verticalrate'] = $line[11]; // verticale rate
1076
-		    //$data['squawk'] = $line[10]; // squawk
1077
-		    //$data['emergency'] = ''; // emergency
1078
-		    //$data['registration'] = $line[2];
1079
-		    //$data['aircraft_icao'] = $line[0];
1080
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1081
-		    $data['format_source'] = 'opensky';
1082
-		    $data['id_source'] = $id_source;
1083
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1084
-		    $SI->add($data);
1085
-		    unset($data);
1067
+			$data = array();
1068
+			$data['hex'] = $line[0]; // hex
1069
+			$data['ident'] = trim($line[1]); // ident
1070
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1071
+			$data['speed'] = round($line[9]*1.94384); // speed
1072
+			$data['heading'] = round($line[10]); // heading
1073
+			$data['latitude'] = $line[6]; // lat
1074
+			$data['longitude'] = $line[5]; // long
1075
+			$data['verticalrate'] = $line[11]; // verticale rate
1076
+			//$data['squawk'] = $line[10]; // squawk
1077
+			//$data['emergency'] = ''; // emergency
1078
+			//$data['registration'] = $line[2];
1079
+			//$data['aircraft_icao'] = $line[0];
1080
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1081
+			$data['format_source'] = 'opensky';
1082
+			$data['id_source'] = $id_source;
1083
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1084
+			$SI->add($data);
1085
+			unset($data);
1086
+		}
1086 1087
 		}
1087
-	    }
1088
-	    //$last_exec['planeupdatefaa'] = time();
1089
-	    $last_exec[$id]['last'] = time();
1088
+		//$last_exec['planeupdatefaa'] = time();
1089
+		$last_exec[$id]['last'] = time();
1090 1090
 	} elseif ($value['format'] === 'aircraftjson' && 
1091
-	    (
1091
+		(
1092 1092
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1093 1093
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1094
-	    )
1094
+		)
1095 1095
 	) {
1096
-	    $buffer = $Common->getData($value['host']);
1097
-	    $all_data = json_decode($buffer,true);
1098
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1096
+		$buffer = $Common->getData($value['host']);
1097
+		$all_data = json_decode($buffer,true);
1098
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1099 1099
 		$reset = 0;
1100 1100
 		foreach ($all_data['aircraft'] as $key => $line) {
1101
-		    $data = array();
1102
-		    // add support for ground vehicule with ~ in front of hex
1103
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1104
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1105
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1106
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1107
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1108
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1109
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1110
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1111
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1112
-		    //$data['emergency'] = ''; // emergency
1113
-		    //$data['registration'] = $line[2];
1114
-		    //$data['aircraft_icao'] = $line[0];
1115
-		    $data['datetime'] = date('Y-m-d H:i:s');
1116
-		    $data['format_source'] = 'aircraftjson';
1117
-		    $data['id_source'] = $id_source;
1118
-		    if (isset($value['name']) && $value['name'] != '') {
1119
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1120
-			    else $data['source_name'] = $value['name'];
1121
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1122
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1123
-		    $SI->add($data);
1124
-		    unset($data);
1101
+			$data = array();
1102
+			// add support for ground vehicule with ~ in front of hex
1103
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1104
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1105
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1106
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1107
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1108
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1109
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1110
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1111
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1112
+			//$data['emergency'] = ''; // emergency
1113
+			//$data['registration'] = $line[2];
1114
+			//$data['aircraft_icao'] = $line[0];
1115
+			$data['datetime'] = date('Y-m-d H:i:s');
1116
+			$data['format_source'] = 'aircraftjson';
1117
+			$data['id_source'] = $id_source;
1118
+			if (isset($value['name']) && $value['name'] != '') {
1119
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1120
+				else $data['source_name'] = $value['name'];
1121
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1122
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1123
+			$SI->add($data);
1124
+			unset($data);
1125 1125
 		}
1126
-	    }
1127
-	    //$last_exec['planeupdatefaa'] = time();
1128
-	    $last_exec[$id]['last'] = time();
1126
+		}
1127
+		//$last_exec['planeupdatefaa'] = time();
1128
+		$last_exec[$id]['last'] = time();
1129 1129
 	} elseif ($value['format'] === 'planefinderclient' && 
1130
-	    (
1130
+		(
1131 1131
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1132 1132
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1133
-	    )
1133
+		)
1134 1134
 	) {
1135
-	    $buffer = $Common->getData($value['host']);
1136
-	    $all_data = json_decode($buffer,true);
1137
-	    if (isset($all_data['aircraft'])) {
1135
+		$buffer = $Common->getData($value['host']);
1136
+		$all_data = json_decode($buffer,true);
1137
+		if (isset($all_data['aircraft'])) {
1138 1138
 		$reset = 0;
1139 1139
 		foreach ($all_data['aircraft'] as $key => $line) {
1140
-		    $data = array();
1141
-		    $data['hex'] = $key; // hex
1142
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1143
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1144
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1145
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1146
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1147
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1148
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1149
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1150
-		    //$data['emergency'] = ''; // emergency
1151
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1152
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1153
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1154
-		    $data['format_source'] = 'planefinderclient';
1155
-		    $data['id_source'] = $id_source;
1156
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1157
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1158
-		    $SI->add($data);
1159
-		    unset($data);
1140
+			$data = array();
1141
+			$data['hex'] = $key; // hex
1142
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1143
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1144
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1145
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1146
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1147
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1148
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1149
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1150
+			//$data['emergency'] = ''; // emergency
1151
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1152
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1153
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1154
+			$data['format_source'] = 'planefinderclient';
1155
+			$data['id_source'] = $id_source;
1156
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1157
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1158
+			$SI->add($data);
1159
+			unset($data);
1160
+		}
1160 1161
 		}
1161
-	    }
1162
-	    $last_exec[$id]['last'] = time();
1162
+		$last_exec[$id]['last'] = time();
1163 1163
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1164 1164
 	} elseif ($value['format'] === 'fr24json' && 
1165
-	    (
1165
+		(
1166 1166
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1167 1167
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1168
-	    )
1168
+		)
1169 1169
 	) {
1170
-	    //$buffer = $Common->getData($hosts[$id]);
1171
-	    $buffer = $Common->getData($value['host']);
1172
-	    $all_data = json_decode($buffer,true);
1173
-	    if (!empty($all_data)) $reset = 0;
1174
-	    foreach ($all_data as $key => $line) {
1170
+		//$buffer = $Common->getData($hosts[$id]);
1171
+		$buffer = $Common->getData($value['host']);
1172
+		$all_data = json_decode($buffer,true);
1173
+		if (!empty($all_data)) $reset = 0;
1174
+		foreach ($all_data as $key => $line) {
1175 1175
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1176
-		    $data = array();
1177
-		    $data['hex'] = $line[0];
1178
-		    $data['ident'] = $line[16]; //$line[13]
1179
-	    	    $data['altitude'] = $line[4]; // altitude
1180
-	    	    $data['speed'] = $line[5]; // speed
1181
-	    	    $data['heading'] = $line[3]; // heading
1182
-	    	    $data['latitude'] = $line[1]; // lat
1183
-	    	    $data['longitude'] = $line[2]; // long
1184
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1185
-	    	    $data['squawk'] = $line[6]; // squawk
1186
-	    	    $data['aircraft_icao'] = $line[8];
1187
-	    	    $data['registration'] = $line[9];
1188
-		    $data['departure_airport_iata'] = $line[11];
1189
-		    $data['arrival_airport_iata'] = $line[12];
1190
-	    	    $data['emergency'] = ''; // emergency
1191
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1192
-	    	    $data['format_source'] = 'fr24json';
1193
-    		    $data['id_source'] = $id_source;
1194
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1195
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1196
-		    $SI->add($data);
1197
-		    unset($data);
1176
+			$data = array();
1177
+			$data['hex'] = $line[0];
1178
+			$data['ident'] = $line[16]; //$line[13]
1179
+				$data['altitude'] = $line[4]; // altitude
1180
+				$data['speed'] = $line[5]; // speed
1181
+				$data['heading'] = $line[3]; // heading
1182
+				$data['latitude'] = $line[1]; // lat
1183
+				$data['longitude'] = $line[2]; // long
1184
+				$data['verticalrate'] = $line[15]; // verticale rate
1185
+				$data['squawk'] = $line[6]; // squawk
1186
+				$data['aircraft_icao'] = $line[8];
1187
+				$data['registration'] = $line[9];
1188
+			$data['departure_airport_iata'] = $line[11];
1189
+			$data['arrival_airport_iata'] = $line[12];
1190
+				$data['emergency'] = ''; // emergency
1191
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1192
+				$data['format_source'] = 'fr24json';
1193
+				$data['id_source'] = $id_source;
1194
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1195
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1196
+			$SI->add($data);
1197
+			unset($data);
1198 1198
 		}
1199
-	    }
1200
-	    //$last_exec['fr24json'] = time();
1201
-	    $last_exec[$id]['last'] = time();
1199
+		}
1200
+		//$last_exec['fr24json'] = time();
1201
+		$last_exec[$id]['last'] = time();
1202 1202
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1203 1203
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1204
-	    (
1204
+		(
1205 1205
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1206 1206
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1207
-	    )
1207
+		)
1208 1208
 	) {
1209
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1210
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1211
-	    //echo $buffer;
1212
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1213
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1214
-	    $all_data = json_decode($buffer,true);
1215
-	    if (json_last_error() != JSON_ERROR_NONE) {
1209
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1210
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1211
+		//echo $buffer;
1212
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1213
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1214
+		$all_data = json_decode($buffer,true);
1215
+		if (json_last_error() != JSON_ERROR_NONE) {
1216 1216
 		die(json_last_error_msg());
1217
-	    }
1218
-	    if (isset($all_data['mrkrs'])) {
1217
+		}
1218
+		if (isset($all_data['mrkrs'])) {
1219 1219
 		$reset = 0;
1220 1220
 		foreach ($all_data['mrkrs'] as $key => $line) {
1221
-		    if (isset($line['inf'])) {
1221
+			if (isset($line['inf'])) {
1222 1222
 			$data = array();
1223 1223
 			$data['hex'] = $line['inf']['ia'];
1224 1224
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1225
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1226
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1227
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1228
-	    		$data['latitude'] = $line['pt'][0]; // lat
1229
-	    		$data['longitude'] = $line['pt'][1]; // long
1230
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1231
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1232
-	    		//$data['aircraft_icao'] = $line[8];
1233
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1225
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1226
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1227
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1228
+				$data['latitude'] = $line['pt'][0]; // lat
1229
+				$data['longitude'] = $line['pt'][1]; // long
1230
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1231
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1232
+				//$data['aircraft_icao'] = $line[8];
1233
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1234 1234
 			//$data['departure_airport_iata'] = $line[11];
1235 1235
 			//$data['arrival_airport_iata'] = $line[12];
1236
-	    		//$data['emergency'] = ''; // emergency
1236
+				//$data['emergency'] = ''; // emergency
1237 1237
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1238
-	    		$data['format_source'] = 'radarvirtueljson';
1239
-    			$data['id_source'] = $id_source;
1238
+				$data['format_source'] = 'radarvirtueljson';
1239
+				$data['id_source'] = $id_source;
1240 1240
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1241 1241
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1242 1242
 			$SI->add($data);
1243 1243
 			unset($data);
1244
-		    }
1244
+			}
1245
+		}
1245 1246
 		}
1246
-	    }
1247
-	    //$last_exec['radarvirtueljson'] = time();
1248
-	    $last_exec[$id]['last'] = time();
1247
+		//$last_exec['radarvirtueljson'] = time();
1248
+		$last_exec[$id]['last'] = time();
1249 1249
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1250 1250
 	} elseif ($value['format'] === 'pirepsjson' && 
1251
-	    (
1251
+		(
1252 1252
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1253 1253
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1254
-	    )
1254
+		)
1255 1255
 	) {
1256
-	    //$buffer = $Common->getData($hosts[$id]);
1257
-	    $buffer = $Common->getData($value['host'].'?'.time());
1258
-	    $all_data = json_decode(utf8_encode($buffer),true);
1256
+		//$buffer = $Common->getData($hosts[$id]);
1257
+		$buffer = $Common->getData($value['host'].'?'.time());
1258
+		$all_data = json_decode(utf8_encode($buffer),true);
1259 1259
 	    
1260
-	    if (isset($all_data['pireps'])) {
1260
+		if (isset($all_data['pireps'])) {
1261 1261
 		$reset = 0;
1262
-	        foreach ($all_data['pireps'] as $line) {
1263
-		    $data = array();
1264
-		    $data['id'] = $line['id'];
1265
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1266
-		    $data['ident'] = $line['callsign']; // ident
1267
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1268
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1269
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1270
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1271
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1272
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1273
-		    $data['latitude'] = $line['lat']; // lat
1274
-		    $data['longitude'] = $line['lon']; // long
1275
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1276
-		    //$data['squawk'] = $line['squawk']; // squawk
1277
-		    //$data['emergency'] = ''; // emergency
1278
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1279
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1280
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1281
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1282
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1283
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1284
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1285
-		    else $data['info'] = '';
1286
-		    $data['format_source'] = 'pireps';
1287
-    		    $data['id_source'] = $id_source;
1288
-		    $data['datetime'] = date('Y-m-d H:i:s');
1289
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1290
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1291
-		    if ($line['icon'] === 'plane') {
1262
+			foreach ($all_data['pireps'] as $line) {
1263
+			$data = array();
1264
+			$data['id'] = $line['id'];
1265
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1266
+			$data['ident'] = $line['callsign']; // ident
1267
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1268
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1269
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1270
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1271
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1272
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1273
+			$data['latitude'] = $line['lat']; // lat
1274
+			$data['longitude'] = $line['lon']; // long
1275
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1276
+			//$data['squawk'] = $line['squawk']; // squawk
1277
+			//$data['emergency'] = ''; // emergency
1278
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1279
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1280
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1281
+			//$data['arrival_airport_time'] = $line['arrtime'];
1282
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1283
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1284
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1285
+			else $data['info'] = '';
1286
+			$data['format_source'] = 'pireps';
1287
+				$data['id_source'] = $id_source;
1288
+			$data['datetime'] = date('Y-m-d H:i:s');
1289
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1290
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1291
+			if ($line['icon'] === 'plane') {
1292 1292
 			$SI->add($data);
1293
-		    //    print_r($data);
1294
-    		    } elseif ($line['icon'] === 'ct') {
1293
+			//    print_r($data);
1294
+				} elseif ($line['icon'] === 'ct') {
1295 1295
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1296 1296
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1297 1297
 			$typec = substr($data['ident'],-3);
@@ -1306,209 +1306,209 @@  discard block
 block discarded – undo
1306 1306
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1307 1307
 			else $data['type'] = 'Observer';
1308 1308
 			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']);
1309
-		    }
1310
-		    unset($data);
1309
+			}
1310
+			unset($data);
1311
+		}
1311 1312
 		}
1312
-	    }
1313
-	    //$last_exec['pirepsjson'] = time();
1314
-	    $last_exec[$id]['last'] = time();
1313
+		//$last_exec['pirepsjson'] = time();
1314
+		$last_exec[$id]['last'] = time();
1315 1315
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1316 1316
 	} elseif ($value['format'] === 'phpvmacars' && 
1317
-	    (
1317
+		(
1318 1318
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1319 1319
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1320
-	    )
1320
+		)
1321 1321
 	) {
1322
-	    //$buffer = $Common->getData($hosts[$id]);
1323
-	    if ($globalDebug) echo 'Get Data...'."\n";
1324
-	    $buffer = $Common->getData($value['host']);
1325
-	    $all_data = json_decode($buffer,true);
1326
-	    if ($buffer != '' && is_array($all_data)) {
1322
+		//$buffer = $Common->getData($hosts[$id]);
1323
+		if ($globalDebug) echo 'Get Data...'."\n";
1324
+		$buffer = $Common->getData($value['host']);
1325
+		$all_data = json_decode($buffer,true);
1326
+		if ($buffer != '' && is_array($all_data)) {
1327 1327
 		$reset = 0;
1328 1328
 		foreach ($all_data as $line) {
1329
-	    	    $data = array();
1330
-	    	    //$data['id'] = $line['id']; // id not usable
1331
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1332
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1333
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1334
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1335
-	    	    $data['ident'] = $line['flightnum']; // ident
1336
-	    	    $data['altitude'] = $line['alt']; // altitude
1337
-	    	    $data['speed'] = $line['gs']; // speed
1338
-	    	    $data['heading'] = $line['heading']; // heading
1339
-	    	    $data['latitude'] = $line['lat']; // lat
1340
-	    	    $data['longitude'] = $line['lng']; // long
1341
-	    	    $data['verticalrate'] = ''; // verticale rate
1342
-	    	    $data['squawk'] = ''; // squawk
1343
-	    	    $data['emergency'] = ''; // emergency
1344
-	    	    //$data['datetime'] = $line['lastupdate'];
1345
-	    	    //$data['last_update'] = $line['lastupdate'];
1346
-	    	    if (isset($value['timezone'])) {
1347
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1348
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1349
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1350
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1351
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1352
-	    	    $data['departure_airport_time'] = $line['deptime'];
1353
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1354
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1355
-    		    if (isset($line['registration'])) {
1356
-    			$data['registration'] = $line['registration'];
1357
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1358
-    		    } else $data['registration'] = $line['aircraft'];
1359
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1360
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1361
-		    if (isset($line['aircraftname'])) {
1329
+				$data = array();
1330
+				//$data['id'] = $line['id']; // id not usable
1331
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1332
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1333
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1334
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1335
+				$data['ident'] = $line['flightnum']; // ident
1336
+				$data['altitude'] = $line['alt']; // altitude
1337
+				$data['speed'] = $line['gs']; // speed
1338
+				$data['heading'] = $line['heading']; // heading
1339
+				$data['latitude'] = $line['lat']; // lat
1340
+				$data['longitude'] = $line['lng']; // long
1341
+				$data['verticalrate'] = ''; // verticale rate
1342
+				$data['squawk'] = ''; // squawk
1343
+				$data['emergency'] = ''; // emergency
1344
+				//$data['datetime'] = $line['lastupdate'];
1345
+				//$data['last_update'] = $line['lastupdate'];
1346
+				if (isset($value['timezone'])) {
1347
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1348
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1349
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1350
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1351
+				$data['departure_airport_icao'] = $line['depicao'];
1352
+				$data['departure_airport_time'] = $line['deptime'];
1353
+				$data['arrival_airport_icao'] = $line['arricao'];
1354
+				$data['arrival_airport_time'] = $line['arrtime'];
1355
+				if (isset($line['registration'])) {
1356
+				$data['registration'] = $line['registration'];
1357
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1358
+				} else $data['registration'] = $line['aircraft'];
1359
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1360
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1361
+			if (isset($line['aircraftname'])) {
1362 1362
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1363 1363
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1364
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1365
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1366
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1367
-	    		else {
1368
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1369
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1370
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1371
-	    		}
1372
-	    	    }
1373
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1374
-    		    $data['id_source'] = $id_source;
1375
-	    	    $data['format_source'] = 'phpvmacars';
1376
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1377
-		    $SI->add($data);
1378
-		    unset($data);
1364
+				$aircraft_data = explode('-',$line['aircraftname']);
1365
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1366
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1367
+				else {
1368
+					$aircraft_data = explode(' ',$line['aircraftname']);
1369
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1370
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1371
+				}
1372
+				}
1373
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1374
+				$data['id_source'] = $id_source;
1375
+				$data['format_source'] = 'phpvmacars';
1376
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1377
+			$SI->add($data);
1378
+			unset($data);
1379 1379
 		}
1380 1380
 		if ($globalDebug) echo 'No more data...'."\n";
1381 1381
 		unset($buffer);
1382 1382
 		unset($all_data);
1383
-	    }
1384
-	    //$last_exec['phpvmacars'] = time();
1385
-	    $last_exec[$id]['last'] = time();
1383
+		}
1384
+		//$last_exec['phpvmacars'] = time();
1385
+		$last_exec[$id]['last'] = time();
1386 1386
 	} elseif ($value['format'] === 'vaos' && 
1387
-	    (
1387
+		(
1388 1388
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1389 1389
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1390
-	    )
1390
+		)
1391 1391
 	) {
1392
-	    //$buffer = $Common->getData($hosts[$id]);
1393
-	    if ($globalDebug) echo 'Get Data...'."\n";
1394
-	    $buffer = $Common->getData($value['host']);
1395
-	    $all_data = json_decode($buffer,true);
1396
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1392
+		//$buffer = $Common->getData($hosts[$id]);
1393
+		if ($globalDebug) echo 'Get Data...'."\n";
1394
+		$buffer = $Common->getData($value['host']);
1395
+		$all_data = json_decode($buffer,true);
1396
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1397 1397
 		$reset = 0;
1398 1398
 		foreach ($all_data['ACARSData'] as $line) {
1399
-		    //print_r($line);
1400
-	    	    $data = array();
1401
-	    	    //$data['id'] = $line['id']; // id not usable
1402
-	    	    $data['id'] = $line['id'];
1403
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1404
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1405
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1406
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1407
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1408
-	    	    $data['altitude'] = $line['altitude']; // altitude
1409
-	    	    $data['speed'] = $line['groundspeed']; // speed
1410
-	    	    $data['heading'] = $line['heading']; // heading
1411
-	    	    $data['latitude'] = $line['lat']; // lat
1412
-	    	    $data['longitude'] = $line['lon']; // long
1413
-	    	    //$data['verticalrate'] = ''; // verticale rate
1414
-	    	    //$data['squawk'] = ''; // squawk
1415
-	    	    //$data['emergency'] = ''; // emergency
1416
-	    	    if (isset($value['timezone'])) {
1417
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1418
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1419
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1420
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1399
+			//print_r($line);
1400
+				$data = array();
1401
+				//$data['id'] = $line['id']; // id not usable
1402
+				$data['id'] = $line['id'];
1403
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1404
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1405
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1406
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1407
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1408
+				$data['altitude'] = $line['altitude']; // altitude
1409
+				$data['speed'] = $line['groundspeed']; // speed
1410
+				$data['heading'] = $line['heading']; // heading
1411
+				$data['latitude'] = $line['lat']; // lat
1412
+				$data['longitude'] = $line['lon']; // long
1413
+				//$data['verticalrate'] = ''; // verticale rate
1414
+				//$data['squawk'] = ''; // squawk
1415
+				//$data['emergency'] = ''; // emergency
1416
+				if (isset($value['timezone'])) {
1417
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1418
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1419
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1420
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1421 1421
 	    	    
1422
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1423
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1424
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1425
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1426
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1422
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1423
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1424
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1425
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1426
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1427 1427
 
1428
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1429
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1430
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1428
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1429
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1430
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1431 1431
 
1432
-    		    $data['id_source'] = $id_source;
1433
-	    	    $data['format_source'] = 'vaos';
1434
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1435
-		    $SI->add($data);
1436
-		    unset($data);
1432
+				$data['id_source'] = $id_source;
1433
+				$data['format_source'] = 'vaos';
1434
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1435
+			$SI->add($data);
1436
+			unset($data);
1437 1437
 		}
1438 1438
 		if ($globalDebug) echo 'No more data...'."\n";
1439 1439
 		unset($buffer);
1440 1440
 		unset($all_data);
1441
-	    }
1442
-	    //$last_exec['phpvmacars'] = time();
1443
-	    $last_exec[$id]['last'] = time();
1441
+		}
1442
+		//$last_exec['phpvmacars'] = time();
1443
+		$last_exec[$id]['last'] = time();
1444 1444
 	} elseif ($value['format'] === 'vam' && 
1445
-	    (
1445
+		(
1446 1446
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1447 1447
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1448
-	    )
1448
+		)
1449 1449
 	) {
1450
-	    //$buffer = $Common->getData($hosts[$id]);
1451
-	    if ($globalDebug) echo 'Get Data...'."\n";
1452
-	    $buffer = $Common->getData($value['host']);
1453
-	    $all_data = json_decode($buffer,true);
1454
-	    if ($buffer != '' && is_array($all_data)) {
1450
+		//$buffer = $Common->getData($hosts[$id]);
1451
+		if ($globalDebug) echo 'Get Data...'."\n";
1452
+		$buffer = $Common->getData($value['host']);
1453
+		$all_data = json_decode($buffer,true);
1454
+		if ($buffer != '' && is_array($all_data)) {
1455 1455
 		$reset = 0;
1456 1456
 		foreach ($all_data as $line) {
1457
-	    	    $data = array();
1458
-	    	    //$data['id'] = $line['id']; // id not usable
1459
-	    	    $data['id'] = trim($line['flight_id']);
1460
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1461
-	    	    $data['pilot_name'] = $line['pilot_name'];
1462
-	    	    $data['pilot_id'] = $line['pilot_id'];
1463
-	    	    $data['ident'] = trim($line['callsign']); // ident
1464
-	    	    $data['altitude'] = $line['altitude']; // altitude
1465
-	    	    $data['speed'] = $line['gs']; // speed
1466
-	    	    $data['heading'] = $line['heading']; // heading
1467
-	    	    $data['latitude'] = $line['latitude']; // lat
1468
-	    	    $data['longitude'] = $line['longitude']; // long
1469
-	    	    $data['verticalrate'] = ''; // verticale rate
1470
-	    	    $data['squawk'] = ''; // squawk
1471
-	    	    $data['emergency'] = ''; // emergency
1472
-	    	    //$data['datetime'] = $line['lastupdate'];
1473
-	    	    $data['last_update'] = $line['last_update'];
1474
-		    $data['datetime'] = date('Y-m-d H:i:s');
1475
-	    	    $data['departure_airport_icao'] = $line['departure'];
1476
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1477
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1478
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1479
-    		    //$data['registration'] = $line['aircraft'];
1480
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1481
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1482
-    		    $data['id_source'] = $id_source;
1483
-	    	    $data['format_source'] = 'vam';
1484
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1485
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1486
-		    $SI->add($data);
1487
-		    unset($data);
1457
+				$data = array();
1458
+				//$data['id'] = $line['id']; // id not usable
1459
+				$data['id'] = trim($line['flight_id']);
1460
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1461
+				$data['pilot_name'] = $line['pilot_name'];
1462
+				$data['pilot_id'] = $line['pilot_id'];
1463
+				$data['ident'] = trim($line['callsign']); // ident
1464
+				$data['altitude'] = $line['altitude']; // altitude
1465
+				$data['speed'] = $line['gs']; // speed
1466
+				$data['heading'] = $line['heading']; // heading
1467
+				$data['latitude'] = $line['latitude']; // lat
1468
+				$data['longitude'] = $line['longitude']; // long
1469
+				$data['verticalrate'] = ''; // verticale rate
1470
+				$data['squawk'] = ''; // squawk
1471
+				$data['emergency'] = ''; // emergency
1472
+				//$data['datetime'] = $line['lastupdate'];
1473
+				$data['last_update'] = $line['last_update'];
1474
+			$data['datetime'] = date('Y-m-d H:i:s');
1475
+				$data['departure_airport_icao'] = $line['departure'];
1476
+				//$data['departure_airport_time'] = $line['departure_time'];
1477
+				$data['arrival_airport_icao'] = $line['arrival'];
1478
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1479
+				//$data['registration'] = $line['aircraft'];
1480
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1481
+				$data['aircraft_icao'] = $line['plane_type'];
1482
+				$data['id_source'] = $id_source;
1483
+				$data['format_source'] = 'vam';
1484
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1485
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1486
+			$SI->add($data);
1487
+			unset($data);
1488 1488
 		}
1489 1489
 		if ($globalDebug) echo 'No more data...'."\n";
1490 1490
 		unset($buffer);
1491 1491
 		unset($all_data);
1492
-	    }
1493
-	    //$last_exec['phpvmacars'] = time();
1494
-	    $last_exec[$id]['last'] = time();
1492
+		}
1493
+		//$last_exec['phpvmacars'] = time();
1494
+		$last_exec[$id]['last'] = time();
1495 1495
 	} elseif ($value['format'] === 'blitzortung' && 
1496
-	    (
1496
+		(
1497 1497
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1498 1498
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1499
-	    )
1499
+		)
1500 1500
 	) {
1501
-	    //$buffer = $Common->getData($hosts[$id]);
1502
-	    if ($globalDebug) echo 'Get Data...'."\n";
1503
-	    $buffer = $Common->getData($value['host']);
1504
-	    $all_data = json_decode($buffer,true);
1505
-	    if ($buffer != '') {
1501
+		//$buffer = $Common->getData($hosts[$id]);
1502
+		if ($globalDebug) echo 'Get Data...'."\n";
1503
+		$buffer = $Common->getData($value['host']);
1504
+		$all_data = json_decode($buffer,true);
1505
+		if ($buffer != '') {
1506 1506
 		$Source->deleteLocationBySource('blitzortung');
1507 1507
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1508 1508
 		$buffer = explode('\n',$buffer);
1509 1509
 		foreach ($buffer as $buffer_line) {
1510
-		    $line = json_decode($buffer_line,true);
1511
-		    if (isset($line['time'])) {
1510
+			$line = json_decode($buffer_line,true);
1511
+			if (isset($line['time'])) {
1512 1512
 			$data = array();
1513 1513
 			$data['altitude'] = $line['alt']; // altitude
1514 1514
 			$data['latitude'] = $line['lat']; // lat
@@ -1520,94 +1520,94 @@  discard block
 block discarded – undo
1520 1520
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1521 1521
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1522 1522
 			unset($data);
1523
-		    }
1523
+			}
1524 1524
 		}
1525 1525
 		if ($globalDebug) echo 'No more data...'."\n";
1526 1526
 		unset($buffer);
1527
-	    }
1528
-	    $last_exec[$id]['last'] = time();
1527
+		}
1528
+		$last_exec[$id]['last'] = time();
1529 1529
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1530 1530
 	} 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') {
1531
-	    //$last_exec[$id]['last'] = time();
1532
-	    //$read = array( $sockets[$id] );
1533
-	    $read = $sockets;
1534
-	    $write = NULL;
1535
-	    $e = NULL;
1536
-	    $n = socket_select($read, $write, $e, $timeout);
1537
-	    if ($e != NULL) var_dump($e);
1538
-	    if ($n > 0) {
1531
+		//$last_exec[$id]['last'] = time();
1532
+		//$read = array( $sockets[$id] );
1533
+		$read = $sockets;
1534
+		$write = NULL;
1535
+		$e = NULL;
1536
+		$n = socket_select($read, $write, $e, $timeout);
1537
+		if ($e != NULL) var_dump($e);
1538
+		if ($n > 0) {
1539 1539
 		$reset = 0;
1540 1540
 		foreach ($read as $nb => $r) {
1541
-		    //$value = $formats[$nb];
1542
-		    $format = $globalSources[$nb]['format'];
1543
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1541
+			//$value = $formats[$nb];
1542
+			$format = $globalSources[$nb]['format'];
1543
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1544 1544
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1545
-		    } elseif ($format === 'vrstcp') {
1545
+			} elseif ($format === 'vrstcp') {
1546 1546
 			$buffer = @socket_read($r, 6000);
1547
-		    } else {
1547
+			} else {
1548 1548
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1549
-		    }
1550
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1551
-		    //echo $buffer."\n";
1552
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1553
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1554
-		    $error = false;
1555
-		    //$SI::del();
1556
-		    if ($buffer !== FALSE) {
1549
+			}
1550
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1551
+			//echo $buffer."\n";
1552
+			// lets play nice and handle signals such as ctrl-c/kill properly
1553
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1554
+			$error = false;
1555
+			//$SI::del();
1556
+			if ($buffer !== FALSE) {
1557 1557
 			if ($format === 'vrstcp') {
1558
-			    $buffer = explode('},{',$buffer);
1558
+				$buffer = explode('},{',$buffer);
1559 1559
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1560
-		    }
1561
-		    // SBS format is CSV format
1562
-		    if ($buffer !== FALSE && $buffer !== '') {
1560
+			}
1561
+			// SBS format is CSV format
1562
+			if ($buffer !== FALSE && $buffer !== '') {
1563 1563
 			$tt[$format] = 0;
1564 1564
 			if ($format === 'acarssbs3') {
1565
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1566
-			    $ACARS->add(trim($buffer));
1567
-			    $ACARS->deleteLiveAcarsData();
1565
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1566
+				$ACARS->add(trim($buffer));
1567
+				$ACARS->deleteLiveAcarsData();
1568 1568
 			} elseif ($format === 'raw') {
1569
-			    // AVR format
1570
-			    $data = $SBS->parse($buffer);
1571
-			    if (is_array($data)) {
1569
+				// AVR format
1570
+				$data = $SBS->parse($buffer);
1571
+				if (is_array($data)) {
1572 1572
 				$data['datetime'] = date('Y-m-d H:i:s');
1573 1573
 				$data['format_source'] = 'raw';
1574 1574
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1575 1575
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1576 1576
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1577 1577
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1578
-			    }
1578
+				}
1579 1579
 			} elseif ($format === 'ais') {
1580
-			    $ais_data = $AIS->parse_line(trim($buffer));
1581
-			    $data = array();
1582
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1583
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1584
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1585
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1586
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1587
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1588
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1589
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1590
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1591
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1592
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1593
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1594
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1595
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1596
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1597
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1580
+				$ais_data = $AIS->parse_line(trim($buffer));
1581
+				$data = array();
1582
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1583
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1584
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1585
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1586
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1587
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1588
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1589
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1590
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1591
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1592
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1593
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1594
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1595
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1596
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1597
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1598 1598
 
1599
-			    if (isset($ais_data['timestamp'])) {
1599
+				if (isset($ais_data['timestamp'])) {
1600 1600
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1601
-			    } else {
1601
+				} else {
1602 1602
 				$data['datetime'] = date('Y-m-d H:i:s');
1603
-			    }
1604
-			    $data['format_source'] = 'aisnmea';
1605
-    			    $data['id_source'] = $id_source;
1606
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1607
-			    unset($data);
1608
-                        } elseif ($format === 'flightgearsp') {
1609
-                    	    //echo $buffer."\n";
1610
-                    	    if (strlen($buffer) > 5) {
1603
+				}
1604
+				$data['format_source'] = 'aisnmea';
1605
+					$data['id_source'] = $id_source;
1606
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1607
+				unset($data);
1608
+						} elseif ($format === 'flightgearsp') {
1609
+							//echo $buffer."\n";
1610
+							if (strlen($buffer) > 5) {
1611 1611
 				$line = explode(',',$buffer);
1612 1612
 				$data = array();
1613 1613
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1624,38 +1624,38 @@  discard block
 block discarded – undo
1624 1624
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1625 1625
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1626 1626
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1627
-			    }
1628
-                        } elseif ($format === 'acars') {
1629
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1630
-			    $ACARS->add(trim($buffer));
1631
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1632
-			    $ACARS->deleteLiveAcarsData();
1627
+				}
1628
+						} elseif ($format === 'acars') {
1629
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1630
+				$ACARS->add(trim($buffer));
1631
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1632
+				$ACARS->deleteLiveAcarsData();
1633 1633
 			} elseif ($format === 'flightgearmp') {
1634
-			    if (substr($buffer,0,1) != '#') {
1634
+				if (substr($buffer,0,1) != '#') {
1635 1635
 				$data = array();
1636 1636
 				//echo $buffer."\n";
1637 1637
 				$line = explode(' ',$buffer);
1638 1638
 				if (count($line) === 11) {
1639
-				    $userserver = explode('@',$line[0]);
1640
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1641
-				    $data['ident'] = $userserver[0];
1642
-				    $data['registration'] = $userserver[0];
1643
-				    $data['latitude'] = $line[4];
1644
-				    $data['longitude'] = $line[5];
1645
-				    $data['altitude'] = $line[6];
1646
-				    $data['datetime'] = date('Y-m-d H:i:s');
1647
-				    $aircraft_type = $line[10];
1648
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1649
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1650
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1651
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1639
+					$userserver = explode('@',$line[0]);
1640
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1641
+					$data['ident'] = $userserver[0];
1642
+					$data['registration'] = $userserver[0];
1643
+					$data['latitude'] = $line[4];
1644
+					$data['longitude'] = $line[5];
1645
+					$data['altitude'] = $line[6];
1646
+					$data['datetime'] = date('Y-m-d H:i:s');
1647
+					$aircraft_type = $line[10];
1648
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1649
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1650
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1651
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1652
+				}
1652 1653
 				}
1653
-			    }
1654 1654
 			} elseif ($format === 'beast') {
1655
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1656
-			    die;
1655
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1656
+				die;
1657 1657
 			} elseif ($format === 'vrstcp') {
1658
-			    foreach($buffer as $all_data) {
1658
+				foreach($buffer as $all_data) {
1659 1659
 				$line = json_decode('{'.$all_data.'}',true);
1660 1660
 				$data = array();
1661 1661
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1675,158 +1675,158 @@  discard block
 block discarded – undo
1675 1675
 				*/
1676 1676
 				$data['datetime'] = date('Y-m-d H:i:s');
1677 1677
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1678
-		    		$data['format_source'] = 'vrstcp';
1678
+					$data['format_source'] = 'vrstcp';
1679 1679
 				$data['id_source'] = $id_source;
1680 1680
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1681 1681
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1682 1682
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1683 1683
 				unset($data);
1684
-			    }
1684
+				}
1685 1685
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1686
-			    $line = explode("\t", $buffer);
1687
-			    for($k = 0; $k < count($line); $k=$k+2) {
1686
+				$line = explode("\t", $buffer);
1687
+				for($k = 0; $k < count($line); $k=$k+2) {
1688 1688
 				$key = $line[$k];
1689
-			        $lined[$key] = $line[$k+1];
1690
-			    }
1691
-    			    if (count($lined) > 3) {
1692
-    				$data['hex'] = $lined['hexid'];
1693
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1694
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1695
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1696
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1697
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1698
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1699
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1700
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1701
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1702
-    				$data['id_source'] = $id_source;
1703
-    				$data['format_source'] = 'tsv';
1704
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1705
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1689
+					$lined[$key] = $line[$k+1];
1690
+				}
1691
+					if (count($lined) > 3) {
1692
+					$data['hex'] = $lined['hexid'];
1693
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1694
+					$data['datetime'] = date('Y-m-d H:i:s');;
1695
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1696
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1697
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1698
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1699
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1700
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1701
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1702
+					$data['id_source'] = $id_source;
1703
+					$data['format_source'] = 'tsv';
1704
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1705
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1706 1706
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1707
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1708
-    				unset($lined);
1709
-    				unset($data);
1710
-    			    } else $error = true;
1707
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1708
+					unset($lined);
1709
+					unset($data);
1710
+					} else $error = true;
1711 1711
 			} elseif ($format === 'aprs' && $use_aprs) {
1712
-			    if ($aprs_connect === 0) {
1712
+				if ($aprs_connect === 0) {
1713 1713
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1714 1714
 				$aprs_connect = 1;
1715
-			    }
1715
+				}
1716 1716
 			    
1717
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1717
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1718 1718
 				$aprs_last_tx = time();
1719 1719
 				$data_aprs = "# Keep alive";
1720 1720
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1721
-			    }
1721
+				}
1722 1722
 			    
1723
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1724
-			    //echo 'APRS data : '.$buffer."\n";
1725
-			    $buffer = str_replace('APRS <- ','',$buffer);
1726
-			    $buffer = str_replace('APRS -> ','',$buffer);
1727
-			    //echo $buffer."\n";
1728
-			    date_default_timezone_set('UTC');
1729
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1723
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1724
+				//echo 'APRS data : '.$buffer."\n";
1725
+				$buffer = str_replace('APRS <- ','',$buffer);
1726
+				$buffer = str_replace('APRS -> ','',$buffer);
1727
+				//echo $buffer."\n";
1728
+				date_default_timezone_set('UTC');
1729
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1730 1730
 				$line = $APRS->parse($buffer);
1731 1731
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1732 1732
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1733
-				    $aprs_last_tx = time();
1734
-				    $data = array();
1735
-				    //print_r($line);
1736
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1737
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1738
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1739
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1740
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1741
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1742
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1743
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1744
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1745
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1746
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1747
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1748
-				    $data['latitude'] = $line['latitude'];
1749
-				    $data['longitude'] = $line['longitude'];
1750
-				    //$data['verticalrate'] = $line[16];
1751
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1752
-				    //else $data['speed'] = 0;
1753
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1754
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1755
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1756
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1733
+					$aprs_last_tx = time();
1734
+					$data = array();
1735
+					//print_r($line);
1736
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1737
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1738
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1739
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1740
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1741
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1742
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1743
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1744
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1745
+					else $data['datetime'] = date('Y-m-d H:i:s');
1746
+					//$data['datetime'] = date('Y-m-d H:i:s');
1747
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1748
+					$data['latitude'] = $line['latitude'];
1749
+					$data['longitude'] = $line['longitude'];
1750
+					//$data['verticalrate'] = $line[16];
1751
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1752
+					//else $data['speed'] = 0;
1753
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1754
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1755
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1756
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1757 1757
 				    
1758
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1759
-				    //else echo 'No heading...'."\n";
1760
-				    //else $data['heading'] = 0;
1761
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1762
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1763
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1764
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1765
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1766
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1767
-    				    $data['id_source'] = $id_source;
1768
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1769
-				    else $data['format_source'] = 'aprs';
1770
-				    $data['source_name'] = $line['source'];
1771
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1772
-				    else $data['source_type'] = 'flarm';
1773
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1774
-				    $currentdate = date('Y-m-d H:i:s');
1775
-				    $aprsdate = strtotime($data['datetime']);
1776
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1777
-				    // Accept data if time <= system time + 20s
1778
-				    //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'])))) {
1779
-				    if (
1758
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1759
+					//else echo 'No heading...'."\n";
1760
+					//else $data['heading'] = 0;
1761
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1762
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1763
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1764
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1765
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1766
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1767
+						$data['id_source'] = $id_source;
1768
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1769
+					else $data['format_source'] = 'aprs';
1770
+					$data['source_name'] = $line['source'];
1771
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1772
+					else $data['source_type'] = 'flarm';
1773
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1774
+					$currentdate = date('Y-m-d H:i:s');
1775
+					$aprsdate = strtotime($data['datetime']);
1776
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1777
+					// Accept data if time <= system time + 20s
1778
+					//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'])))) {
1779
+					if (
1780 1780
 					($data['source_type'] === 'modes') || 
1781 1781
 					isset($line['stealth']) && 
1782 1782
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1783 1783
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1784 1784
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1785 1785
 					$send = $SI->add($data);
1786
-				    } elseif ($data['source_type'] === 'ais') {
1786
+					} elseif ($data['source_type'] === 'ais') {
1787 1787
 					$data['type'] = '';
1788 1788
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1789
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1789
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1790 1790
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1791
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1792
-					    //$line['symbol'] === 'Balloon' ||
1793
-					    $line['symbol'] === 'Glider' || 
1794
-					    $line['symbol'] === 'No. Plane' || 
1795
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1796
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1797
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1798
-					    $send = $SI->add($data);
1799
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1800
-					    $line['symbol'] === 'Yacht (Sail)' || 
1801
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1802
-					    $send = $MI->add($data);
1803
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1804
-					    $line['symbol'] === 'Car' || 
1805
-					    $line['symbol'] === 'Ambulance' || 
1806
-					    $line['symbol'] === 'Van' || 
1807
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1808
-					    $line['symbol'] === 'Motorcycle' || 
1809
-					    $line['symbol'] === 'Tractor' || 
1810
-					    $line['symbol'] === 'Police' || 
1811
-					    $line['symbol'] === 'Bike' || 
1812
-					    $line['symbol'] === 'Jogger' || 
1813
-					    $line['symbol'] === 'Horse' || 
1814
-					    $line['symbol'] === 'Bus' || 
1815
-					    $line['symbol'] === 'Jeep' || 
1816
-					    $line['symbol'] === 'Recreational Vehicle' || 
1817
-					    $line['symbol'] === 'Yacht (Sail)' || 
1818
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1819
-					    $line['symbol'] === 'Firetruck' || 
1820
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1821
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1822
-					    $line['symbol'] === 'SUV' ||
1823
-					    $line['symbol'] === 'Snowmobile' ||
1824
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1825
-				    //} 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') {
1791
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1792
+						//$line['symbol'] === 'Balloon' ||
1793
+						$line['symbol'] === 'Glider' || 
1794
+						$line['symbol'] === 'No. Plane' || 
1795
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1796
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1797
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1798
+						$send = $SI->add($data);
1799
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1800
+						$line['symbol'] === 'Yacht (Sail)' || 
1801
+						$line['symbol'] === 'Ship (Power Boat)')) {
1802
+						$send = $MI->add($data);
1803
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1804
+						$line['symbol'] === 'Car' || 
1805
+						$line['symbol'] === 'Ambulance' || 
1806
+						$line['symbol'] === 'Van' || 
1807
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1808
+						$line['symbol'] === 'Motorcycle' || 
1809
+						$line['symbol'] === 'Tractor' || 
1810
+						$line['symbol'] === 'Police' || 
1811
+						$line['symbol'] === 'Bike' || 
1812
+						$line['symbol'] === 'Jogger' || 
1813
+						$line['symbol'] === 'Horse' || 
1814
+						$line['symbol'] === 'Bus' || 
1815
+						$line['symbol'] === 'Jeep' || 
1816
+						$line['symbol'] === 'Recreational Vehicle' || 
1817
+						$line['symbol'] === 'Yacht (Sail)' || 
1818
+						$line['symbol'] === 'Ship (Power Boat)' || 
1819
+						$line['symbol'] === 'Firetruck' || 
1820
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1821
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1822
+						$line['symbol'] === 'SUV' ||
1823
+						$line['symbol'] === 'Snowmobile' ||
1824
+						$line['symbol'] === 'Mobile Satellite Station')) {
1825
+					//} 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') {
1826 1826
 				//    } 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') {
1827 1827
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1828 1828
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1829
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1829
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1830 1830
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1831 1831
 					$Source->deleteOldLocationByType('gs');
1832 1832
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
 					} else {
1835 1835
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1836 1836
 					}
1837
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1837
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1838 1838
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1839 1839
 					if ($globalDebug) echo '# Weather Station added'."\n";
1840 1840
 					$Source->deleteOldLocationByType('wx');
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
 					} else {
1845 1845
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1846 1846
 					}
1847
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1847
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1848 1848
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1849 1849
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1850 1850
 					$Source->deleteOldLocationByType('lightning');
@@ -1853,11 +1853,11 @@  discard block
 block discarded – undo
1853 1853
 					} else {
1854 1854
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1855 1855
 					}
1856
-				    } elseif ($globalDebug) {
1857
-				    	echo '/!\ Not added: '.$buffer."\n";
1858
-				    	print_r($line);
1859
-				    }
1860
-				    unset($data);
1856
+					} elseif ($globalDebug) {
1857
+						echo '/!\ Not added: '.$buffer."\n";
1858
+						print_r($line);
1859
+					}
1860
+					unset($data);
1861 1861
 				}
1862 1862
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1863 1863
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1876,12 +1876,12 @@  discard block
 block discarded – undo
1876 1876
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1877 1877
 					$globalSources[$nb]['last_weather_clean'] = time();
1878 1878
 				}
1879
-			    }
1879
+				}
1880 1880
 			} else {
1881
-			    $line = explode(',', $buffer);
1882
-    			    if (count($line) > 20) {
1883
-    			    	$data['hex'] = $line[4];
1884
-    				/*
1881
+				$line = explode(',', $buffer);
1882
+					if (count($line) > 20) {
1883
+						$data['hex'] = $line[4];
1884
+					/*
1885 1885
     				$data['datetime'] = $line[6].' '.$line[7];
1886 1886
     					date_default_timezone_set($globalTimezone);
1887 1887
     					$datetime = new DateTime($data['datetime']);
@@ -1889,31 +1889,31 @@  discard block
 block discarded – undo
1889 1889
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1890 1890
     					date_default_timezone_set('UTC');
1891 1891
     				*/
1892
-    				// Force datetime to current UTC datetime
1893
-    				date_default_timezone_set('UTC');
1894
-    				$data['datetime'] = date('Y-m-d H:i:s');
1895
-    				$data['ident'] = trim($line[10]);
1896
-    				$data['latitude'] = $line[14];
1897
-    				$data['longitude'] = $line[15];
1898
-    				$data['verticalrate'] = $line[16];
1899
-    				$data['emergency'] = $line[20];
1900
-    				$data['speed'] = $line[12];
1901
-    				$data['squawk'] = $line[17];
1902
-    				$data['altitude'] = $line[11];
1903
-    				$data['heading'] = $line[13];
1904
-    				$data['ground'] = $line[21];
1905
-    				$data['emergency'] = $line[19];
1906
-    				$data['format_source'] = 'sbs';
1892
+					// Force datetime to current UTC datetime
1893
+					date_default_timezone_set('UTC');
1894
+					$data['datetime'] = date('Y-m-d H:i:s');
1895
+					$data['ident'] = trim($line[10]);
1896
+					$data['latitude'] = $line[14];
1897
+					$data['longitude'] = $line[15];
1898
+					$data['verticalrate'] = $line[16];
1899
+					$data['emergency'] = $line[20];
1900
+					$data['speed'] = $line[12];
1901
+					$data['squawk'] = $line[17];
1902
+					$data['altitude'] = $line[11];
1903
+					$data['heading'] = $line[13];
1904
+					$data['ground'] = $line[21];
1905
+					$data['emergency'] = $line[19];
1906
+					$data['format_source'] = 'sbs';
1907 1907
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1908 1908
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1909
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1909
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1910 1910
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1911
-    				$data['id_source'] = $id_source;
1912
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1913
-    				else $error = true;
1914
-    				unset($data);
1915
-    			    } else $error = true;
1916
-			    if ($error) {
1911
+					$data['id_source'] = $id_source;
1912
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1913
+					else $error = true;
1914
+					unset($data);
1915
+					} else $error = true;
1916
+				if ($error) {
1917 1917
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1918 1918
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1919 1919
 				} else {
@@ -1929,13 +1929,13 @@  discard block
 block discarded – undo
1929 1929
 					connect_all($sourceer);
1930 1930
 					$sourceer = array();
1931 1931
 				}
1932
-			    }
1932
+				}
1933 1933
 			}
1934 1934
 			// Sleep for xxx microseconds
1935 1935
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1936
-		    } else {
1936
+			} else {
1937 1937
 			if ($format === 'flightgearmp') {
1938
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1938
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1939 1939
 				//@socket_close($r);
1940 1940
 				sleep($globalMinFetch);
1941 1941
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1944,9 +1944,9 @@  discard block
 block discarded – undo
1944 1944
 				break;
1945 1945
 				
1946 1946
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1947
-			    if (isset($tt[$format])) $tt[$format]++;
1948
-			    else $tt[$format] = 0;
1949
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1947
+				if (isset($tt[$format])) $tt[$format]++;
1948
+				else $tt[$format] = 0;
1949
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1950 1950
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1951 1951
 				//@socket_close($r);
1952 1952
 				sleep(2);
@@ -1957,24 +1957,24 @@  discard block
 block discarded – undo
1957 1957
 				//connect_all($globalSources);
1958 1958
 				$tt[$format]=0;
1959 1959
 				break;
1960
-			    } 
1961
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1960
+				} 
1961
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1962
+			}
1962 1963
 			}
1963
-		    }
1964 1964
 		}
1965
-	    } else {
1965
+		} else {
1966 1966
 		$error = socket_strerror(socket_last_error());
1967 1967
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1968 1968
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1969 1969
 			if (isset($globalDebug)) echo "Restarting...\n";
1970 1970
 			// Restart the script if possible
1971 1971
 			if (is_array($sockets)) {
1972
-			    if ($globalDebug) echo "Shutdown all sockets...";
1972
+				if ($globalDebug) echo "Shutdown all sockets...";
1973 1973
 			    
1974
-			    foreach ($sockets as $sock) {
1974
+				foreach ($sockets as $sock) {
1975 1975
 				@socket_shutdown($sock,2);
1976 1976
 				@socket_close($sock);
1977
-			    }
1977
+				}
1978 1978
 			    
1979 1979
 			}
1980 1980
 			if ($globalDebug) echo "Waiting...";
@@ -1989,15 +1989,15 @@  discard block
 block discarded – undo
1989 1989
 			if ($globalDebug) echo "Restart all connections...";
1990 1990
 			connect_all($globalSources);
1991 1991
 		}
1992
-	    }
1992
+		}
1993 1993
 	}
1994 1994
 	if ($globalDaemon === false) {
1995
-	    if ($globalDebug) echo 'Check all...'."\n";
1996
-	    if (isset($SI)) $SI->checkAll();
1997
-	    if (isset($TI)) $TI->checkAll();
1998
-	    if (isset($MI)) $MI->checkAll();
1995
+		if ($globalDebug) echo 'Check all...'."\n";
1996
+		if (isset($SI)) $SI->checkAll();
1997
+		if (isset($TI)) $TI->checkAll();
1998
+		if (isset($MI)) $MI->checkAll();
1999
+	}
1999 2000
 	}
2000
-    }
2001 2001
 }
2002 2002
 
2003 2003
 ?>
Please login to merge, or discard this patch.
Spacing   +211 added lines, -211 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,21 +740,21 @@  discard block
 block discarded – undo
740 740
 	    )
741 741
 	) {
742 742
 	    if ($globalDebug) echo '! Download... ';
743
-	    for ($i =0; $i <= 1; $i++) {
743
+	    for ($i = 0; $i <= 1; $i++) {
744 744
 		    if ($globalDebug) echo 'Racetype: '.$i."\n";
745 745
 	    $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
746 746
 	    if ($globalDebug) echo 'done'."\n";
747 747
 	    if ($buffer != '') {
748
-		$all_data = json_decode($buffer,true);
748
+		$all_data = json_decode($buffer, true);
749 749
 		if (isset($all_data['missions'])) {
750 750
 			foreach ($all_data['missions'] as $mission) {
751 751
 				$mission_user = $mission['usrname'];
752
-				$mission_name = iconv("utf-8", "utf-8//ignore",$mission['mistitle']);
753
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
752
+				$mission_name = iconv("utf-8", "utf-8//ignore", $mission['mistitle']);
753
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
754 754
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
755 755
 				} else $bufferm = '';
756 756
 				if ($bufferm != '') {
757
-					$mission_data = json_decode($bufferm,true);
757
+					$mission_data = json_decode($bufferm, true);
758 758
 					if (isset($mission_data['leaderboard'][0]['results'])) {
759 759
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
760 760
 							//print_r($bufferm);
@@ -771,10 +771,10 @@  discard block
 block discarded – undo
771 771
 								$pos = $Common->convertDecLatLong($sail['pos']);
772 772
 								$data['latitude'] = $pos['latitude'];
773 773
 								$data['longitude'] = $pos['longitude'];
774
-								$resultdescr = explode(',',$sail['resultdescr']);
775
-								$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*0.539957);
776
-								$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
777
-								$data['ident'] = trim( preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$sail['ubtname']));
774
+								$resultdescr = explode(',', $sail['resultdescr']);
775
+								$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*0.539957);
776
+								$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
777
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $sail['ubtname']));
778 778
 								$data['captain_id'] = $sail['usrnr'];
779 779
 								$data['captain_name'] = $sail['usrname'];
780 780
 								$data['race_id'] = $sail['misnr'];
@@ -815,8 +815,8 @@  discard block
 block discarded – undo
815 815
 	) {
816 816
 	    //$buffer = $Common->getData($hosts[$id]);
817 817
 	    $buffer = $Common->getData($value['host']);
818
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
819
-	    $buffer = explode('\n',$buffer);
818
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
819
+	    $buffer = explode('\n', $buffer);
820 820
 	    $reset = 0;
821 821
 	    foreach ($buffer as $line) {
822 822
     		if ($line != '') {
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
828 828
 			$data['pilot_id'] = $line[1];
829 829
 			$data['pilot_name'] = $line[2];
830
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
830
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
831 831
 			$data['ident'] = $line[0]; // ident
832 832
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
833 833
 			$data['speed'] = $line[8]; // speed
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
844 844
 			//if (isset($line[37])) $data['last_update'] = $line[37];
845 845
 		        $data['departure_airport_icao'] = $line[11];
846
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
846
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
847 847
 		        $data['arrival_airport_icao'] = $line[13];
848 848
 			$data['frequency'] = $line[4];
849 849
 			$data['type'] = $line[18];
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
     			$data['id_source'] = $id_source;
853 853
 	    		//$data['arrival_airport_time'] = ;
854 854
 	    		if ($line[9] != '') {
855
-	    		    $aircraft_data = explode('/',$line[9]);
855
+	    		    $aircraft_data = explode('/', $line[9]);
856 856
 	    		    if (isset($aircraft_data[1])) {
857 857
 	    			$data['aircraft_icao'] = $aircraft_data[1];
858 858
 	    		    }
@@ -867,9 +867,9 @@  discard block
 block discarded – undo
867 867
     			if ($line[3] === 'PILOT') $SI->add($data);
868 868
 			elseif ($line[3] === 'ATC') {
869 869
 				//print_r($data);
870
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
871
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
872
-				$typec = substr($data['ident'],-3);
870
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
871
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
872
+				$typec = substr($data['ident'], -3);
873 873
 				if ($typec === 'APP') $data['type'] = 'Approach';
874 874
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
875 875
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -881,8 +881,8 @@  discard block
 block discarded – undo
881 881
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
882 882
 				if (!isset($data['source_name'])) $data['source_name'] = '';
883 883
 				if (isset($ATC)) {
884
-					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']);
885
-					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']);
884
+					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']);
885
+					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']);
886 886
 				}
887 887
 			}
888 888
     			unset($data);
@@ -898,24 +898,24 @@  discard block
 block discarded – undo
898 898
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
899 899
     	    )
900 900
     	) {
901
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
901
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
902 902
 	    if ($buffer != '') {
903 903
 		$all_data = simplexml_load_string($buffer);
904
-		foreach($all_data->children() as $childdata) {
904
+		foreach ($all_data->children() as $childdata) {
905 905
 			$data = array();
906 906
 			$line = $childdata;
907 907
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
908
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
909
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
910
-			$data['latitude'] = (float)$line['pktLatitude'];
911
-			$data['longitude'] = (float)$line['pktLongitude'];
912
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
913
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
914
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
908
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
909
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
910
+			$data['latitude'] = (float) $line['pktLatitude'];
911
+			$data['longitude'] = (float) $line['pktLongitude'];
912
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
913
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
914
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
915 915
 			$data['altitude_relative'] = 'AMSL';
916
-			$data['pilot_id'] = (int)$line['pktPilotID'];
916
+			$data['pilot_id'] = (int) $line['pktPilotID'];
917 917
 			$data['aircraft_icao'] = 'PARAGLIDER';
918
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
918
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
919 919
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
920 920
 			$data['format_source'] = $value['format'];
921 921
 			$SI->add($data);
@@ -923,22 +923,22 @@  discard block
 block discarded – undo
923 923
 		}
924 924
 	    }
925 925
 	    $Source->deleteOldLocationByType('gs');
926
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
926
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
927 927
 	    if ($buffer != '') {
928 928
 		$all_data = simplexml_load_string($buffer);
929
-		foreach($all_data->children() as $childdata) {
929
+		foreach ($all_data->children() as $childdata) {
930 930
 			$data = array();
931 931
 			$line = $childdata;
932
-			$data['id'] = (int)$line['gsID'];
933
-			$data['latitude'] = (float)$line['gsLatitude'];
934
-			$data['longitude'] = (float)$line['gsLongitude'];
935
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
932
+			$data['id'] = (int) $line['gsID'];
933
+			$data['latitude'] = (float) $line['gsLatitude'];
934
+			$data['longitude'] = (float) $line['gsLongitude'];
935
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
936 936
 			$data['altitude_relative'] = 'AMSL';
937
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
937
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
938 938
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
939
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
939
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
940 940
 			} else {
941
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
941
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
942 942
 			}
943 943
 			unset($data);
944 944
 		}
@@ -956,9 +956,9 @@  discard block
 block discarded – undo
956 956
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
957 957
 	    )
958 958
 	) {
959
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
959
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
960 960
 	    if ($buffer != '') {
961
-	        $all_data = json_decode($buffer,true);
961
+	        $all_data = json_decode($buffer, true);
962 962
 		if (isset($all_data['acList'])) {
963 963
 		    $reset = 0;
964 964
 		    foreach ($all_data['acList'] as $line) {
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
975 975
 			$data['emergency'] = ''; // emergency
976 976
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
977
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
977
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
978 978
 			else $data['datetime'] = date('Y-m-d H:i:s');
979 979
 			//$data['datetime'] = date('Y-m-d H:i:s');
980 980
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1000 1000
 			$data['squawk'] = $line['squawk']; // squawk
1001 1001
 			$data['emergency'] = ''; // emergency
1002
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1002
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1003 1003
 			else $data['datetime'] = date('Y-m-d H:i:s');
1004 1004
 			$data['format_source'] = 'aircraftlistjson';
1005 1005
 			$data['id_source'] = $id_source;
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
     	    )
1021 1021
     	) {
1022 1022
 	    $buffer = $Common->getData($value['host']);
1023
-	    $all_data = json_decode($buffer,true);
1023
+	    $all_data = json_decode($buffer, true);
1024 1024
 	    if (isset($all_data['planes'])) {
1025 1025
 		$reset = 0;
1026 1026
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1037,12 +1037,12 @@  discard block
 block discarded – undo
1037 1037
 		    $data['emergency'] = ''; // emergency
1038 1038
 		    $data['registration'] = $line[2];
1039 1039
 		    $data['aircraft_icao'] = $line[0];
1040
-		    $deparr = explode('-',$line[1]);
1040
+		    $deparr = explode('-', $line[1]);
1041 1041
 		    if (count($deparr) === 2) {
1042 1042
 			$data['departure_airport_icao'] = $deparr[0];
1043 1043
 			$data['arrival_airport_icao'] = $deparr[1];
1044 1044
 		    }
1045
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1045
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1046 1046
 	    	    $data['format_source'] = 'planeupdatefaa';
1047 1047
     		    $data['id_source'] = $id_source;
1048 1048
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 	    )
1061 1061
 	) {
1062 1062
 	    $buffer = $Common->getData($value['host']);
1063
-	    $all_data = json_decode($buffer,true);
1063
+	    $all_data = json_decode($buffer, true);
1064 1064
 	    if (isset($all_data['states'])) {
1065 1065
 		$reset = 0;
1066 1066
 		foreach ($all_data['states'] as $key => $line) {
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 		    //$data['emergency'] = ''; // emergency
1078 1078
 		    //$data['registration'] = $line[2];
1079 1079
 		    //$data['aircraft_icao'] = $line[0];
1080
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1080
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1081 1081
 		    $data['format_source'] = 'opensky';
1082 1082
 		    $data['id_source'] = $id_source;
1083 1083
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
 	    )
1095 1095
 	) {
1096 1096
 	    $buffer = $Common->getData($value['host']);
1097
-	    $all_data = json_decode($buffer,true);
1098
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1097
+	    $all_data = json_decode($buffer, true);
1098
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1099 1099
 		$reset = 0;
1100 1100
 		foreach ($all_data['aircraft'] as $key => $line) {
1101 1101
 		    $data = array();
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 	    )
1134 1134
 	) {
1135 1135
 	    $buffer = $Common->getData($value['host']);
1136
-	    $all_data = json_decode($buffer,true);
1136
+	    $all_data = json_decode($buffer, true);
1137 1137
 	    if (isset($all_data['aircraft'])) {
1138 1138
 		$reset = 0;
1139 1139
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 		    //$data['emergency'] = ''; // emergency
1151 1151
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1152 1152
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1153
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1153
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1154 1154
 		    $data['format_source'] = 'planefinderclient';
1155 1155
 		    $data['id_source'] = $id_source;
1156 1156
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 	) {
1170 1170
 	    //$buffer = $Common->getData($hosts[$id]);
1171 1171
 	    $buffer = $Common->getData($value['host']);
1172
-	    $all_data = json_decode($buffer,true);
1172
+	    $all_data = json_decode($buffer, true);
1173 1173
 	    if (!empty($all_data)) $reset = 0;
1174 1174
 	    foreach ($all_data as $key => $line) {
1175 1175
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1207,11 +1207,11 @@  discard block
 block discarded – undo
1207 1207
 	    )
1208 1208
 	) {
1209 1209
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1210
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1210
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1211 1211
 	    //echo $buffer;
1212
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1213
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1214
-	    $all_data = json_decode($buffer,true);
1212
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1213
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1214
+	    $all_data = json_decode($buffer, true);
1215 1215
 	    if (json_last_error() != JSON_ERROR_NONE) {
1216 1216
 		die(json_last_error_msg());
1217 1217
 	    }
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
 			//$data['departure_airport_iata'] = $line[11];
1235 1235
 			//$data['arrival_airport_iata'] = $line[12];
1236 1236
 	    		//$data['emergency'] = ''; // emergency
1237
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1237
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1238 1238
 	    		$data['format_source'] = 'radarvirtueljson';
1239 1239
     			$data['id_source'] = $id_source;
1240 1240
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1255,14 +1255,14 @@  discard block
 block discarded – undo
1255 1255
 	) {
1256 1256
 	    //$buffer = $Common->getData($hosts[$id]);
1257 1257
 	    $buffer = $Common->getData($value['host'].'?'.time());
1258
-	    $all_data = json_decode(utf8_encode($buffer),true);
1258
+	    $all_data = json_decode(utf8_encode($buffer), true);
1259 1259
 	    
1260 1260
 	    if (isset($all_data['pireps'])) {
1261 1261
 		$reset = 0;
1262 1262
 	        foreach ($all_data['pireps'] as $line) {
1263 1263
 		    $data = array();
1264 1264
 		    $data['id'] = $line['id'];
1265
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1265
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1266 1266
 		    $data['ident'] = $line['callsign']; // ident
1267 1267
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1268 1268
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1292,9 +1292,9 @@  discard block
 block discarded – undo
1292 1292
 			$SI->add($data);
1293 1293
 		    //    print_r($data);
1294 1294
     		    } elseif ($line['icon'] === 'ct') {
1295
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1296
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1297
-			$typec = substr($data['ident'],-3);
1295
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1296
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1297
+			$typec = substr($data['ident'], -3);
1298 1298
 			$data['type'] = '';
1299 1299
 			if ($typec === 'APP') $data['type'] = 'Approach';
1300 1300
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1306 1306
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1307 1307
 			else $data['type'] = 'Observer';
1308
-			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']);
1308
+			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']);
1309 1309
 		    }
1310 1310
 		    unset($data);
1311 1311
 		}
@@ -1322,14 +1322,14 @@  discard block
 block discarded – undo
1322 1322
 	    //$buffer = $Common->getData($hosts[$id]);
1323 1323
 	    if ($globalDebug) echo 'Get Data...'."\n";
1324 1324
 	    $buffer = $Common->getData($value['host']);
1325
-	    $all_data = json_decode($buffer,true);
1325
+	    $all_data = json_decode($buffer, true);
1326 1326
 	    if ($buffer != '' && is_array($all_data)) {
1327 1327
 		$reset = 0;
1328 1328
 		foreach ($all_data as $line) {
1329 1329
 	    	    $data = array();
1330 1330
 	    	    //$data['id'] = $line['id']; // id not usable
1331 1331
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1332
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1332
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1333 1333
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1334 1334
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1335 1335
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
 	    	    //$data['datetime'] = $line['lastupdate'];
1345 1345
 	    	    //$data['last_update'] = $line['lastupdate'];
1346 1346
 	    	    if (isset($value['timezone'])) {
1347
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1347
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1348 1348
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1349 1349
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1350 1350
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1360,14 +1360,14 @@  discard block
 block discarded – undo
1360 1360
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1361 1361
 		    if (isset($line['aircraftname'])) {
1362 1362
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1363
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1364
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1363
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1364
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1365 1365
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1366 1366
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1367 1367
 	    		else {
1368
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1369
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1370
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1368
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1369
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1370
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1371 1371
 	    		}
1372 1372
 	    	    }
1373 1373
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
 	    //$buffer = $Common->getData($hosts[$id]);
1393 1393
 	    if ($globalDebug) echo 'Get Data...'."\n";
1394 1394
 	    $buffer = $Common->getData($value['host']);
1395
-	    $all_data = json_decode($buffer,true);
1395
+	    $all_data = json_decode($buffer, true);
1396 1396
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1397 1397
 		$reset = 0;
1398 1398
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1404 1404
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1405 1405
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1406
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1406
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1407 1407
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1408 1408
 	    	    $data['altitude'] = $line['altitude']; // altitude
1409 1409
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
 	    	    //$data['squawk'] = ''; // squawk
1415 1415
 	    	    //$data['emergency'] = ''; // emergency
1416 1416
 	    	    if (isset($value['timezone'])) {
1417
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1417
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1418 1418
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1419 1419
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1420 1420
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1450,14 +1450,14 @@  discard block
 block discarded – undo
1450 1450
 	    //$buffer = $Common->getData($hosts[$id]);
1451 1451
 	    if ($globalDebug) echo 'Get Data...'."\n";
1452 1452
 	    $buffer = $Common->getData($value['host']);
1453
-	    $all_data = json_decode($buffer,true);
1453
+	    $all_data = json_decode($buffer, true);
1454 1454
 	    if ($buffer != '' && is_array($all_data)) {
1455 1455
 		$reset = 0;
1456 1456
 		foreach ($all_data as $line) {
1457 1457
 	    	    $data = array();
1458 1458
 	    	    //$data['id'] = $line['id']; // id not usable
1459 1459
 	    	    $data['id'] = trim($line['flight_id']);
1460
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1460
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1461 1461
 	    	    $data['pilot_name'] = $line['pilot_name'];
1462 1462
 	    	    $data['pilot_id'] = $line['pilot_id'];
1463 1463
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1501,24 +1501,24 @@  discard block
 block discarded – undo
1501 1501
 	    //$buffer = $Common->getData($hosts[$id]);
1502 1502
 	    if ($globalDebug) echo 'Get Data...'."\n";
1503 1503
 	    $buffer = $Common->getData($value['host']);
1504
-	    $all_data = json_decode($buffer,true);
1504
+	    $all_data = json_decode($buffer, true);
1505 1505
 	    if ($buffer != '') {
1506 1506
 		$Source->deleteLocationBySource('blitzortung');
1507
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1508
-		$buffer = explode('\n',$buffer);
1507
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1508
+		$buffer = explode('\n', $buffer);
1509 1509
 		foreach ($buffer as $buffer_line) {
1510
-		    $line = json_decode($buffer_line,true);
1510
+		    $line = json_decode($buffer_line, true);
1511 1511
 		    if (isset($line['time'])) {
1512 1512
 			$data = array();
1513 1513
 			$data['altitude'] = $line['alt']; // altitude
1514 1514
 			$data['latitude'] = $line['lat']; // lat
1515 1515
 			$data['longitude'] = $line['lon']; // long
1516
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1516
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1517 1517
 			$data['id_source'] = $id_source;
1518 1518
 			$data['format_source'] = 'blitzortung';
1519 1519
 			$SI->add($data);
1520 1520
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1521
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1521
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1522 1522
 			unset($data);
1523 1523
 		    }
1524 1524
 		}
@@ -1541,11 +1541,11 @@  discard block
 block discarded – undo
1541 1541
 		    //$value = $formats[$nb];
1542 1542
 		    $format = $globalSources[$nb]['format'];
1543 1543
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1544
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1544
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1545 1545
 		    } elseif ($format === 'vrstcp') {
1546 1546
 			$buffer = @socket_read($r, 6000);
1547 1547
 		    } else {
1548
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1548
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1549 1549
 		    }
1550 1550
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1551 1551
 		    //echo $buffer."\n";
@@ -1555,8 +1555,8 @@  discard block
 block discarded – undo
1555 1555
 		    //$SI::del();
1556 1556
 		    if ($buffer !== FALSE) {
1557 1557
 			if ($format === 'vrstcp') {
1558
-			    $buffer = explode('},{',$buffer);
1559
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1558
+			    $buffer = explode('},{', $buffer);
1559
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1560 1560
 		    }
1561 1561
 		    // SBS format is CSV format
1562 1562
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1580,7 +1580,7 @@  discard block
 block discarded – undo
1580 1580
 			    $ais_data = $AIS->parse_line(trim($buffer));
1581 1581
 			    $data = array();
1582 1582
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1583
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1583
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1584 1584
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1585 1585
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1586 1586
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1591,13 +1591,13 @@  discard block
 block discarded – undo
1591 1591
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1592 1592
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1593 1593
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1594
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1594
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1595 1595
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1596 1596
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1597 1597
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1598 1598
 
1599 1599
 			    if (isset($ais_data['timestamp'])) {
1600
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1600
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1601 1601
 			    } else {
1602 1602
 				$data['datetime'] = date('Y-m-d H:i:s');
1603 1603
 			    }
@@ -1608,10 +1608,10 @@  discard block
 block discarded – undo
1608 1608
                         } elseif ($format === 'flightgearsp') {
1609 1609
                     	    //echo $buffer."\n";
1610 1610
                     	    if (strlen($buffer) > 5) {
1611
-				$line = explode(',',$buffer);
1611
+				$line = explode(',', $buffer);
1612 1612
 				$data = array();
1613 1613
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1614
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1614
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1615 1615
 				$data['ident'] = $line[6];
1616 1616
 				$data['aircraft_name'] = $line[7];
1617 1617
 				$data['longitude'] = $line[1];
@@ -1628,16 +1628,16 @@  discard block
 block discarded – undo
1628 1628
                         } elseif ($format === 'acars') {
1629 1629
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1630 1630
 			    $ACARS->add(trim($buffer));
1631
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1631
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1632 1632
 			    $ACARS->deleteLiveAcarsData();
1633 1633
 			} elseif ($format === 'flightgearmp') {
1634
-			    if (substr($buffer,0,1) != '#') {
1634
+			    if (substr($buffer, 0, 1) != '#') {
1635 1635
 				$data = array();
1636 1636
 				//echo $buffer."\n";
1637
-				$line = explode(' ',$buffer);
1637
+				$line = explode(' ', $buffer);
1638 1638
 				if (count($line) === 11) {
1639
-				    $userserver = explode('@',$line[0]);
1640
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1639
+				    $userserver = explode('@', $line[0]);
1640
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1641 1641
 				    $data['ident'] = $userserver[0];
1642 1642
 				    $data['registration'] = $userserver[0];
1643 1643
 				    $data['latitude'] = $line[4];
@@ -1645,8 +1645,8 @@  discard block
 block discarded – undo
1645 1645
 				    $data['altitude'] = $line[6];
1646 1646
 				    $data['datetime'] = date('Y-m-d H:i:s');
1647 1647
 				    $aircraft_type = $line[10];
1648
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1649
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1648
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1649
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1650 1650
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1651 1651
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1652 1652
 				}
@@ -1655,8 +1655,8 @@  discard block
 block discarded – undo
1655 1655
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1656 1656
 			    die;
1657 1657
 			} elseif ($format === 'vrstcp') {
1658
-			    foreach($buffer as $all_data) {
1659
-				$line = json_decode('{'.$all_data.'}',true);
1658
+			    foreach ($buffer as $all_data) {
1659
+				$line = json_decode('{'.$all_data.'}', true);
1660 1660
 				$data = array();
1661 1661
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1662 1662
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1682,16 +1682,16 @@  discard block
 block discarded – undo
1682 1682
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1683 1683
 				unset($data);
1684 1684
 			    }
1685
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1685
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1686 1686
 			    $line = explode("\t", $buffer);
1687
-			    for($k = 0; $k < count($line); $k=$k+2) {
1687
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1688 1688
 				$key = $line[$k];
1689
-			        $lined[$key] = $line[$k+1];
1689
+			        $lined[$key] = $line[$k + 1];
1690 1690
 			    }
1691 1691
     			    if (count($lined) > 3) {
1692 1692
     				$data['hex'] = $lined['hexid'];
1693 1693
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1694
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1694
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1695 1695
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1696 1696
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1697 1697
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1710,23 +1710,23 @@  discard block
 block discarded – undo
1710 1710
     			    } else $error = true;
1711 1711
 			} elseif ($format === 'aprs' && $use_aprs) {
1712 1712
 			    if ($aprs_connect === 0) {
1713
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1713
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1714 1714
 				$aprs_connect = 1;
1715 1715
 			    }
1716 1716
 			    
1717
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1717
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1718 1718
 				$aprs_last_tx = time();
1719 1719
 				$data_aprs = "# Keep alive";
1720
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1720
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1721 1721
 			    }
1722 1722
 			    
1723 1723
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1724 1724
 			    //echo 'APRS data : '.$buffer."\n";
1725
-			    $buffer = str_replace('APRS <- ','',$buffer);
1726
-			    $buffer = str_replace('APRS -> ','',$buffer);
1725
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1726
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1727 1727
 			    //echo $buffer."\n";
1728 1728
 			    date_default_timezone_set('UTC');
1729
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1729
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1730 1730
 				$line = $APRS->parse($buffer);
1731 1731
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1732 1732
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1742 1742
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1743 1743
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1744
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1744
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1745 1745
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1746 1746
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1747 1747
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1829,29 +1829,29 @@  discard block
 block discarded – undo
1829 1829
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1830 1830
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1831 1831
 					$Source->deleteOldLocationByType('gs');
1832
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1833
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1832
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1833
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1834 1834
 					} else {
1835
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1835
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1836 1836
 					}
1837 1837
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1838 1838
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1839 1839
 					if ($globalDebug) echo '# Weather Station added'."\n";
1840 1840
 					$Source->deleteOldLocationByType('wx');
1841 1841
 					$weather_data = json_encode($line);
1842
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1843
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1842
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1843
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1844 1844
 					} else {
1845
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1845
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1846 1846
 					}
1847 1847
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1848 1848
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1849 1849
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1850 1850
 					$Source->deleteOldLocationByType('lightning');
1851
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1852
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1851
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1852
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1853 1853
 					} else {
1854
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1854
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1855 1855
 					}
1856 1856
 				    } elseif ($globalDebug) {
1857 1857
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1860,7 +1860,7 @@  discard block
 block discarded – undo
1860 1860
 				    unset($data);
1861 1861
 				}
1862 1862
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1863
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1863
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1864 1864
 				}
1865 1865
 				/*
1866 1866
 				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')) {
@@ -1869,7 +1869,7 @@  discard block
 block discarded – undo
1869 1869
 				*/
1870 1870
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1871 1871
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1872
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1872
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1873 1873
 					$Source->deleteOldLocationByType('lightning');
1874 1874
 					$Source->deleteOldLocationByType('wx');
1875 1875
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1955,7 +1955,7 @@  discard block
 block discarded – undo
1955 1955
 				connect_all($sourceee);
1956 1956
 				$sourceee = array();
1957 1957
 				//connect_all($globalSources);
1958
-				$tt[$format]=0;
1958
+				$tt[$format] = 0;
1959 1959
 				break;
1960 1960
 			    } 
1961 1961
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -1965,14 +1965,14 @@  discard block
 block discarded – undo
1965 1965
 	    } else {
1966 1966
 		$error = socket_strerror(socket_last_error());
1967 1967
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1968
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1968
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1969 1969
 			if (isset($globalDebug)) echo "Restarting...\n";
1970 1970
 			// Restart the script if possible
1971 1971
 			if (is_array($sockets)) {
1972 1972
 			    if ($globalDebug) echo "Shutdown all sockets...";
1973 1973
 			    
1974 1974
 			    foreach ($sockets as $sock) {
1975
-				@socket_shutdown($sock,2);
1975
+				@socket_shutdown($sock, 2);
1976 1976
 				@socket_close($sock);
1977 1977
 			    }
1978 1978
 			    
Please login to merge, or discard this patch.
Braces   +1210 added lines, -406 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);
@@ -739,11 +1008,17 @@  discard block
 block discarded – undo
739 1008
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
740 1009
 	    )
741 1010
 	) {
742
-	    if ($globalDebug) echo '! Download... ';
1011
+	    if ($globalDebug) {
1012
+	    	echo '! Download... ';
1013
+	    }
743 1014
 	    for ($i =0; $i <= 1; $i++) {
744
-		    if ($globalDebug) echo 'Racetype: '.$i."\n";
1015
+		    if ($globalDebug) {
1016
+		    	echo 'Racetype: '.$i."\n";
1017
+		    }
745 1018
 	    $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
746
-	    if ($globalDebug) echo 'done'."\n";
1019
+	    if ($globalDebug) {
1020
+	    	echo 'done'."\n";
1021
+	    }
747 1022
 	    if ($buffer != '') {
748 1023
 		$all_data = json_decode($buffer,true);
749 1024
 		if (isset($all_data['missions'])) {
@@ -752,7 +1027,9 @@  discard block
 block discarded – undo
752 1027
 				$mission_name = iconv("utf-8", "utf-8//ignore",$mission['mistitle']);
753 1028
 				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
754 1029
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
755
-				} else $bufferm = '';
1030
+				} else {
1031
+					$bufferm = '';
1032
+				}
756 1033
 				if ($bufferm != '') {
757 1034
 					$mission_data = json_decode($bufferm,true);
758 1035
 					if (isset($mission_data['leaderboard'][0]['results'])) {
@@ -782,7 +1059,9 @@  discard block
 block discarded – undo
782 1059
 								//$data['callsign'] = trim(substr($line,100,7);
783 1060
 								$data['format_source'] = 'sailaway';
784 1061
 								$data['id_source'] = $id_source;
785
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1062
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1063
+									$data['noarchive'] = true;
1064
+								}
786 1065
 								//print_r($data);
787 1066
 								//echo 'Add...'."\n";
788 1067
 								$MI->add($data);
@@ -823,16 +1102,28 @@  discard block
 block discarded – undo
823 1102
     		    $line = explode(':', $line);
824 1103
     		    if (count($line) > 30 && $line[0] != 'callsign') {
825 1104
 			$data = array();
826
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
827
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1105
+			if (isset($line[37]) && $line[37] != '') {
1106
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1107
+			} else {
1108
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1109
+			}
828 1110
 			$data['pilot_id'] = $line[1];
829 1111
 			$data['pilot_name'] = $line[2];
830 1112
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
831 1113
 			$data['ident'] = $line[0]; // ident
832
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1114
+			if ($line[7] != '' && $line[7] != 0) {
1115
+				$data['altitude'] = $line[7];
1116
+			}
1117
+			// altitude
833 1118
 			$data['speed'] = $line[8]; // speed
834
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
835
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1119
+			if (isset($line[45])) {
1120
+				$data['heading'] = $line[45];
1121
+			}
1122
+			// heading
1123
+			elseif (isset($line[38])) {
1124
+				$data['heading'] = $line[38];
1125
+			}
1126
+			// heading
836 1127
 			$data['latitude'] = $line[5]; // lat
837 1128
 	        	$data['longitude'] = $line[6]; // long
838 1129
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -848,7 +1139,9 @@  discard block
 block discarded – undo
848 1139
 			$data['frequency'] = $line[4];
849 1140
 			$data['type'] = $line[18];
850 1141
 			$data['range'] = $line[19];
851
-			if (isset($line[35])) $data['info'] = $line[35];
1142
+			if (isset($line[35])) {
1143
+				$data['info'] = $line[35];
1144
+			}
852 1145
     			$data['id_source'] = $id_source;
853 1146
 	    		//$data['arrival_airport_time'] = ;
854 1147
 	    		if ($line[9] != '') {
@@ -862,27 +1155,47 @@  discard block
 block discarded – undo
862 1155
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
863 1156
 	    		*/
864 1157
 	    		$data['format_source'] = $value['format'];
865
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
866
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
867
-    			if ($line[3] === 'PILOT') $SI->add($data);
868
-			elseif ($line[3] === 'ATC') {
1158
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1159
+				$data['noarchive'] = true;
1160
+			}
1161
+			if (isset($value['name']) && $value['name'] != '') {
1162
+				$data['source_name'] = $value['name'];
1163
+			}
1164
+    			if ($line[3] === 'PILOT') {
1165
+    				$SI->add($data);
1166
+    			} elseif ($line[3] === 'ATC') {
869 1167
 				//print_r($data);
870 1168
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
871 1169
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
872 1170
 				$typec = substr($data['ident'],-3);
873
-				if ($typec === 'APP') $data['type'] = 'Approach';
874
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
875
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
876
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
877
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
878
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
879
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
880
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
881
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
882
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1171
+				if ($typec === 'APP') {
1172
+					$data['type'] = 'Approach';
1173
+				} elseif ($typec === 'TWR') {
1174
+					$data['type'] = 'Tower';
1175
+				} elseif ($typec === 'OBS') {
1176
+					$data['type'] = 'Observer';
1177
+				} elseif ($typec === 'GND') {
1178
+					$data['type'] = 'Ground';
1179
+				} elseif ($typec === 'DEL') {
1180
+					$data['type'] = 'Delivery';
1181
+				} elseif ($typec === 'DEP') {
1182
+					$data['type'] = 'Departure';
1183
+				} elseif ($typec === 'FSS') {
1184
+					$data['type'] = 'Flight Service Station';
1185
+				} elseif ($typec === 'CTR') {
1186
+					$data['type'] = 'Control Radar or Centre';
1187
+				} elseif ($data['type'] === '') {
1188
+					$data['type'] = 'Observer';
1189
+				}
1190
+				if (!isset($data['source_name'])) {
1191
+					$data['source_name'] = '';
1192
+				}
883 1193
 				if (isset($ATC)) {
884
-					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']);
885
-					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']);
1194
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1195
+						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']);
1196
+					} else {
1197
+						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']);
1198
+					}
886 1199
 				}
887 1200
 			}
888 1201
     			unset($data);
@@ -909,14 +1222,20 @@  discard block
 block discarded – undo
909 1222
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
910 1223
 			$data['latitude'] = (float)$line['pktLatitude'];
911 1224
 			$data['longitude'] = (float)$line['pktLongitude'];
912
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
913
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1225
+			if ((float)$line['pktTrack'] != 0) {
1226
+				$data['heading'] = (float)$line['pktTrack'];
1227
+			}
1228
+			if ((int)$line['pktSpeed'] != 0) {
1229
+				$data['speed'] = (int)$line['pktSpeed'];
1230
+			}
914 1231
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
915 1232
 			$data['altitude_relative'] = 'AMSL';
916 1233
 			$data['pilot_id'] = (int)$line['pktPilotID'];
917 1234
 			$data['aircraft_icao'] = 'PARAGLIDER';
918 1235
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
919
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1236
+			if (isset($pilot_data[4])) {
1237
+				$data['pilot_name'] = $pilot_data[4];
1238
+			}
920 1239
 			$data['format_source'] = $value['format'];
921 1240
 			$SI->add($data);
922 1241
 			unset($data);
@@ -964,25 +1283,59 @@  discard block
 block discarded – undo
964 1283
 		    foreach ($all_data['acList'] as $line) {
965 1284
 			$data = array();
966 1285
 			$data['hex'] = $line['Icao']; // hex
967
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
968
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
969
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
970
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
971
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
972
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1286
+			if (isset($line['Call'])) {
1287
+				$data['ident'] = $line['Call'];
1288
+			}
1289
+			// ident
1290
+			if (isset($line['Alt'])) {
1291
+				$data['altitude'] = $line['Alt'];
1292
+			}
1293
+			// altitude
1294
+			if (isset($line['Spd'])) {
1295
+				$data['speed'] = $line['Spd'];
1296
+			}
1297
+			// speed
1298
+			if (isset($line['Trak'])) {
1299
+				$data['heading'] = $line['Trak'];
1300
+			}
1301
+			// heading
1302
+			if (isset($line['Lat'])) {
1303
+				$data['latitude'] = $line['Lat'];
1304
+			}
1305
+			// lat
1306
+			if (isset($line['Long'])) {
1307
+				$data['longitude'] = $line['Long'];
1308
+			}
1309
+			// long
973 1310
 			//$data['verticalrate'] = $line['']; // verticale rate
974
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1311
+			if (isset($line['Sqk'])) {
1312
+				$data['squawk'] = $line['Sqk'];
1313
+			}
1314
+			// squawk
975 1315
 			$data['emergency'] = ''; // emergency
976
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
977
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
978
-			else $data['datetime'] = date('Y-m-d H:i:s');
1316
+			if (isset($line['Reg'])) {
1317
+				$data['registration'] = $line['Reg'];
1318
+			}
1319
+			if (isset($line['PosTime'])) {
1320
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1321
+			} else {
1322
+				$data['datetime'] = date('Y-m-d H:i:s');
1323
+			}
979 1324
 			//$data['datetime'] = date('Y-m-d H:i:s');
980
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1325
+			if (isset($line['Type'])) {
1326
+				$data['aircraft_icao'] = $line['Type'];
1327
+			}
981 1328
 			$data['format_source'] = 'aircraftlistjson';
982 1329
 			$data['id_source'] = $id_source;
983
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
984
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
985
-			if (isset($data['latitude'])) $SI->add($data);
1330
+			if (isset($value['name']) && $value['name'] != '') {
1331
+				$data['source_name'] = $value['name'];
1332
+			}
1333
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1334
+				$data['noarchive'] = true;
1335
+			}
1336
+			if (isset($data['latitude'])) {
1337
+				$SI->add($data);
1338
+			}
986 1339
 			unset($data);
987 1340
 		    }
988 1341
 		} elseif (is_array($all_data)) {
@@ -999,17 +1352,26 @@  discard block
 block discarded – undo
999 1352
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1000 1353
 			$data['squawk'] = $line['squawk']; // squawk
1001 1354
 			$data['emergency'] = ''; // emergency
1002
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1003
-			else $data['datetime'] = date('Y-m-d H:i:s');
1355
+			if (isset($line['PosTime'])) {
1356
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1357
+			} else {
1358
+				$data['datetime'] = date('Y-m-d H:i:s');
1359
+			}
1004 1360
 			$data['format_source'] = 'aircraftlistjson';
1005 1361
 			$data['id_source'] = $id_source;
1006
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1007
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1362
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1363
+				$data['noarchive'] = true;
1364
+			}
1365
+			if (isset($value['name']) && $value['name'] != '') {
1366
+				$data['source_name'] = $value['name'];
1367
+			}
1008 1368
 			$SI->add($data);
1009 1369
 			unset($data);
1010 1370
 		    }
1011 1371
 		}
1012
-	    } elseif ($globalDebug) echo 'No data'."\n";
1372
+	    } elseif ($globalDebug) {
1373
+	    	echo 'No data'."\n";
1374
+	    }
1013 1375
     	    //$last_exec['aircraftlistjson'] = time();
1014 1376
     	    $last_exec[$id]['last'] = time();
1015 1377
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1045,8 +1407,12 @@  discard block
 block discarded – undo
1045 1407
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1046 1408
 	    	    $data['format_source'] = 'planeupdatefaa';
1047 1409
     		    $data['id_source'] = $id_source;
1048
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1049
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1410
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1411
+		    	$data['noarchive'] = true;
1412
+		    }
1413
+		    if (isset($value['name']) && $value['name'] != '') {
1414
+		    	$data['source_name'] = $value['name'];
1415
+		    }
1050 1416
 		    $SI->add($data);
1051 1417
 		    unset($data);
1052 1418
 		}
@@ -1080,7 +1446,9 @@  discard block
 block discarded – undo
1080 1446
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1081 1447
 		    $data['format_source'] = 'opensky';
1082 1448
 		    $data['id_source'] = $id_source;
1083
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1449
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1450
+		    	$data['noarchive'] = true;
1451
+		    }
1084 1452
 		    $SI->add($data);
1085 1453
 		    unset($data);
1086 1454
 		}
@@ -1100,15 +1468,42 @@  discard block
 block discarded – undo
1100 1468
 		foreach ($all_data['aircraft'] as $key => $line) {
1101 1469
 		    $data = array();
1102 1470
 		    // add support for ground vehicule with ~ in front of hex
1103
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1104
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1105
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1106
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1107
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1108
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1109
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1110
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1111
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1471
+		    if (isset($line['hex'])) {
1472
+		    	$data['hex'] = $line['hex'];
1473
+		    }
1474
+		    // hex
1475
+		    if (isset($line['flight'])) {
1476
+		    	$data['ident'] = trim($line['flight']);
1477
+		    }
1478
+		    // ident
1479
+		    if (isset($line['altitude'])) {
1480
+		    	$data['altitude'] = $line['altitude'];
1481
+		    }
1482
+		    // altitude
1483
+		    if (isset($line['speed'])) {
1484
+		    	$data['speed'] = $line['speed'];
1485
+		    }
1486
+		    // speed
1487
+		    if (isset($line['track'])) {
1488
+		    	$data['heading'] = $line['track'];
1489
+		    }
1490
+		    // heading
1491
+		    if (isset($line['lat'])) {
1492
+		    	$data['latitude'] = $line['lat'];
1493
+		    }
1494
+		    // lat
1495
+		    if (isset($line['lon'])) {
1496
+		    	$data['longitude'] = $line['lon'];
1497
+		    }
1498
+		    // long
1499
+		    if (isset($line['vert_rate'])) {
1500
+		    	$data['verticalrate'] = $line['vert_rate'];
1501
+		    }
1502
+		    // verticale rate
1503
+		    if (isset($line['squawk'])) {
1504
+		    	$data['squawk'] = $line['squawk'];
1505
+		    }
1506
+		    // squawk
1112 1507
 		    //$data['emergency'] = ''; // emergency
1113 1508
 		    //$data['registration'] = $line[2];
1114 1509
 		    //$data['aircraft_icao'] = $line[0];
@@ -1116,10 +1511,17 @@  discard block
 block discarded – undo
1116 1511
 		    $data['format_source'] = 'aircraftjson';
1117 1512
 		    $data['id_source'] = $id_source;
1118 1513
 		    if (isset($value['name']) && $value['name'] != '') {
1119
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1120
-			    else $data['source_name'] = $value['name'];
1121
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1122
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1514
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1515
+			    	$data['source_name'] = $value['name'].'_MLAT';
1516
+			    } else {
1517
+			    	$data['source_name'] = $value['name'];
1518
+			    }
1519
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1520
+		    	$data['source_name'] = 'MLAT';
1521
+		    }
1522
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1523
+		    	$data['noarchive'] = true;
1524
+		    }
1123 1525
 		    $SI->add($data);
1124 1526
 		    unset($data);
1125 1527
 		}
@@ -1139,22 +1541,54 @@  discard block
 block discarded – undo
1139 1541
 		foreach ($all_data['aircraft'] as $key => $line) {
1140 1542
 		    $data = array();
1141 1543
 		    $data['hex'] = $key; // hex
1142
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1143
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1144
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1145
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1146
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1147
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1148
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1149
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1544
+		    if (isset($line['callsign'])) {
1545
+		    	$data['ident'] = trim($line['callsign']);
1546
+		    }
1547
+		    // ident
1548
+		    if (isset($line['altitude'])) {
1549
+		    	$data['altitude'] = $line['altitude'];
1550
+		    }
1551
+		    // altitude
1552
+		    if (isset($line['speed'])) {
1553
+		    	$data['speed'] = $line['speed'];
1554
+		    }
1555
+		    // speed
1556
+		    if (isset($line['heading'])) {
1557
+		    	$data['heading'] = $line['heading'];
1558
+		    }
1559
+		    // heading
1560
+		    if (isset($line['lat'])) {
1561
+		    	$data['latitude'] = $line['lat'];
1562
+		    }
1563
+		    // lat
1564
+		    if (isset($line['lon'])) {
1565
+		    	$data['longitude'] = $line['lon'];
1566
+		    }
1567
+		    // long
1568
+		    if (isset($line['vert_rate'])) {
1569
+		    	$data['verticalrate'] = $line['vert_rate'];
1570
+		    }
1571
+		    // verticale rate
1572
+		    if (isset($line['squawk'])) {
1573
+		    	$data['squawk'] = $line['squawk'];
1574
+		    }
1575
+		    // squawk
1150 1576
 		    //$data['emergency'] = ''; // emergency
1151
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1152
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1577
+		    if (isset($line['reg'])) {
1578
+		    	$data['registration'] = $line['reg'];
1579
+		    }
1580
+		    if (isset($line['type'])) {
1581
+		    	$data['aircraft_icao'] = $line['type'];
1582
+		    }
1153 1583
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1154 1584
 		    $data['format_source'] = 'planefinderclient';
1155 1585
 		    $data['id_source'] = $id_source;
1156
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1157
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1586
+		    if (isset($value['name']) && $value['name'] != '') {
1587
+		    	$data['source_name'] = $value['name'];
1588
+		    }
1589
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1590
+		    	$data['noarchive'] = true;
1591
+		    }
1158 1592
 		    $SI->add($data);
1159 1593
 		    unset($data);
1160 1594
 		}
@@ -1170,7 +1604,9 @@  discard block
 block discarded – undo
1170 1604
 	    //$buffer = $Common->getData($hosts[$id]);
1171 1605
 	    $buffer = $Common->getData($value['host']);
1172 1606
 	    $all_data = json_decode($buffer,true);
1173
-	    if (!empty($all_data)) $reset = 0;
1607
+	    if (!empty($all_data)) {
1608
+	    	$reset = 0;
1609
+	    }
1174 1610
 	    foreach ($all_data as $key => $line) {
1175 1611
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1176 1612
 		    $data = array();
@@ -1191,8 +1627,12 @@  discard block
 block discarded – undo
1191 1627
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1192 1628
 	    	    $data['format_source'] = 'fr24json';
1193 1629
     		    $data['id_source'] = $id_source;
1194
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1195
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1630
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1631
+		    	$data['noarchive'] = true;
1632
+		    }
1633
+		    if (isset($value['name']) && $value['name'] != '') {
1634
+		    	$data['source_name'] = $value['name'];
1635
+		    }
1196 1636
 		    $SI->add($data);
1197 1637
 		    unset($data);
1198 1638
 		}
@@ -1221,24 +1661,42 @@  discard block
 block discarded – undo
1221 1661
 		    if (isset($line['inf'])) {
1222 1662
 			$data = array();
1223 1663
 			$data['hex'] = $line['inf']['ia'];
1224
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1664
+			if (isset($line['inf']['cs'])) {
1665
+				$data['ident'] = $line['inf']['cs'];
1666
+			}
1667
+			//$line[13]
1225 1668
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1226
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1227
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1669
+	    		if (isset($line['inf']['gs'])) {
1670
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1671
+	    		}
1672
+	    		// speed
1673
+	    		if (isset($line['inf']['tr'])) {
1674
+	    			$data['heading'] = $line['inf']['tr'];
1675
+	    		}
1676
+	    		// heading
1228 1677
 	    		$data['latitude'] = $line['pt'][0]; // lat
1229 1678
 	    		$data['longitude'] = $line['pt'][1]; // long
1230 1679
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1231
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1680
+	    		if (isset($line['inf']['sq'])) {
1681
+	    			$data['squawk'] = $line['inf']['sq'];
1682
+	    		}
1683
+	    		// squawk
1232 1684
 	    		//$data['aircraft_icao'] = $line[8];
1233
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1685
+	    		if (isset($line['inf']['rc'])) {
1686
+	    			$data['registration'] = $line['inf']['rc'];
1687
+	    		}
1234 1688
 			//$data['departure_airport_iata'] = $line[11];
1235 1689
 			//$data['arrival_airport_iata'] = $line[12];
1236 1690
 	    		//$data['emergency'] = ''; // emergency
1237 1691
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1238 1692
 	    		$data['format_source'] = 'radarvirtueljson';
1239 1693
     			$data['id_source'] = $id_source;
1240
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1241
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1694
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1695
+				$data['noarchive'] = true;
1696
+			}
1697
+			if (isset($value['name']) && $value['name'] != '') {
1698
+				$data['source_name'] = $value['name'];
1699
+			}
1242 1700
 			$SI->add($data);
1243 1701
 			unset($data);
1244 1702
 		    }
@@ -1264,30 +1722,65 @@  discard block
 block discarded – undo
1264 1722
 		    $data['id'] = $line['id'];
1265 1723
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1266 1724
 		    $data['ident'] = $line['callsign']; // ident
1267
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1268
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1269
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1270
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1271
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1272
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1725
+		    if (isset($line['pilotid'])) {
1726
+		    	$data['pilot_id'] = $line['pilotid'];
1727
+		    }
1728
+		    // pilot id
1729
+		    if (isset($line['name'])) {
1730
+		    	$data['pilot_name'] = $line['name'];
1731
+		    }
1732
+		    // pilot name
1733
+		    if (isset($line['alt'])) {
1734
+		    	$data['altitude'] = $line['alt'];
1735
+		    }
1736
+		    // altitude
1737
+		    if (isset($line['gs'])) {
1738
+		    	$data['speed'] = $line['gs'];
1739
+		    }
1740
+		    // speed
1741
+		    if (isset($line['heading'])) {
1742
+		    	$data['heading'] = $line['heading'];
1743
+		    }
1744
+		    // heading
1745
+		    if (isset($line['route'])) {
1746
+		    	$data['waypoints'] = $line['route'];
1747
+		    }
1748
+		    // route
1273 1749
 		    $data['latitude'] = $line['lat']; // lat
1274 1750
 		    $data['longitude'] = $line['lon']; // long
1275 1751
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1276 1752
 		    //$data['squawk'] = $line['squawk']; // squawk
1277 1753
 		    //$data['emergency'] = ''; // emergency
1278
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1279
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1280
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1754
+		    if (isset($line['depicao'])) {
1755
+		    	$data['departure_airport_icao'] = $line['depicao'];
1756
+		    }
1757
+		    if (isset($line['deptime'])) {
1758
+		    	$data['departure_airport_time'] = $line['deptime'];
1759
+		    }
1760
+		    if (isset($line['arricao'])) {
1761
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1762
+		    }
1281 1763
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1282
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1283
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1284
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1285
-		    else $data['info'] = '';
1764
+		    if (isset($line['aircraft'])) {
1765
+		    	$data['aircraft_icao'] = $line['aircraft'];
1766
+		    }
1767
+		    if (isset($line['transponder'])) {
1768
+		    	$data['squawk'] = $line['transponder'];
1769
+		    }
1770
+		    if (isset($line['atis'])) {
1771
+		    	$data['info'] = $line['atis'];
1772
+		    } else {
1773
+		    	$data['info'] = '';
1774
+		    }
1286 1775
 		    $data['format_source'] = 'pireps';
1287 1776
     		    $data['id_source'] = $id_source;
1288 1777
 		    $data['datetime'] = date('Y-m-d H:i:s');
1289
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1290
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1778
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1779
+		    	$data['noarchive'] = true;
1780
+		    }
1781
+		    if (isset($value['name']) && $value['name'] != '') {
1782
+		    	$data['source_name'] = $value['name'];
1783
+		    }
1291 1784
 		    if ($line['icon'] === 'plane') {
1292 1785
 			$SI->add($data);
1293 1786
 		    //    print_r($data);
@@ -1296,16 +1789,28 @@  discard block
 block discarded – undo
1296 1789
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1297 1790
 			$typec = substr($data['ident'],-3);
1298 1791
 			$data['type'] = '';
1299
-			if ($typec === 'APP') $data['type'] = 'Approach';
1300
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1301
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1302
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1303
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1304
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1305
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1306
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1307
-			else $data['type'] = 'Observer';
1308
-			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']);
1792
+			if ($typec === 'APP') {
1793
+				$data['type'] = 'Approach';
1794
+			} elseif ($typec === 'TWR') {
1795
+				$data['type'] = 'Tower';
1796
+			} elseif ($typec === 'OBS') {
1797
+				$data['type'] = 'Observer';
1798
+			} elseif ($typec === 'GND') {
1799
+				$data['type'] = 'Ground';
1800
+			} elseif ($typec === 'DEL') {
1801
+				$data['type'] = 'Delivery';
1802
+			} elseif ($typec === 'DEP') {
1803
+				$data['type'] = 'Departure';
1804
+			} elseif ($typec === 'FSS') {
1805
+				$data['type'] = 'Flight Service Station';
1806
+			} elseif ($typec === 'CTR') {
1807
+				$data['type'] = 'Control Radar or Centre';
1808
+			} else {
1809
+				$data['type'] = 'Observer';
1810
+			}
1811
+			if (isset($ATC)) {
1812
+				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']);
1813
+			}
1309 1814
 		    }
1310 1815
 		    unset($data);
1311 1816
 		}
@@ -1320,7 +1825,9 @@  discard block
 block discarded – undo
1320 1825
 	    )
1321 1826
 	) {
1322 1827
 	    //$buffer = $Common->getData($hosts[$id]);
1323
-	    if ($globalDebug) echo 'Get Data...'."\n";
1828
+	    if ($globalDebug) {
1829
+	    	echo 'Get Data...'."\n";
1830
+	    }
1324 1831
 	    $buffer = $Common->getData($value['host']);
1325 1832
 	    $all_data = json_decode($buffer,true);
1326 1833
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1328,10 +1835,16 @@  discard block
 block discarded – undo
1328 1835
 		foreach ($all_data as $line) {
1329 1836
 	    	    $data = array();
1330 1837
 	    	    //$data['id'] = $line['id']; // id not usable
1331
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1838
+	    	    if (isset($line['pilotid'])) {
1839
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1840
+	    	    }
1332 1841
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1333
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1334
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1842
+	    	    if (isset($line['pilotname'])) {
1843
+	    	    	$data['pilot_name'] = $line['pilotname'];
1844
+	    	    }
1845
+	    	    if (isset($line['pilotid'])) {
1846
+	    	    	$data['pilot_id'] = $line['pilotid'];
1847
+	    	    }
1335 1848
 	    	    $data['ident'] = $line['flightnum']; // ident
1336 1849
 	    	    $data['altitude'] = $line['alt']; // altitude
1337 1850
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1347,7 +1860,9 @@  discard block
 block discarded – undo
1347 1860
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1348 1861
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1349 1862
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1350
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1863
+	    	    } else {
1864
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1865
+	    	    }
1351 1866
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1352 1867
 	    	    $data['departure_airport_time'] = $line['deptime'];
1353 1868
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1355,29 +1870,47 @@  discard block
 block discarded – undo
1355 1870
     		    if (isset($line['registration'])) {
1356 1871
     			$data['registration'] = $line['registration'];
1357 1872
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1358
-    		    } else $data['registration'] = $line['aircraft'];
1359
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1360
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1873
+    		    } else {
1874
+    		    	$data['registration'] = $line['aircraft'];
1875
+    		    }
1876
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1877
+		    	$data['noarchive'] = true;
1878
+		    }
1879
+		    if (isset($line['route'])) {
1880
+		    	$data['waypoints'] = $line['route'];
1881
+		    }
1882
+		    // route
1361 1883
 		    if (isset($line['aircraftname'])) {
1362 1884
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1363 1885
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1364 1886
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1365
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1366
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1367
-	    		else {
1887
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1888
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1889
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1890
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1891
+	    		} else {
1368 1892
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1369
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1370
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1893
+	    		    if (isset($aircraft_data[1])) {
1894
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1895
+	    		    } else {
1896
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1897
+	    		    }
1371 1898
 	    		}
1372 1899
 	    	    }
1373
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1900
+    		    if (isset($line['route'])) {
1901
+    		    	$data['waypoints'] = $line['route'];
1902
+    		    }
1374 1903
     		    $data['id_source'] = $id_source;
1375 1904
 	    	    $data['format_source'] = 'phpvmacars';
1376
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1905
+		    if (isset($value['name']) && $value['name'] != '') {
1906
+		    	$data['source_name'] = $value['name'];
1907
+		    }
1377 1908
 		    $SI->add($data);
1378 1909
 		    unset($data);
1379 1910
 		}
1380
-		if ($globalDebug) echo 'No more data...'."\n";
1911
+		if ($globalDebug) {
1912
+			echo 'No more data...'."\n";
1913
+		}
1381 1914
 		unset($buffer);
1382 1915
 		unset($all_data);
1383 1916
 	    }
@@ -1390,7 +1923,9 @@  discard block
 block discarded – undo
1390 1923
 	    )
1391 1924
 	) {
1392 1925
 	    //$buffer = $Common->getData($hosts[$id]);
1393
-	    if ($globalDebug) echo 'Get Data...'."\n";
1926
+	    if ($globalDebug) {
1927
+	    	echo 'Get Data...'."\n";
1928
+	    }
1394 1929
 	    $buffer = $Common->getData($value['host']);
1395 1930
 	    $all_data = json_decode($buffer,true);
1396 1931
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1401,10 +1936,16 @@  discard block
 block discarded – undo
1401 1936
 	    	    //$data['id'] = $line['id']; // id not usable
1402 1937
 	    	    $data['id'] = $line['id'];
1403 1938
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1404
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1405
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1939
+	    	    if (isset($line['user']['username'])) {
1940
+	    	    	$data['pilot_name'] = $line['user']['username'];
1941
+	    	    }
1942
+	    	    if (isset($line['user_id'])) {
1943
+	    	    	$data['pilot_id'] = $line['user_id'];
1944
+	    	    }
1406 1945
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1407
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1946
+	    	    if (is_numeric($data['ident'])) {
1947
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1948
+	    	    }
1408 1949
 	    	    $data['altitude'] = $line['altitude']; // altitude
1409 1950
 	    	    $data['speed'] = $line['groundspeed']; // speed
1410 1951
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1417,7 +1958,9 @@  discard block
 block discarded – undo
1417 1958
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1418 1959
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1419 1960
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1420
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1961
+	    	    } else {
1962
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1963
+	    	    }
1421 1964
 	    	    
1422 1965
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1423 1966
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1425,17 +1968,26 @@  discard block
 block discarded – undo
1425 1968
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1426 1969
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1427 1970
 
1428
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1429
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1971
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1972
+		    	$data['noarchive'] = true;
1973
+		    }
1974
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
1975
+		    	$data['waypoints'] = $line['bid']['route'];
1976
+		    }
1977
+		    // route
1430 1978
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1431 1979
 
1432 1980
     		    $data['id_source'] = $id_source;
1433 1981
 	    	    $data['format_source'] = 'vaos';
1434
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1982
+		    if (isset($value['name']) && $value['name'] != '') {
1983
+		    	$data['source_name'] = $value['name'];
1984
+		    }
1435 1985
 		    $SI->add($data);
1436 1986
 		    unset($data);
1437 1987
 		}
1438
-		if ($globalDebug) echo 'No more data...'."\n";
1988
+		if ($globalDebug) {
1989
+			echo 'No more data...'."\n";
1990
+		}
1439 1991
 		unset($buffer);
1440 1992
 		unset($all_data);
1441 1993
 	    }
@@ -1448,7 +2000,9 @@  discard block
 block discarded – undo
1448 2000
 	    )
1449 2001
 	) {
1450 2002
 	    //$buffer = $Common->getData($hosts[$id]);
1451
-	    if ($globalDebug) echo 'Get Data...'."\n";
2003
+	    if ($globalDebug) {
2004
+	    	echo 'Get Data...'."\n";
2005
+	    }
1452 2006
 	    $buffer = $Common->getData($value['host']);
1453 2007
 	    $all_data = json_decode($buffer,true);
1454 2008
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1477,16 +2031,25 @@  discard block
 block discarded – undo
1477 2031
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1478 2032
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1479 2033
     		    //$data['registration'] = $line['aircraft'];
1480
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2034
+		    if (isset($line['route'])) {
2035
+		    	$data['waypoints'] = $line['route'];
2036
+		    }
2037
+		    // route
1481 2038
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1482 2039
     		    $data['id_source'] = $id_source;
1483 2040
 	    	    $data['format_source'] = 'vam';
1484
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1485
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2041
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2042
+		    	$data['noarchive'] = true;
2043
+		    }
2044
+		    if (isset($value['name']) && $value['name'] != '') {
2045
+		    	$data['source_name'] = $value['name'];
2046
+		    }
1486 2047
 		    $SI->add($data);
1487 2048
 		    unset($data);
1488 2049
 		}
1489
-		if ($globalDebug) echo 'No more data...'."\n";
2050
+		if ($globalDebug) {
2051
+			echo 'No more data...'."\n";
2052
+		}
1490 2053
 		unset($buffer);
1491 2054
 		unset($all_data);
1492 2055
 	    }
@@ -1499,7 +2062,9 @@  discard block
 block discarded – undo
1499 2062
 	    )
1500 2063
 	) {
1501 2064
 	    //$buffer = $Common->getData($hosts[$id]);
1502
-	    if ($globalDebug) echo 'Get Data...'."\n";
2065
+	    if ($globalDebug) {
2066
+	    	echo 'Get Data...'."\n";
2067
+	    }
1503 2068
 	    $buffer = $Common->getData($value['host']);
1504 2069
 	    $all_data = json_decode($buffer,true);
1505 2070
 	    if ($buffer != '') {
@@ -1517,12 +2082,16 @@  discard block
 block discarded – undo
1517 2082
 			$data['id_source'] = $id_source;
1518 2083
 			$data['format_source'] = 'blitzortung';
1519 2084
 			$SI->add($data);
1520
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2085
+			if ($globalDebug) {
2086
+				echo '☈ Lightning added'."\n";
2087
+			}
1521 2088
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1522 2089
 			unset($data);
1523 2090
 		    }
1524 2091
 		}
1525
-		if ($globalDebug) echo 'No more data...'."\n";
2092
+		if ($globalDebug) {
2093
+			echo 'No more data...'."\n";
2094
+		}
1526 2095
 		unset($buffer);
1527 2096
 	    }
1528 2097
 	    $last_exec[$id]['last'] = time();
@@ -1534,7 +2103,9 @@  discard block
 block discarded – undo
1534 2103
 	    $write = NULL;
1535 2104
 	    $e = NULL;
1536 2105
 	    $n = socket_select($read, $write, $e, $timeout);
1537
-	    if ($e != NULL) var_dump($e);
2106
+	    if ($e != NULL) {
2107
+	    	var_dump($e);
2108
+	    }
1538 2109
 	    if ($n > 0) {
1539 2110
 		$reset = 0;
1540 2111
 		foreach ($read as $nb => $r) {
@@ -1556,13 +2127,17 @@  discard block
 block discarded – undo
1556 2127
 		    if ($buffer !== FALSE) {
1557 2128
 			if ($format === 'vrstcp') {
1558 2129
 			    $buffer = explode('},{',$buffer);
1559
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2130
+			} else {
2131
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2132
+			}
1560 2133
 		    }
1561 2134
 		    // SBS format is CSV format
1562 2135
 		    if ($buffer !== FALSE && $buffer !== '') {
1563 2136
 			$tt[$format] = 0;
1564 2137
 			if ($format === 'acarssbs3') {
1565
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2138
+			    if ($globalDebug) {
2139
+			    	echo 'ACARS : '.$buffer."\n";
2140
+			    }
1566 2141
 			    $ACARS->add(trim($buffer));
1567 2142
 			    $ACARS->deleteLiveAcarsData();
1568 2143
 			} elseif ($format === 'raw') {
@@ -1571,30 +2146,70 @@  discard block
 block discarded – undo
1571 2146
 			    if (is_array($data)) {
1572 2147
 				$data['datetime'] = date('Y-m-d H:i:s');
1573 2148
 				$data['format_source'] = 'raw';
1574
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1575
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1576
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1577
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2149
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2150
+					$data['source_name'] = $globalSources[$nb]['name'];
2151
+				}
2152
+				if (isset($globalSources[$nb]['sourcestats'])) {
2153
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2154
+				}
2155
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2156
+					$data['noarchive'] = true;
2157
+				}
2158
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2159
+					$SI->add($data);
2160
+				}
1578 2161
 			    }
1579 2162
 			} elseif ($format === 'ais') {
1580 2163
 			    $ais_data = $AIS->parse_line(trim($buffer));
1581 2164
 			    $data = array();
1582
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1583
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1584
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1585
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1586
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1587
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1588
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1589
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1590
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1591
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1592
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1593
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1594
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1595
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1596
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1597
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2165
+			    if (isset($ais_data['ident'])) {
2166
+			    	$data['ident'] = $ais_data['ident'];
2167
+			    }
2168
+			    if (isset($ais_data['mmsi'])) {
2169
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2170
+			    }
2171
+			    if (isset($ais_data['speed'])) {
2172
+			    	$data['speed'] = $ais_data['speed'];
2173
+			    }
2174
+			    if (isset($ais_data['heading'])) {
2175
+			    	$data['heading'] = $ais_data['heading'];
2176
+			    }
2177
+			    if (isset($ais_data['latitude'])) {
2178
+			    	$data['latitude'] = $ais_data['latitude'];
2179
+			    }
2180
+			    if (isset($ais_data['longitude'])) {
2181
+			    	$data['longitude'] = $ais_data['longitude'];
2182
+			    }
2183
+			    if (isset($ais_data['status'])) {
2184
+			    	$data['status'] = $ais_data['status'];
2185
+			    }
2186
+			    if (isset($ais_data['statusid'])) {
2187
+			    	$data['status_id'] = $ais_data['statusid'];
2188
+			    }
2189
+			    if (isset($ais_data['type'])) {
2190
+			    	$data['type'] = $ais_data['type'];
2191
+			    }
2192
+			    if (isset($ais_data['imo'])) {
2193
+			    	$data['imo'] = $ais_data['imo'];
2194
+			    }
2195
+			    if (isset($ais_data['callsign'])) {
2196
+			    	$data['callsign'] = $ais_data['callsign'];
2197
+			    }
2198
+			    if (isset($ais_data['destination'])) {
2199
+			    	$data['arrival_code'] = $ais_data['destination'];
2200
+			    }
2201
+			    if (isset($ais_data['eta_ts'])) {
2202
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2203
+			    }
2204
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2205
+			    	$data['noarchive'] = true;
2206
+			    }
2207
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2208
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2209
+			    }
2210
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2211
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2212
+			    }
1598 2213
 
1599 2214
 			    if (isset($ais_data['timestamp'])) {
1600 2215
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1603,7 +2218,9 @@  discard block
 block discarded – undo
1603 2218
 			    }
1604 2219
 			    $data['format_source'] = 'aisnmea';
1605 2220
     			    $data['id_source'] = $id_source;
1606
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2221
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2222
+			    	$MI->add($data);
2223
+			    }
1607 2224
 			    unset($data);
1608 2225
                         } elseif ($format === 'flightgearsp') {
1609 2226
                     	    //echo $buffer."\n";
@@ -1621,12 +2238,18 @@  discard block
 block discarded – undo
1621 2238
 				$data['speed'] = round($line[5]*1.94384);
1622 2239
 				$data['datetime'] = date('Y-m-d H:i:s');
1623 2240
 				$data['format_source'] = 'flightgearsp';
1624
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1625
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2241
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2242
+					$data['noarchive'] = true;
2243
+				}
2244
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2245
+					$SI->add($data);
2246
+				}
1626 2247
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1627 2248
 			    }
1628 2249
                         } elseif ($format === 'acars') {
1629
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2250
+                    	    if ($globalDebug) {
2251
+                    	    	echo 'ACARS : '.$buffer."\n";
2252
+                    	    }
1630 2253
 			    $ACARS->add(trim($buffer));
1631 2254
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1632 2255
 			    $ACARS->deleteLiveAcarsData();
@@ -1647,8 +2270,12 @@  discard block
 block discarded – undo
1647 2270
 				    $aircraft_type = $line[10];
1648 2271
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1649 2272
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1650
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1651
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2273
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2274
+				    	$data['noarchive'] = true;
2275
+				    }
2276
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2277
+				    	$SI->add($data);
2278
+				    }
1652 2279
 				}
1653 2280
 			    }
1654 2281
 			} elseif ($format === 'beast') {
@@ -1658,28 +2285,62 @@  discard block
 block discarded – undo
1658 2285
 			    foreach($buffer as $all_data) {
1659 2286
 				$line = json_decode('{'.$all_data.'}',true);
1660 2287
 				$data = array();
1661
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1662
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1663
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1664
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1665
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1666
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1667
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2288
+				if (isset($line['Icao'])) {
2289
+					$data['hex'] = $line['Icao'];
2290
+				}
2291
+				// hex
2292
+				if (isset($line['Call'])) {
2293
+					$data['ident'] = $line['Call'];
2294
+				}
2295
+				// ident
2296
+				if (isset($line['Alt'])) {
2297
+					$data['altitude'] = $line['Alt'];
2298
+				}
2299
+				// altitude
2300
+				if (isset($line['Spd'])) {
2301
+					$data['speed'] = $line['Spd'];
2302
+				}
2303
+				// speed
2304
+				if (isset($line['Trak'])) {
2305
+					$data['heading'] = $line['Trak'];
2306
+				}
2307
+				// heading
2308
+				if (isset($line['Lat'])) {
2309
+					$data['latitude'] = $line['Lat'];
2310
+				}
2311
+				// lat
2312
+				if (isset($line['Long'])) {
2313
+					$data['longitude'] = $line['Long'];
2314
+				}
2315
+				// long
1668 2316
 				//$data['verticalrate'] = $line['']; // verticale rate
1669
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2317
+				if (isset($line['Sqk'])) {
2318
+					$data['squawk'] = $line['Sqk'];
2319
+				}
2320
+				// squawk
1670 2321
 				$data['emergency'] = ''; // emergency
1671
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2322
+				if (isset($line['Reg'])) {
2323
+					$data['registration'] = $line['Reg'];
2324
+				}
1672 2325
 				/*
1673 2326
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1674 2327
 				else $data['datetime'] = date('Y-m-d H:i:s');
1675 2328
 				*/
1676 2329
 				$data['datetime'] = date('Y-m-d H:i:s');
1677
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2330
+				if (isset($line['Type'])) {
2331
+					$data['aircraft_icao'] = $line['Type'];
2332
+				}
1678 2333
 		    		$data['format_source'] = 'vrstcp';
1679 2334
 				$data['id_source'] = $id_source;
1680
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1681
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1682
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2335
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2336
+					$data['noarchive'] = true;
2337
+				}
2338
+				if (isset($value['name']) && $value['name'] != '') {
2339
+					$data['source_name'] = $value['name'];
2340
+				}
2341
+				if (isset($data['latitude']) && isset($data['hex'])) {
2342
+					$SI->add($data);
2343
+				}
1683 2344
 				unset($data);
1684 2345
 			    }
1685 2346
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1692,22 +2353,46 @@  discard block
 block discarded – undo
1692 2353
     				$data['hex'] = $lined['hexid'];
1693 2354
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1694 2355
     				$data['datetime'] = date('Y-m-d H:i:s');;
1695
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1696
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1697
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1698
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1699
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1700
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1701
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2356
+    				if (isset($lined['ident'])) {
2357
+    					$data['ident'] = $lined['ident'];
2358
+    				}
2359
+    				if (isset($lined['lat'])) {
2360
+    					$data['latitude'] = $lined['lat'];
2361
+    				}
2362
+    				if (isset($lined['lon'])) {
2363
+    					$data['longitude'] = $lined['lon'];
2364
+    				}
2365
+    				if (isset($lined['speed'])) {
2366
+    					$data['speed'] = $lined['speed'];
2367
+    				}
2368
+    				if (isset($lined['squawk'])) {
2369
+    					$data['squawk'] = $lined['squawk'];
2370
+    				}
2371
+    				if (isset($lined['alt'])) {
2372
+    					$data['altitude'] = $lined['alt'];
2373
+    				}
2374
+    				if (isset($lined['heading'])) {
2375
+    					$data['heading'] = $lined['heading'];
2376
+    				}
1702 2377
     				$data['id_source'] = $id_source;
1703 2378
     				$data['format_source'] = 'tsv';
1704
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1705
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1706
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1707
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2379
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2380
+    					$data['source_name'] = $globalSources[$nb]['name'];
2381
+    				}
2382
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2383
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2384
+    				}
2385
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2386
+					$data['noarchive'] = true;
2387
+				}
2388
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2389
+    					$SI->add($data);
2390
+    				}
1708 2391
     				unset($lined);
1709 2392
     				unset($data);
1710
-    			    } else $error = true;
2393
+    			    } else {
2394
+    			    	$error = true;
2395
+    			    }
1711 2396
 			} elseif ($format === 'aprs' && $use_aprs) {
1712 2397
 			    if ($aprs_connect === 0) {
1713 2398
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1733,47 +2418,96 @@  discard block
 block discarded – undo
1733 2418
 				    $aprs_last_tx = time();
1734 2419
 				    $data = array();
1735 2420
 				    //print_r($line);
1736
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1737
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1738
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1739
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1740
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1741
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1742
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1743
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1744
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1745
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2421
+				    if (isset($line['address'])) {
2422
+				    	$data['hex'] = $line['address'];
2423
+				    }
2424
+				    if (isset($line['mmsi'])) {
2425
+				    	$data['mmsi'] = $line['mmsi'];
2426
+				    }
2427
+				    if (isset($line['imo'])) {
2428
+				    	$data['imo'] = $line['imo'];
2429
+				    }
2430
+				    if (isset($line['squawk'])) {
2431
+				    	$data['squawk'] = $line['squawk'];
2432
+				    }
2433
+				    if (isset($line['arrival_code'])) {
2434
+				    	$data['arrival_code'] = $line['arrival_code'];
2435
+				    }
2436
+				    if (isset($line['arrival_date'])) {
2437
+				    	$data['arrival_date'] = $line['arrival_date'];
2438
+				    }
2439
+				    if (isset($line['typeid'])) {
2440
+				    	$data['type_id'] = $line['typeid'];
2441
+				    }
2442
+				    if (isset($line['statusid'])) {
2443
+				    	$data['status_id'] = $line['statusid'];
2444
+				    }
2445
+				    if (isset($line['timestamp'])) {
2446
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2447
+				    } else {
2448
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2449
+				    }
1746 2450
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1747
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2451
+				    if (isset($line['ident'])) {
2452
+				    	$data['ident'] = $line['ident'];
2453
+				    }
1748 2454
 				    $data['latitude'] = $line['latitude'];
1749 2455
 				    $data['longitude'] = $line['longitude'];
1750 2456
 				    //$data['verticalrate'] = $line[16];
1751
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2457
+				    if (isset($line['speed'])) {
2458
+				    	$data['speed'] = $line['speed'];
2459
+				    }
1752 2460
 				    //else $data['speed'] = 0;
1753
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1754
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1755
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2461
+				    if (isset($line['altitude'])) {
2462
+				    	$data['altitude'] = $line['altitude'];
2463
+				    }
2464
+				    if (isset($line['comment'])) {
2465
+				    	$data['comment'] = $line['comment'];
2466
+				    }
2467
+				    if (isset($line['symbol'])) {
2468
+				    	$data['type'] = $line['symbol'];
2469
+				    }
1756 2470
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1757 2471
 				    
1758
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2472
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2473
+				    	$data['heading'] = $line['heading'];
2474
+				    }
1759 2475
 				    //else echo 'No heading...'."\n";
1760 2476
 				    //else $data['heading'] = 0;
1761
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2477
+				    if (isset($line['stealth'])) {
2478
+				    	$data['aircraft_type'] = $line['stealth'];
2479
+				    }
1762 2480
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1763
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1764
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1765
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1766
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2481
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2482
+				    	$data['noarchive'] = true;
2483
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2484
+				    	$data['noarchive'] = false;
2485
+				    }
2486
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2487
+				    	$data['noarchive'] = true;
2488
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2489
+				    	$data['noarchive'] = false;
2490
+				    }
1767 2491
     				    $data['id_source'] = $id_source;
1768
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1769
-				    else $data['format_source'] = 'aprs';
2492
+    				    if (isset($line['format_source'])) {
2493
+    				    	$data['format_source'] = $line['format_source'];
2494
+    				    } else {
2495
+				    	$data['format_source'] = 'aprs';
2496
+				    }
1770 2497
 				    $data['source_name'] = $line['source'];
1771
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1772
-				    else $data['source_type'] = 'flarm';
1773
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2498
+				    if (isset($line['source_type'])) {
2499
+				    	$data['source_type'] = $line['source_type'];
2500
+				    } else {
2501
+				    	$data['source_type'] = 'flarm';
2502
+				    }
2503
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2504
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2505
+    				    }
1774 2506
 				    $currentdate = date('Y-m-d H:i:s');
1775 2507
 				    $aprsdate = strtotime($data['datetime']);
1776
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2508
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2509
+				    	$data['altitude_relative'] = 'AMSL';
2510
+				    }
1777 2511
 				    // Accept data if time <= system time + 20s
1778 2512
 				    //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'])))) {
1779 2513
 				    if (
@@ -1785,7 +2519,9 @@  discard block
 block discarded – undo
1785 2519
 					$send = $SI->add($data);
1786 2520
 				    } elseif ($data['source_type'] === 'ais') {
1787 2521
 					$data['type'] = '';
1788
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2522
+					if (isset($globalMarine) && $globalMarine) {
2523
+						$send = $MI->add($data);
2524
+					}
1789 2525
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1790 2526
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1791 2527
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1793,8 +2529,12 @@  discard block
 block discarded – undo
1793 2529
 					    $line['symbol'] === 'Glider' || 
1794 2530
 					    $line['symbol'] === 'No. Plane' || 
1795 2531
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1796
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1797
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2532
+					    if ($line['symbol'] === 'Ballon') {
2533
+					    	$data['aircraft_icao'] = 'BALL';
2534
+					    }
2535
+					    if ($line['symbol'] === 'Glider') {
2536
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2537
+					    }
1798 2538
 					    $send = $SI->add($data);
1799 2539
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1800 2540
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1825,9 +2565,13 @@  discard block
 block discarded – undo
1825 2565
 				    //} 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') {
1826 2566
 				//    } 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') {
1827 2567
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1828
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2568
+					if (isset($globalTracker) && $globalTracker) {
2569
+						$send = $TI->add($data);
2570
+					}
1829 2571
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1830
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2572
+					if (!isset($data['altitude'])) {
2573
+						$data['altitude'] = 0;
2574
+					}
1831 2575
 					$Source->deleteOldLocationByType('gs');
1832 2576
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1833 2577
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1836,7 +2580,9 @@  discard block
 block discarded – undo
1836 2580
 					}
1837 2581
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1838 2582
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1839
-					if ($globalDebug) echo '# Weather Station added'."\n";
2583
+					if ($globalDebug) {
2584
+						echo '# Weather Station added'."\n";
2585
+					}
1840 2586
 					$Source->deleteOldLocationByType('wx');
1841 2587
 					$weather_data = json_encode($line);
1842 2588
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1846,7 +2592,9 @@  discard block
 block discarded – undo
1846 2592
 					}
1847 2593
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1848 2594
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1849
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2595
+					if ($globalDebug) {
2596
+						echo '☈ Lightning added'."\n";
2597
+					}
1850 2598
 					$Source->deleteOldLocationByType('lightning');
1851 2599
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1852 2600
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1858,8 +2606,7 @@  discard block
 block discarded – undo
1858 2606
 				    	print_r($line);
1859 2607
 				    }
1860 2608
 				    unset($data);
1861
-				}
1862
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2609
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1863 2610
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1864 2611
 				}
1865 2612
 				/*
@@ -1868,7 +2615,9 @@  discard block
 block discarded – undo
1868 2615
 				}
1869 2616
 				*/
1870 2617
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1871
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2618
+				elseif ($line === true && $globalDebug) {
2619
+					echo '!! Failed : '.$buffer."!!\n";
2620
+				}
1872 2621
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1873 2622
 					$Source->deleteOldLocationByType('lightning');
1874 2623
 					$Source->deleteOldLocationByType('wx');
@@ -1904,27 +2653,47 @@  discard block
 block discarded – undo
1904 2653
     				$data['ground'] = $line[21];
1905 2654
     				$data['emergency'] = $line[19];
1906 2655
     				$data['format_source'] = 'sbs';
1907
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1908
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1909
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1910
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2656
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2657
+					$data['source_name'] = $globalSources[$nb]['name'];
2658
+				} elseif ($line[0] == 'MLAT') {
2659
+					$data['source_name'] = 'MLAT';
2660
+				}
2661
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2662
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2663
+    				}
2664
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2665
+					$data['noarchive'] = true;
2666
+				}
1911 2667
     				$data['id_source'] = $id_source;
1912
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1913
-    				else $error = true;
2668
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2669
+    					$send = $SI->add($data);
2670
+    				} else {
2671
+    					$error = true;
2672
+    				}
1914 2673
     				unset($data);
1915
-    			    } else $error = true;
2674
+    			    } else {
2675
+    			    	$error = true;
2676
+    			    }
1916 2677
 			    if ($error) {
1917 2678
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1918
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2679
+					if ($globalDebug) {
2680
+						echo "Not a message. Ignoring... \n";
2681
+					}
1919 2682
 				} else {
1920
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2683
+					if ($globalDebug) {
2684
+						echo "Wrong line format. Ignoring... \n";
2685
+					}
1921 2686
 					if ($globalDebug) {
1922 2687
 						echo $buffer;
1923 2688
 						//print_r($line);
1924 2689
 					}
1925 2690
 					//socket_close($r);
1926
-					if ($globalDebug) echo "Reconnect after an error...\n";
1927
-					if ($format === 'aprs') $aprs_connect = 0;
2691
+					if ($globalDebug) {
2692
+						echo "Reconnect after an error...\n";
2693
+					}
2694
+					if ($format === 'aprs') {
2695
+						$aprs_connect = 0;
2696
+					}
1928 2697
 					$sourceer[$nb] = $globalSources[$nb];
1929 2698
 					connect_all($sourceer);
1930 2699
 					$sourceer = array();
@@ -1932,10 +2701,14 @@  discard block
 block discarded – undo
1932 2701
 			    }
1933 2702
 			}
1934 2703
 			// Sleep for xxx microseconds
1935
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2704
+			if (isset($globalSBSSleep)) {
2705
+				usleep($globalSBSSleep);
2706
+			}
1936 2707
 		    } else {
1937 2708
 			if ($format === 'flightgearmp') {
1938
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2709
+			    	if ($globalDebug) {
2710
+			    		echo "Reconnect FlightGear MP...";
2711
+			    	}
1939 2712
 				//@socket_close($r);
1940 2713
 				sleep($globalMinFetch);
1941 2714
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1944,10 +2717,15 @@  discard block
 block discarded – undo
1944 2717
 				break;
1945 2718
 				
1946 2719
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1947
-			    if (isset($tt[$format])) $tt[$format]++;
1948
-			    else $tt[$format] = 0;
2720
+			    if (isset($tt[$format])) {
2721
+			    	$tt[$format]++;
2722
+			    } else {
2723
+			    	$tt[$format] = 0;
2724
+			    }
1949 2725
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1950
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2726
+				if ($globalDebug) {
2727
+					echo "ERROR : Reconnect ".$format."...";
2728
+				}
1951 2729
 				//@socket_close($r);
1952 2730
 				sleep(2);
1953 2731
 				$aprs_connect = 0;
@@ -1965,11 +2743,17 @@  discard block
 block discarded – undo
1965 2743
 	    } else {
1966 2744
 		$error = socket_strerror(socket_last_error());
1967 2745
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1968
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1969
-			if (isset($globalDebug)) echo "Restarting...\n";
2746
+			if ($globalDebug) {
2747
+				echo "ERROR : socket_select give this error ".$error . "\n";
2748
+			}
2749
+			if (isset($globalDebug)) {
2750
+				echo "Restarting...\n";
2751
+			}
1970 2752
 			// Restart the script if possible
1971 2753
 			if (is_array($sockets)) {
1972
-			    if ($globalDebug) echo "Shutdown all sockets...";
2754
+			    if ($globalDebug) {
2755
+			    	echo "Shutdown all sockets...";
2756
+			    }
1973 2757
 			    
1974 2758
 			    foreach ($sockets as $sock) {
1975 2759
 				@socket_shutdown($sock,2);
@@ -1977,25 +2761,45 @@  discard block
 block discarded – undo
1977 2761
 			    }
1978 2762
 			    
1979 2763
 			}
1980
-			if ($globalDebug) echo "Waiting...";
2764
+			if ($globalDebug) {
2765
+				echo "Waiting...";
2766
+			}
1981 2767
 			sleep(2);
1982 2768
 			$time = time();
1983 2769
 			//connect_all($hosts);
1984 2770
 			$aprs_connect = 0;
1985
-			if ($reset%5 === 0) sleep(20);
1986
-			if ($reset%10 === 0) sleep(100);
1987
-			if ($reset%20 === 0) sleep(200);
1988
-			if ($reset > 100) exit('Too many attempts...');
1989
-			if ($globalDebug) echo "Restart all connections...";
2771
+			if ($reset%5 === 0) {
2772
+				sleep(20);
2773
+			}
2774
+			if ($reset%10 === 0) {
2775
+				sleep(100);
2776
+			}
2777
+			if ($reset%20 === 0) {
2778
+				sleep(200);
2779
+			}
2780
+			if ($reset > 100) {
2781
+				exit('Too many attempts...');
2782
+			}
2783
+			if ($globalDebug) {
2784
+				echo "Restart all connections...";
2785
+			}
1990 2786
 			connect_all($globalSources);
1991 2787
 		}
1992 2788
 	    }
1993 2789
 	}
1994 2790
 	if ($globalDaemon === false) {
1995
-	    if ($globalDebug) echo 'Check all...'."\n";
1996
-	    if (isset($SI)) $SI->checkAll();
1997
-	    if (isset($TI)) $TI->checkAll();
1998
-	    if (isset($MI)) $MI->checkAll();
2791
+	    if ($globalDebug) {
2792
+	    	echo 'Check all...'."\n";
2793
+	    }
2794
+	    if (isset($SI)) {
2795
+	    	$SI->checkAll();
2796
+	    }
2797
+	    if (isset($TI)) {
2798
+	    	$TI->checkAll();
2799
+	    }
2800
+	    if (isset($MI)) {
2801
+	    	$MI->checkAll();
2802
+	    }
1999 2803
 	}
2000 2804
     }
2001 2805
 }
Please login to merge, or discard this patch.