Completed
Push — master ( 7c25a0...e3e251 )
by Yannick
29:02
created
scripts/daemon-spotter.php 3 patches
Indentation   +958 added lines, -958 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 if (isset($options['idsource'])) $id_source = $options['idsource'];
86 86
 else $id_source = 1;
87 87
 if (isset($globalServer) && $globalServer) {
88
-    if ($globalDebug) echo "Using Server Mode\n";
89
-    $SI=new SpotterServer();
88
+	if ($globalDebug) echo "Using Server Mode\n";
89
+	$SI=new SpotterServer();
90 90
 /*
91 91
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
92 92
     $SI = new adsb2aprs();
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 
97 97
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
98 98
 if (isset($globalMarine) && $globalMarine) {
99
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
100
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
99
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
100
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
101 101
 }
102 102
 
103 103
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
104 104
 if (isset($globalMarine) && $globalMarine) {
105
-    $AIS = new AIS();
106
-    $MI = new MarineImport($Connection->db);
105
+	$AIS = new AIS();
106
+	$MI = new MarineImport($Connection->db);
107 107
 }
108 108
 //$APRS=new APRS($Connection->db);
109 109
 $SBS=new SBS();
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
 //$servertz = system('date +%Z');
115 115
 // signal handler - playing nice with sockets and dump1090
116 116
 if (function_exists('pcntl_fork')) {
117
-    pcntl_signal(SIGINT,  function() {
118
-        global $sockets;
119
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
120
-        die("Bye!\n");
121
-    });
122
-    pcntl_signal_dispatch();
117
+	pcntl_signal(SIGINT,  function() {
118
+		global $sockets;
119
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
120
+		die("Bye!\n");
121
+	});
122
+	pcntl_signal_dispatch();
123 123
 }
124 124
 
125 125
 // let's try and connect
@@ -129,36 +129,36 @@  discard block
 block discarded – undo
129 129
 $reset = 0;
130 130
 
131 131
 function connect_all($hosts) {
132
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
133
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
134
-    $reset++;
135
-    if ($globalDebug) echo 'Connect to all...'."\n";
136
-    foreach ($hosts as $id => $value) {
132
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
133
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
134
+	$reset++;
135
+	if ($globalDebug) echo 'Connect to all...'."\n";
136
+	foreach ($hosts as $id => $value) {
137 137
 	$host = $value['host'];
138 138
 	$globalSources[$id]['last_exec'] = 0;
139 139
 	// Here we check type of source(s)
140 140
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
141
-            if (preg_match('/deltadb.txt$/i',$host)) {
142
-        	//$formats[$id] = 'deltadbtxt';
143
-        	$globalSources[$id]['format'] = 'deltadbtxt';
144
-        	//$last_exec['deltadbtxt'] = 0;
145
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
146
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
147
-        	//$formats[$id] = 'vatsimtxt';
148
-        	$globalSources[$id]['format'] = 'vatsimtxt';
149
-        	//$last_exec['vatsimtxt'] = 0;
150
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
151
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
152
-        	//$formats[$id] = 'aircraftlistjson';
153
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
154
-        	//$last_exec['aircraftlistjson'] = 0;
155
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
156
-    	    } else if (preg_match('/opensky/i',$host)) {
157
-        	//$formats[$id] = 'aircraftlistjson';
158
-        	$globalSources[$id]['format'] = 'opensky';
159
-        	//$last_exec['aircraftlistjson'] = 0;
160
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
161
-    	    /*
141
+			if (preg_match('/deltadb.txt$/i',$host)) {
142
+			//$formats[$id] = 'deltadbtxt';
143
+			$globalSources[$id]['format'] = 'deltadbtxt';
144
+			//$last_exec['deltadbtxt'] = 0;
145
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
146
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
147
+			//$formats[$id] = 'vatsimtxt';
148
+			$globalSources[$id]['format'] = 'vatsimtxt';
149
+			//$last_exec['vatsimtxt'] = 0;
150
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
151
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
152
+			//$formats[$id] = 'aircraftlistjson';
153
+			$globalSources[$id]['format'] = 'aircraftlistjson';
154
+			//$last_exec['aircraftlistjson'] = 0;
155
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
156
+			} else if (preg_match('/opensky/i',$host)) {
157
+			//$formats[$id] = 'aircraftlistjson';
158
+			$globalSources[$id]['format'] = 'opensky';
159
+			//$last_exec['aircraftlistjson'] = 0;
160
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
161
+			/*
162 162
     	    // Disabled for now, site change source format
163 163
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
164 164
         	//$formats[$id] = 'radarvirtueljson';
@@ -170,121 +170,121 @@  discard block
 block discarded – undo
170 170
         	    exit(0);
171 171
         	}
172 172
     	    */
173
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
174
-        	//$formats[$id] = 'planeupdatefaa';
175
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
176
-        	//$last_exec['planeupdatefaa'] = 0;
177
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
178
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
179
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
180
-        	    exit(0);
181
-        	}
182
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
183
-        	//$formats[$id] = 'phpvmacars';
184
-        	$globalSources[$id]['format'] = 'phpvmacars';
185
-        	//$last_exec['phpvmacars'] = 0;
186
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
187
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
188
-        	//$formats[$id] = 'phpvmacars';
189
-        	$globalSources[$id]['format'] = 'vam';
190
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
191
-            } else if (preg_match('/whazzup/i',$host)) {
192
-        	//$formats[$id] = 'whazzup';
193
-        	$globalSources[$id]['format'] = 'whazzup';
194
-        	//$last_exec['whazzup'] = 0;
195
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
196
-            } else if (preg_match('/blitzortung/i',$host)) {
197
-        	$globalSources[$id]['format'] = 'blitzortung';
198
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
199
-            } else if (preg_match('/airwhere/i',$host)) {
200
-        	$globalSources[$id]['format'] = 'airwhere';
201
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
202
-            } else if (preg_match('/recentpireps/i',$host)) {
203
-        	//$formats[$id] = 'pirepsjson';
204
-        	$globalSources[$id]['format'] = 'pirepsjson';
205
-        	//$last_exec['pirepsjson'] = 0;
206
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
207
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
208
-        	//$formats[$id] = 'fr24json';
209
-        	$globalSources[$id]['format'] = 'fr24json';
210
-        	//$last_exec['fr24json'] = 0;
211
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
212
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
213
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
214
-        	    exit(0);
215
-        	}
216
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
217
-        	//$formats[$id] = 'fr24json';
218
-        	$globalSources[$id]['format'] = 'myshiptracking';
219
-        	//$last_exec['fr24json'] = 0;
220
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
221
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
222
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
223
-        	    exit(0);
224
-        	}
225
-            //} else if (preg_match('/10001/',$host)) {
226
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
227
-        	//$formats[$id] = 'tsv';
228
-        	$globalSources[$id]['format'] = 'tsv';
229
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
230
-            }
231
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
232
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
233
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
234
-    		    if ($idf !== false) {
235
-    			$httpfeeds[$id] = $idf;
236
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
237
-    		    }
238
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
239
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
241
-	    $hostport = explode(':',$host);
242
-	    if (isset($hostport[1])) {
173
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
174
+			//$formats[$id] = 'planeupdatefaa';
175
+			$globalSources[$id]['format'] = 'planeupdatefaa';
176
+			//$last_exec['planeupdatefaa'] = 0;
177
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
178
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
179
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
180
+				exit(0);
181
+			}
182
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
183
+			//$formats[$id] = 'phpvmacars';
184
+			$globalSources[$id]['format'] = 'phpvmacars';
185
+			//$last_exec['phpvmacars'] = 0;
186
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
187
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
188
+			//$formats[$id] = 'phpvmacars';
189
+			$globalSources[$id]['format'] = 'vam';
190
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
191
+			} else if (preg_match('/whazzup/i',$host)) {
192
+			//$formats[$id] = 'whazzup';
193
+			$globalSources[$id]['format'] = 'whazzup';
194
+			//$last_exec['whazzup'] = 0;
195
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
196
+			} else if (preg_match('/blitzortung/i',$host)) {
197
+			$globalSources[$id]['format'] = 'blitzortung';
198
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
199
+			} else if (preg_match('/airwhere/i',$host)) {
200
+			$globalSources[$id]['format'] = 'airwhere';
201
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
202
+			} else if (preg_match('/recentpireps/i',$host)) {
203
+			//$formats[$id] = 'pirepsjson';
204
+			$globalSources[$id]['format'] = 'pirepsjson';
205
+			//$last_exec['pirepsjson'] = 0;
206
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
207
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
208
+			//$formats[$id] = 'fr24json';
209
+			$globalSources[$id]['format'] = 'fr24json';
210
+			//$last_exec['fr24json'] = 0;
211
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
212
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
213
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
214
+				exit(0);
215
+			}
216
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
217
+			//$formats[$id] = 'fr24json';
218
+			$globalSources[$id]['format'] = 'myshiptracking';
219
+			//$last_exec['fr24json'] = 0;
220
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
221
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
222
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
223
+				exit(0);
224
+			}
225
+			//} else if (preg_match('/10001/',$host)) {
226
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
227
+			//$formats[$id] = 'tsv';
228
+			$globalSources[$id]['format'] = 'tsv';
229
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
230
+			}
231
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
232
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
233
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
234
+				if ($idf !== false) {
235
+				$httpfeeds[$id] = $idf;
236
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
237
+				}
238
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
239
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
241
+		$hostport = explode(':',$host);
242
+		if (isset($hostport[1])) {
243 243
 		$port = $hostport[1];
244 244
 		$hostn = $hostport[0];
245
-	    } else {
245
+		} else {
246 246
 		$port = $globalSources[$id]['port'];
247 247
 		$hostn = $globalSources[$id]['host'];
248
-	    }
249
-	    $Common = new Common();
250
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
251
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
252
-    	    } else {
253
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
254
-	    }
255
-	    if ($s) {
256
-    	        $sockets[$id] = $s;
257
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
258
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
248
+		}
249
+		$Common = new Common();
250
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
251
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
252
+			} else {
253
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
254
+		}
255
+		if ($s) {
256
+				$sockets[$id] = $s;
257
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
258
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
259 259
 			//$formats[$id] = 'aprs';
260 260
 			$globalSources[$id]['format'] = 'aprs';
261 261
 			//$aprs_connect = 0;
262 262
 			//$use_aprs = true;
263
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
263
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
264 264
 			$globalSources[$id]['format'] = 'vrstcp';
265
-    		    } elseif ($port == '10001') {
266
-        		//$formats[$id] = 'tsv';
267
-        		$globalSources[$id]['format'] = 'tsv';
268
-		    } elseif ($port == '30002') {
269
-        		//$formats[$id] = 'raw';
270
-        		$globalSources[$id]['format'] = 'raw';
271
-		    } elseif ($port == '5001') {
272
-        		//$formats[$id] = 'raw';
273
-        		$globalSources[$id]['format'] = 'flightgearmp';
274
-		    } elseif ($port == '30005') {
265
+				} elseif ($port == '10001') {
266
+				//$formats[$id] = 'tsv';
267
+				$globalSources[$id]['format'] = 'tsv';
268
+			} elseif ($port == '30002') {
269
+				//$formats[$id] = 'raw';
270
+				$globalSources[$id]['format'] = 'raw';
271
+			} elseif ($port == '5001') {
272
+				//$formats[$id] = 'raw';
273
+				$globalSources[$id]['format'] = 'flightgearmp';
274
+			} elseif ($port == '30005') {
275 275
 			// Not yet supported
276
-        		//$formats[$id] = 'beast';
277
-        		$globalSources[$id]['format'] = 'beast';
278
-		    //} else $formats[$id] = 'sbs';
279
-		    } else $globalSources[$id]['format'] = 'sbs';
280
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
276
+				//$formats[$id] = 'beast';
277
+				$globalSources[$id]['format'] = 'beast';
278
+			//} else $formats[$id] = 'sbs';
279
+			} else $globalSources[$id]['format'] = 'sbs';
280
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
281 281
 		}
282 282
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
283
-            } else {
283
+			} else {
284 284
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
285
-    	    }
286
-        }
287
-    }
285
+			}
286
+		}
287
+	}
288 288
 }
289 289
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
290 290
 
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
 //connect_all($globalSources);
308 308
 
309 309
 if (isset($globalProxy) && $globalProxy) {
310
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
310
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
311 311
 } else {
312
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
312
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
313 313
 }
314 314
 
315 315
 // APRS Configuration
@@ -318,21 +318,21 @@  discard block
 block discarded – undo
318 318
 	die;
319 319
 }
320 320
 foreach ($globalSources as $key => $source) {
321
-    if (!isset($source['format'])) {
322
-        $globalSources[$key]['format'] = 'auto';
323
-    }
324
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
325
-        unset($globalSources[$key]);
326
-    }
321
+	if (!isset($source['format'])) {
322
+		$globalSources[$key]['format'] = 'auto';
323
+	}
324
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
325
+		unset($globalSources[$key]);
326
+	}
327 327
 }
328 328
 connect_all($globalSources);
329 329
 foreach ($globalSources as $key => $source) {
330
-    if (isset($source['format']) && $source['format'] == 'aprs') {
330
+	if (isset($source['format']) && $source['format'] == 'aprs') {
331 331
 	$aprs_connect = 0;
332 332
 	$use_aprs = true;
333 333
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
334 334
 	break;
335
-    }
335
+	}
336 336
 }
337 337
 
338 338
 if ($use_aprs) {
@@ -373,126 +373,126 @@  discard block
 block discarded – undo
373 373
 
374 374
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
375 375
 while ($i > 0) {
376
-    if (!$globalDaemon) $i = $endtime-time();
377
-    // Delete old ATC
378
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
376
+	if (!$globalDaemon) $i = $endtime-time();
377
+	// Delete old ATC
378
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
379 379
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
380
-        $ATC->deleteOldATC();
381
-    }
380
+		$ATC->deleteOldATC();
381
+	}
382 382
     
383
-    if (count($last_exec) == count($globalSources)) {
383
+	if (count($last_exec) == count($globalSources)) {
384 384
 	$max = $globalMinFetch;
385 385
 	foreach ($last_exec as $last) {
386
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
386
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
387 387
 	}
388 388
 	if ($max != $globalMinFetch) {
389
-	    if ($globalDebug) echo 'Sleeping...'."\n";
390
-	    sleep($globalMinFetch-$max+2);
389
+		if ($globalDebug) echo 'Sleeping...'."\n";
390
+		sleep($globalMinFetch-$max+2);
391
+	}
391 392
 	}
392
-    }
393 393
 
394 394
     
395
-    //foreach ($formats as $id => $value) {
396
-    foreach ($globalSources as $id => $value) {
395
+	//foreach ($formats as $id => $value) {
396
+	foreach ($globalSources as $id => $value) {
397 397
 	date_default_timezone_set('UTC');
398 398
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
399 399
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
400 400
 	if ($value['format'] == 'deltadbtxt' && 
401
-	    (
401
+		(
402 402
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
403 403
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
404
-	    )
404
+		)
405 405
 	) {
406
-	    //$buffer = $Common->getData($hosts[$id]);
407
-	    $buffer = $Common->getData($value['host']);
408
-	    if ($buffer != '') $reset = 0;
409
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
410
-	    $buffer = explode('\n',$buffer);
411
-	    foreach ($buffer as $line) {
412
-    		if ($line != '' && count($line) > 7) {
413
-    		    $line = explode(',', $line);
414
-	            $data = array();
415
-	            $data['hex'] = $line[1]; // hex
416
-	            $data['ident'] = $line[2]; // ident
417
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
418
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
419
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
420
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
421
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
422
-	            $data['verticalrate'] = ''; // vertical rate
423
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
424
-	            $data['emergency'] = ''; // emergency
425
-		    $data['datetime'] = date('Y-m-d H:i:s');
426
-		    $data['format_source'] = 'deltadbtxt';
427
-    		    $data['id_source'] = $id_source;
428
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
429
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
430
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
431
-    		    $SI->add($data);
432
-		    unset($data);
433
-    		}
434
-    	    }
435
-    	    $last_exec[$id]['last'] = time();
406
+		//$buffer = $Common->getData($hosts[$id]);
407
+		$buffer = $Common->getData($value['host']);
408
+		if ($buffer != '') $reset = 0;
409
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
410
+		$buffer = explode('\n',$buffer);
411
+		foreach ($buffer as $line) {
412
+			if ($line != '' && count($line) > 7) {
413
+				$line = explode(',', $line);
414
+				$data = array();
415
+				$data['hex'] = $line[1]; // hex
416
+				$data['ident'] = $line[2]; // ident
417
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
418
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
419
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
420
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
421
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
422
+				$data['verticalrate'] = ''; // vertical rate
423
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
424
+				$data['emergency'] = ''; // emergency
425
+			$data['datetime'] = date('Y-m-d H:i:s');
426
+			$data['format_source'] = 'deltadbtxt';
427
+				$data['id_source'] = $id_source;
428
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
429
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
430
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
431
+				$SI->add($data);
432
+			unset($data);
433
+			}
434
+			}
435
+			$last_exec[$id]['last'] = time();
436 436
 	} elseif ($value['format'] == 'aisnmeatxt' && 
437
-	    (
437
+		(
438 438
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
439 439
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
440
-	    )
440
+		)
441 441
 	) {
442
-	    date_default_timezone_set('CET');
443
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
444
-	    date_default_timezone_set('UTC');
445
-	    if ($buffer != '') $reset = 0;
446
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
447
-	    $buffer = explode('\n',$buffer);
448
-	    foreach ($buffer as $line) {
442
+		date_default_timezone_set('CET');
443
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
444
+		date_default_timezone_set('UTC');
445
+		if ($buffer != '') $reset = 0;
446
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
447
+		$buffer = explode('\n',$buffer);
448
+		foreach ($buffer as $line) {
449 449
 		if ($line != '') {
450
-		    //echo "'".$line."'\n";
451
-		    $add = false;
452
-		    $ais_data = $AIS->parse_line(trim($line));
453
-		    $data = array();
454
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
455
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
456
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
457
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
458
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
459
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
460
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
461
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
462
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
463
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
464
-		    if (isset($ais_data['timestamp'])) {
450
+			//echo "'".$line."'\n";
451
+			$add = false;
452
+			$ais_data = $AIS->parse_line(trim($line));
453
+			$data = array();
454
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
455
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
456
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
457
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
458
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
459
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
460
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
461
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
462
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
463
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
464
+			if (isset($ais_data['timestamp'])) {
465 465
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
466 466
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
467
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
468
-			    $add = true;
467
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
468
+				$add = true;
469 469
 			}
470
-		    } else {
470
+			} else {
471 471
 			$data['datetime'] = date('Y-m-d H:i:s');
472 472
 			$add = true;
473
-		    }
474
-		    $data['format_source'] = 'aisnmeatxt';
475
-    		    $data['id_source'] = $id_source;
476
-		    //print_r($data);
477
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
479
-		    unset($data);
473
+			}
474
+			$data['format_source'] = 'aisnmeatxt';
475
+				$data['id_source'] = $id_source;
476
+			//print_r($data);
477
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
479
+			unset($data);
480 480
 		}
481
-    	    }
482
-    	    $last_exec[$id]['last'] = time();
481
+			}
482
+			$last_exec[$id]['last'] = time();
483 483
 	} elseif ($value['format'] == 'aisnmeahttp') {
484
-	    $arr = $httpfeeds;
485
-	    $w = $e = null;
484
+		$arr = $httpfeeds;
485
+		$w = $e = null;
486 486
 	    
487
-	    if (isset($arr[$id])) {
487
+		if (isset($arr[$id])) {
488 488
 		$nn = stream_select($arr,$w,$e,$timeout);
489 489
 		if ($nn > 0) {
490
-		    foreach ($httpfeeds as $feed) {
490
+			foreach ($httpfeeds as $feed) {
491 491
 			$buffer = stream_get_line($feed,2000,"\n");
492 492
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
493 493
 			$buffer = explode('\n',$buffer);
494 494
 			foreach ($buffer as $line) {
495
-			    if ($line != '') {
495
+				if ($line != '') {
496 496
 				$ais_data = $AIS->parse_line(trim($line));
497 497
 				$data = array();
498 498
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -510,111 +510,111 @@  discard block
 block discarded – undo
510 510
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
511 511
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
512 512
 				if (isset($ais_data['timestamp'])) {
513
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
513
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
514 514
 				} else {
515
-				    $data['datetime'] = date('Y-m-d H:i:s');
515
+					$data['datetime'] = date('Y-m-d H:i:s');
516 516
 				}
517 517
 				$data['format_source'] = 'aisnmeahttp';
518 518
 				$data['id_source'] = $id_source;
519 519
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520 520
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
521 521
 				unset($data);
522
-			    }
522
+				}
523
+			}
523 524
 			}
524
-		    }
525 525
 		} else {
526
-		    $format = $value['format'];
527
-		    if (isset($tt[$format])) $tt[$format]++;
528
-		    else $tt[$format] = 0;
529
-		    if ($tt[$format] > 30) {
526
+			$format = $value['format'];
527
+			if (isset($tt[$format])) $tt[$format]++;
528
+			else $tt[$format] = 0;
529
+			if ($tt[$format] > 30) {
530 530
 			if ($globalDebug) echo 'Reconnect...'."\n";
531 531
 			sleep(2);
532 532
 			$sourceeen[] = $value;
533 533
 			connect_all($sourceeen);
534 534
 			$sourceeen = array();
535
-		    }
535
+			}
536
+		}
536 537
 		}
537
-	    }
538 538
 	} elseif ($value['format'] == 'myshiptracking' && 
539
-	    (
539
+		(
540 540
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
541 541
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
542
-	    )
542
+		)
543 543
 	) {
544
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
545
-	    if ($buffer != '') {
544
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
545
+		if ($buffer != '') {
546 546
 		//echo $buffer;
547 547
 		$all_data = json_decode($buffer,true);
548 548
 		//print_r($all_data);
549 549
 		if (isset($all_data[0]['DATA'])) {
550
-		    foreach ($all_data[0]['DATA'] as $line) {
550
+			foreach ($all_data[0]['DATA'] as $line) {
551 551
 			if ($line != '') {
552
-			    $data = array();
553
-			    $data['ident'] = $line['NAME'];
554
-			    $data['mmsi'] = $line['MMSI'];
555
-			    $data['speed'] = $line['SOG'];
556
-			    $data['heading'] = $line['COG'];
557
-			    $data['latitude'] = $line['LAT'];
558
-			    $data['longitude'] = $line['LNG'];
559
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
560
-			    $data['imo'] = $line['IMO'];
561
-			    //$data['arrival_code'] = $ais_data['destination'];
562
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
563
-			    $data['format_source'] = 'myshiptracking';
564
-			    $data['id_source'] = $id_source;
565
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
566
-			    $MI->add($data);
567
-			    unset($data);
552
+				$data = array();
553
+				$data['ident'] = $line['NAME'];
554
+				$data['mmsi'] = $line['MMSI'];
555
+				$data['speed'] = $line['SOG'];
556
+				$data['heading'] = $line['COG'];
557
+				$data['latitude'] = $line['LAT'];
558
+				$data['longitude'] = $line['LNG'];
559
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
560
+				$data['imo'] = $line['IMO'];
561
+				//$data['arrival_code'] = $ais_data['destination'];
562
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
563
+				$data['format_source'] = 'myshiptracking';
564
+				$data['id_source'] = $id_source;
565
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
566
+				$MI->add($data);
567
+				unset($data);
568
+			}
568 569
 			}
569
-		    }
570 570
 		}
571
-	    }
572
-	    $last_exec[$id]['last'] = time();
571
+		}
572
+		$last_exec[$id]['last'] = time();
573 573
 	} elseif ($value['format'] == 'boatbeaconapp' && 
574
-	    (
574
+		(
575 575
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
576 576
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
577
-	    )
577
+		)
578 578
 	) {
579
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
580
-	    if ($buffer != '') {
579
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
580
+		if ($buffer != '') {
581 581
 		$all_data = json_decode($buffer,true);
582 582
 		if (isset($all_data[0]['mmsi'])) {
583
-		    foreach ($all_data as $line) {
583
+			foreach ($all_data as $line) {
584 584
 			if ($line != '') {
585
-			    $data = array();
586
-			    $data['ident'] = $line['shipname'];
587
-			    $data['callsign'] = $line['callsign'];
588
-			    $data['mmsi'] = $line['mmsi'];
589
-			    $data['speed'] = $line['sog'];
590
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
591
-			    $data['latitude'] = $line['latitude'];
592
-			    $data['longitude'] = $line['longitude'];
593
-			    $data['type_id'] = $line['shiptype'];
594
-			    $data['arrival_code'] = $line['destination'];
595
-			    $data['datetime'] = $line['time'];
596
-			    $data['format_source'] = 'boatbeaconapp';
597
-			    $data['id_source'] = $id_source;
598
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
599
-			    $MI->add($data);
600
-			    unset($data);
585
+				$data = array();
586
+				$data['ident'] = $line['shipname'];
587
+				$data['callsign'] = $line['callsign'];
588
+				$data['mmsi'] = $line['mmsi'];
589
+				$data['speed'] = $line['sog'];
590
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
591
+				$data['latitude'] = $line['latitude'];
592
+				$data['longitude'] = $line['longitude'];
593
+				$data['type_id'] = $line['shiptype'];
594
+				$data['arrival_code'] = $line['destination'];
595
+				$data['datetime'] = $line['time'];
596
+				$data['format_source'] = 'boatbeaconapp';
597
+				$data['id_source'] = $id_source;
598
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
599
+				$MI->add($data);
600
+				unset($data);
601
+			}
601 602
 			}
602
-		    }
603 603
 		}
604 604
 		
605
-	    }
606
-    	    $last_exec[$id]['last'] = time();
605
+		}
606
+			$last_exec[$id]['last'] = time();
607 607
 	} elseif ($value['format'] == 'boatnerd' && 
608
-	    (
608
+		(
609 609
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
610 610
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
611
-	    )
611
+		)
612 612
 	) {
613
-	    $buffer = $Common->getData($value['host']);
614
-	    if ($buffer != '') {
613
+		$buffer = $Common->getData($value['host']);
614
+		if ($buffer != '') {
615 615
 		$all_data = json_decode($buffer,true);
616 616
 		if (isset($all_data['features'][0]['id'])) {
617
-		    foreach ($all_data['features'] as $line) {
617
+			foreach ($all_data['features'] as $line) {
618 618
 			$data = array();
619 619
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
620 620
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -633,78 +633,78 @@  discard block
 block discarded – undo
633 633
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
634 634
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
635 635
 			unset($data);
636
-		    }
636
+			}
637 637
 		}
638 638
 		
639
-	    }
640
-    	    $last_exec[$id]['last'] = time();
639
+		}
640
+			$last_exec[$id]['last'] = time();
641 641
 	} elseif ($value['format'] == 'shipplotter' && 
642
-	    (
642
+		(
643 643
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
644 644
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
645
-	    )
645
+		)
646 646
 	) {
647
-	    echo 'download...';
648
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
649
-	    echo 'done !'."\n";
650
-	    if ($buffer != '') $reset = 0;
651
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
652
-	    $buffer = explode('\n',$buffer);
653
-	    foreach ($buffer as $line) {
647
+		echo 'download...';
648
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
649
+		echo 'done !'."\n";
650
+		if ($buffer != '') $reset = 0;
651
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
652
+		$buffer = explode('\n',$buffer);
653
+		foreach ($buffer as $line) {
654 654
 		if ($line != '') {
655
-		    $data = array();
656
-		    $data['mmsi'] = (int)substr($line,0,9);
657
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
658
-		    //$data['status'] = substr($line,21,2);
659
-		    //$data['type'] = substr($line,24,3);
660
-		    $data['latitude'] = substr($line,29,9);
661
-		    $data['longitude'] = substr($line,41,9);
662
-		    $data['speed'] = round(substr($line,51,5));
663
-		    //$data['course'] = substr($line,57,5);
664
-		    $data['heading'] = round(substr($line,63,3));
665
-		    //$data['draft'] = substr($line,67,4);
666
-		    //$data['length'] = substr($line,72,3);
667
-		    //$data['beam'] = substr($line,76,2);
668
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
669
-		    //$data['callsign'] = trim(substr($line,100,7);
670
-		    //$data['dest'] = substr($line,108,20);
671
-		    //$data['etaDate'] = substr($line,129,5);
672
-		    //$data['etaTime'] = substr($line,135,5);
673
-		    $data['format_source'] = 'shipplotter';
674
-    		    $data['id_source'] = $id_source;
675
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
676
-		    //print_r($data);
677
-		    echo 'Add...'."\n";
678
-		    $MI->add($data);
679
-		    unset($data);
655
+			$data = array();
656
+			$data['mmsi'] = (int)substr($line,0,9);
657
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
658
+			//$data['status'] = substr($line,21,2);
659
+			//$data['type'] = substr($line,24,3);
660
+			$data['latitude'] = substr($line,29,9);
661
+			$data['longitude'] = substr($line,41,9);
662
+			$data['speed'] = round(substr($line,51,5));
663
+			//$data['course'] = substr($line,57,5);
664
+			$data['heading'] = round(substr($line,63,3));
665
+			//$data['draft'] = substr($line,67,4);
666
+			//$data['length'] = substr($line,72,3);
667
+			//$data['beam'] = substr($line,76,2);
668
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
669
+			//$data['callsign'] = trim(substr($line,100,7);
670
+			//$data['dest'] = substr($line,108,20);
671
+			//$data['etaDate'] = substr($line,129,5);
672
+			//$data['etaTime'] = substr($line,135,5);
673
+			$data['format_source'] = 'shipplotter';
674
+				$data['id_source'] = $id_source;
675
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
676
+			//print_r($data);
677
+			echo 'Add...'."\n";
678
+			$MI->add($data);
679
+			unset($data);
680 680
 		}
681
-    	    }
682
-    	    $last_exec[$id]['last'] = time();
681
+			}
682
+			$last_exec[$id]['last'] = time();
683 683
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
684 684
 	} elseif (
685
-	    (
685
+		(
686 686
 		$value['format'] == 'whazzup' && 
687 687
 		(
688
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
689
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
688
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
689
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
690 690
 		)
691
-	    ) || (
691
+		) || (
692 692
 		$value['format'] == 'vatsimtxt' && 
693 693
 		(
694
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
695
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
694
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
695
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
696
+		)
696 697
 		)
697
-	    )
698 698
 	) {
699
-	    //$buffer = $Common->getData($hosts[$id]);
700
-	    $buffer = $Common->getData($value['host']);
701
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
702
-	    $buffer = explode('\n',$buffer);
703
-	    $reset = 0;
704
-	    foreach ($buffer as $line) {
705
-    		if ($line != '') {
706
-    		    $line = explode(':', $line);
707
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
699
+		//$buffer = $Common->getData($hosts[$id]);
700
+		$buffer = $Common->getData($value['host']);
701
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
702
+		$buffer = explode('\n',$buffer);
703
+		$reset = 0;
704
+		foreach ($buffer as $line) {
705
+			if ($line != '') {
706
+				$line = explode(':', $line);
707
+				if (count($line) > 30 && $line[0] != 'callsign') {
708 708
 			$data = array();
709 709
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
710 710
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -717,37 +717,37 @@  discard block
 block discarded – undo
717 717
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
718 718
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
719 719
 			$data['latitude'] = $line[5]; // lat
720
-	        	$data['longitude'] = $line[6]; // long
721
-	        	$data['verticalrate'] = ''; // vertical rate
722
-	        	$data['squawk'] = ''; // squawk
723
-	        	$data['emergency'] = ''; // emergency
724
-	        	$data['waypoints'] = $line[30];
720
+				$data['longitude'] = $line[6]; // long
721
+				$data['verticalrate'] = ''; // vertical rate
722
+				$data['squawk'] = ''; // squawk
723
+				$data['emergency'] = ''; // emergency
724
+				$data['waypoints'] = $line[30];
725 725
 			$data['datetime'] = date('Y-m-d H:i:s');
726 726
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
727 727
 			//if (isset($line[37])) $data['last_update'] = $line[37];
728
-		        $data['departure_airport_icao'] = $line[11];
729
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
730
-		        $data['arrival_airport_icao'] = $line[13];
728
+				$data['departure_airport_icao'] = $line[11];
729
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
730
+				$data['arrival_airport_icao'] = $line[13];
731 731
 			$data['frequency'] = $line[4];
732 732
 			$data['type'] = $line[18];
733 733
 			$data['range'] = $line[19];
734 734
 			if (isset($line[35])) $data['info'] = $line[35];
735
-    			$data['id_source'] = $id_source;
736
-	    		//$data['arrival_airport_time'] = ;
737
-	    		if ($line[9] != '') {
738
-	    		    $aircraft_data = explode('/',$line[9]);
739
-	    		    if (isset($aircraft_data[1])) {
740
-	    			$data['aircraft_icao'] = $aircraft_data[1];
741
-	    		    }
742
-        		}
743
-	    		/*
735
+				$data['id_source'] = $id_source;
736
+				//$data['arrival_airport_time'] = ;
737
+				if ($line[9] != '') {
738
+					$aircraft_data = explode('/',$line[9]);
739
+					if (isset($aircraft_data[1])) {
740
+					$data['aircraft_icao'] = $aircraft_data[1];
741
+					}
742
+				}
743
+				/*
744 744
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
745 745
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
746 746
 	    		*/
747
-	    		$data['format_source'] = $value['format'];
747
+				$data['format_source'] = $value['format'];
748 748
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
749 749
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
750
-    			if ($line[3] == 'PILOT') $SI->add($data);
750
+				if ($line[3] == 'PILOT') $SI->add($data);
751 751
 			elseif ($line[3] == 'ATC') {
752 752
 				//print_r($data);
753 753
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -768,21 +768,21 @@  discard block
 block discarded – undo
768 768
 					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']);
769 769
 				}
770 770
 			}
771
-    			unset($data);
772
-    		    }
773
-    		}
774
-    	    }
775
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
776
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
777
-    	    $last_exec[$id]['last'] = time();
778
-    	} elseif ($value['format'] == 'airwhere' && 
779
-    	    (
780
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
781
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
782
-    	    )
783
-    	) {
784
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
785
-	    if ($buffer != '') {
771
+				unset($data);
772
+				}
773
+			}
774
+			}
775
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
776
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
777
+			$last_exec[$id]['last'] = time();
778
+		} elseif ($value['format'] == 'airwhere' && 
779
+			(
780
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
781
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
782
+			)
783
+		) {
784
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
785
+		if ($buffer != '') {
786 786
 		$all_data = simplexml_load_string($buffer);
787 787
 		foreach($all_data->children() as $childdata) {
788 788
 			$data = array();
@@ -804,10 +804,10 @@  discard block
 block discarded – undo
804 804
 			$SI->add($data);
805 805
 			unset($data);
806 806
 		}
807
-	    }
808
-	    $Source->deleteOldLocationByType('gs');
809
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
810
-	    if ($buffer != '') {
807
+		}
808
+		$Source->deleteOldLocationByType('gs');
809
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
810
+		if ($buffer != '') {
811 811
 		$all_data = simplexml_load_string($buffer);
812 812
 		foreach($all_data->children() as $childdata) {
813 813
 			$data = array();
@@ -825,8 +825,8 @@  discard block
 block discarded – undo
825 825
 			}
826 826
 			unset($data);
827 827
 		}
828
-	    }
829
-	    $last_exec[$id]['last'] = time();
828
+		}
829
+		$last_exec[$id]['last'] = time();
830 830
 	/*
831 831
 	} if ($value['format'] == 'aircraftlistjson') {
832 832
 	    print_r($globalSources);
@@ -834,17 +834,17 @@  discard block
 block discarded – undo
834 834
 	    echo $globalMinFetch;
835 835
 	*/
836 836
 	} elseif ($value['format'] == 'aircraftlistjson' && 
837
-	    (
837
+		(
838 838
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
839 839
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
840
-	    )
840
+		)
841 841
 	) {
842
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
843
-	    if ($buffer != '') {
844
-	        $all_data = json_decode($buffer,true);
842
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
843
+		if ($buffer != '') {
844
+			$all_data = json_decode($buffer,true);
845 845
 		if (isset($all_data['acList'])) {
846
-		    $reset = 0;
847
-		    foreach ($all_data['acList'] as $line) {
846
+			$reset = 0;
847
+			foreach ($all_data['acList'] as $line) {
848 848
 			$data = array();
849 849
 			$data['hex'] = $line['Icao']; // hex
850 850
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -867,10 +867,10 @@  discard block
 block discarded – undo
867 867
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
868 868
 			if (isset($data['latitude'])) $SI->add($data);
869 869
 			unset($data);
870
-		    }
870
+			}
871 871
 		} elseif (is_array($all_data)) {
872
-		    $reset = 0;
873
-		    foreach ($all_data as $line) {
872
+			$reset = 0;
873
+			foreach ($all_data as $line) {
874 874
 			$data = array();
875 875
 			$data['hex'] = $line['hex']; // hex
876 876
 			$data['ident'] = $line['flight']; // ident
@@ -890,218 +890,218 @@  discard block
 block discarded – undo
890 890
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
891 891
 			$SI->add($data);
892 892
 			unset($data);
893
-		    }
893
+			}
894 894
 		}
895
-	    } elseif ($globalDebug) echo 'No data'."\n";
896
-    	    //$last_exec['aircraftlistjson'] = time();
897
-    	    $last_exec[$id]['last'] = time();
898
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
899
-    	} elseif ($value['format'] == 'planeupdatefaa' && 
900
-    	    (
901
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
902
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
903
-    	    )
904
-    	) {
905
-	    $buffer = $Common->getData($value['host']);
906
-	    $all_data = json_decode($buffer,true);
907
-	    if (isset($all_data['planes'])) {
895
+		} elseif ($globalDebug) echo 'No data'."\n";
896
+			//$last_exec['aircraftlistjson'] = time();
897
+			$last_exec[$id]['last'] = time();
898
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
899
+		} elseif ($value['format'] == 'planeupdatefaa' && 
900
+			(
901
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
902
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
903
+			)
904
+		) {
905
+		$buffer = $Common->getData($value['host']);
906
+		$all_data = json_decode($buffer,true);
907
+		if (isset($all_data['planes'])) {
908 908
 		$reset = 0;
909 909
 		foreach ($all_data['planes'] as $key => $line) {
910
-		    $data = array();
911
-		    $data['hex'] = $key; // hex
912
-		    $data['ident'] = $line[3]; // ident
913
-		    $data['altitude'] = $line[6]; // altitude
914
-		    $data['speed'] = $line[8]; // speed
915
-		    $data['heading'] = $line[7]; // heading
916
-		    $data['latitude'] = $line[4]; // lat
917
-		    $data['longitude'] = $line[5]; // long
918
-		    //$data['verticalrate'] = $line[]; // verticale rate
919
-		    $data['squawk'] = $line[10]; // squawk
920
-		    $data['emergency'] = ''; // emergency
921
-		    $data['registration'] = $line[2];
922
-		    $data['aircraft_icao'] = $line[0];
923
-		    $deparr = explode('-',$line[1]);
924
-		    if (count($deparr) == 2) {
910
+			$data = array();
911
+			$data['hex'] = $key; // hex
912
+			$data['ident'] = $line[3]; // ident
913
+			$data['altitude'] = $line[6]; // altitude
914
+			$data['speed'] = $line[8]; // speed
915
+			$data['heading'] = $line[7]; // heading
916
+			$data['latitude'] = $line[4]; // lat
917
+			$data['longitude'] = $line[5]; // long
918
+			//$data['verticalrate'] = $line[]; // verticale rate
919
+			$data['squawk'] = $line[10]; // squawk
920
+			$data['emergency'] = ''; // emergency
921
+			$data['registration'] = $line[2];
922
+			$data['aircraft_icao'] = $line[0];
923
+			$deparr = explode('-',$line[1]);
924
+			if (count($deparr) == 2) {
925 925
 			$data['departure_airport_icao'] = $deparr[0];
926 926
 			$data['arrival_airport_icao'] = $deparr[1];
927
-		    }
928
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
929
-	    	    $data['format_source'] = 'planeupdatefaa';
930
-    		    $data['id_source'] = $id_source;
931
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
932
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
933
-		    $SI->add($data);
934
-		    unset($data);
927
+			}
928
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
929
+				$data['format_source'] = 'planeupdatefaa';
930
+				$data['id_source'] = $id_source;
931
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
932
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
933
+			$SI->add($data);
934
+			unset($data);
935
+		}
935 936
 		}
936
-	    }
937
-	    //$last_exec['planeupdatefaa'] = time();
938
-	    $last_exec[$id]['last'] = time();
937
+		//$last_exec['planeupdatefaa'] = time();
938
+		$last_exec[$id]['last'] = time();
939 939
 	} elseif ($value['format'] == 'opensky' && 
940
-	    (
940
+		(
941 941
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
942 942
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
943
-	    )
943
+		)
944 944
 	) {
945
-	    $buffer = $Common->getData($value['host']);
946
-	    $all_data = json_decode($buffer,true);
947
-	    if (isset($all_data['states'])) {
945
+		$buffer = $Common->getData($value['host']);
946
+		$all_data = json_decode($buffer,true);
947
+		if (isset($all_data['states'])) {
948 948
 		$reset = 0;
949 949
 		foreach ($all_data['states'] as $key => $line) {
950
-		    $data = array();
951
-		    $data['hex'] = $line[0]; // hex
952
-		    $data['ident'] = trim($line[1]); // ident
953
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
954
-		    $data['speed'] = round($line[9]*1.94384); // speed
955
-		    $data['heading'] = round($line[10]); // heading
956
-		    $data['latitude'] = $line[6]; // lat
957
-		    $data['longitude'] = $line[5]; // long
958
-		    $data['verticalrate'] = $line[11]; // verticale rate
959
-		    //$data['squawk'] = $line[10]; // squawk
960
-		    //$data['emergency'] = ''; // emergency
961
-		    //$data['registration'] = $line[2];
962
-		    //$data['aircraft_icao'] = $line[0];
963
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
964
-		    $data['format_source'] = 'opensky';
965
-		    $data['id_source'] = $id_source;
966
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
967
-		    $SI->add($data);
968
-		    unset($data);
950
+			$data = array();
951
+			$data['hex'] = $line[0]; // hex
952
+			$data['ident'] = trim($line[1]); // ident
953
+			$data['altitude'] = round($line[7]*3.28084); // altitude
954
+			$data['speed'] = round($line[9]*1.94384); // speed
955
+			$data['heading'] = round($line[10]); // heading
956
+			$data['latitude'] = $line[6]; // lat
957
+			$data['longitude'] = $line[5]; // long
958
+			$data['verticalrate'] = $line[11]; // verticale rate
959
+			//$data['squawk'] = $line[10]; // squawk
960
+			//$data['emergency'] = ''; // emergency
961
+			//$data['registration'] = $line[2];
962
+			//$data['aircraft_icao'] = $line[0];
963
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
964
+			$data['format_source'] = 'opensky';
965
+			$data['id_source'] = $id_source;
966
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
967
+			$SI->add($data);
968
+			unset($data);
969 969
 		}
970
-	    }
971
-	    //$last_exec['planeupdatefaa'] = time();
972
-	    $last_exec[$id]['last'] = time();
970
+		}
971
+		//$last_exec['planeupdatefaa'] = time();
972
+		$last_exec[$id]['last'] = time();
973 973
 	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
974 974
 	} elseif ($value['format'] == 'fr24json' && 
975
-	    (
975
+		(
976 976
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
977 977
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
978
-	    )
978
+		)
979 979
 	) {
980
-	    //$buffer = $Common->getData($hosts[$id]);
981
-	    $buffer = $Common->getData($value['host']);
982
-	    $all_data = json_decode($buffer,true);
983
-	    if (!empty($all_data)) $reset = 0;
984
-	    foreach ($all_data as $key => $line) {
980
+		//$buffer = $Common->getData($hosts[$id]);
981
+		$buffer = $Common->getData($value['host']);
982
+		$all_data = json_decode($buffer,true);
983
+		if (!empty($all_data)) $reset = 0;
984
+		foreach ($all_data as $key => $line) {
985 985
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
986
-		    $data = array();
987
-		    $data['hex'] = $line[0];
988
-		    $data['ident'] = $line[16]; //$line[13]
989
-	    	    $data['altitude'] = $line[4]; // altitude
990
-	    	    $data['speed'] = $line[5]; // speed
991
-	    	    $data['heading'] = $line[3]; // heading
992
-	    	    $data['latitude'] = $line[1]; // lat
993
-	    	    $data['longitude'] = $line[2]; // long
994
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
995
-	    	    $data['squawk'] = $line[6]; // squawk
996
-	    	    $data['aircraft_icao'] = $line[8];
997
-	    	    $data['registration'] = $line[9];
998
-		    $data['departure_airport_iata'] = $line[11];
999
-		    $data['arrival_airport_iata'] = $line[12];
1000
-	    	    $data['emergency'] = ''; // emergency
1001
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1002
-	    	    $data['format_source'] = 'fr24json';
1003
-    		    $data['id_source'] = $id_source;
1004
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1005
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1006
-		    $SI->add($data);
1007
-		    unset($data);
986
+			$data = array();
987
+			$data['hex'] = $line[0];
988
+			$data['ident'] = $line[16]; //$line[13]
989
+				$data['altitude'] = $line[4]; // altitude
990
+				$data['speed'] = $line[5]; // speed
991
+				$data['heading'] = $line[3]; // heading
992
+				$data['latitude'] = $line[1]; // lat
993
+				$data['longitude'] = $line[2]; // long
994
+				$data['verticalrate'] = $line[15]; // verticale rate
995
+				$data['squawk'] = $line[6]; // squawk
996
+				$data['aircraft_icao'] = $line[8];
997
+				$data['registration'] = $line[9];
998
+			$data['departure_airport_iata'] = $line[11];
999
+			$data['arrival_airport_iata'] = $line[12];
1000
+				$data['emergency'] = ''; // emergency
1001
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1002
+				$data['format_source'] = 'fr24json';
1003
+				$data['id_source'] = $id_source;
1004
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1005
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1006
+			$SI->add($data);
1007
+			unset($data);
1008 1008
 		}
1009
-	    }
1010
-	    //$last_exec['fr24json'] = time();
1011
-	    $last_exec[$id]['last'] = time();
1009
+		}
1010
+		//$last_exec['fr24json'] = time();
1011
+		$last_exec[$id]['last'] = time();
1012 1012
 	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1013 1013
 	} elseif ($value['format'] == 'radarvirtueljson' && 
1014
-	    (
1014
+		(
1015 1015
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1016 1016
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1017
-	    )
1017
+		)
1018 1018
 	) {
1019
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1020
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1021
-	    //echo $buffer;
1022
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1023
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1024
-	    $all_data = json_decode($buffer,true);
1025
-	    if (json_last_error() != JSON_ERROR_NONE) {
1019
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1020
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1021
+		//echo $buffer;
1022
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1023
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1024
+		$all_data = json_decode($buffer,true);
1025
+		if (json_last_error() != JSON_ERROR_NONE) {
1026 1026
 		die(json_last_error_msg());
1027
-	    }
1028
-	    if (isset($all_data['mrkrs'])) {
1027
+		}
1028
+		if (isset($all_data['mrkrs'])) {
1029 1029
 		$reset = 0;
1030 1030
 		foreach ($all_data['mrkrs'] as $key => $line) {
1031
-		    if (isset($line['inf'])) {
1031
+			if (isset($line['inf'])) {
1032 1032
 			$data = array();
1033 1033
 			$data['hex'] = $line['inf']['ia'];
1034 1034
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1035
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1036
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1037
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1038
-	    		$data['latitude'] = $line['pt'][0]; // lat
1039
-	    		$data['longitude'] = $line['pt'][1]; // long
1040
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1041
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1042
-	    		//$data['aircraft_icao'] = $line[8];
1043
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1035
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1036
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1037
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1038
+				$data['latitude'] = $line['pt'][0]; // lat
1039
+				$data['longitude'] = $line['pt'][1]; // long
1040
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1041
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1042
+				//$data['aircraft_icao'] = $line[8];
1043
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1044 1044
 			//$data['departure_airport_iata'] = $line[11];
1045 1045
 			//$data['arrival_airport_iata'] = $line[12];
1046
-	    		//$data['emergency'] = ''; // emergency
1046
+				//$data['emergency'] = ''; // emergency
1047 1047
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1048
-	    		$data['format_source'] = 'radarvirtueljson';
1049
-    			$data['id_source'] = $id_source;
1048
+				$data['format_source'] = 'radarvirtueljson';
1049
+				$data['id_source'] = $id_source;
1050 1050
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1051 1051
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1052 1052
 			$SI->add($data);
1053 1053
 			unset($data);
1054
-		    }
1054
+			}
1055
+		}
1055 1056
 		}
1056
-	    }
1057
-	    //$last_exec['radarvirtueljson'] = time();
1058
-	    $last_exec[$id]['last'] = time();
1057
+		//$last_exec['radarvirtueljson'] = time();
1058
+		$last_exec[$id]['last'] = time();
1059 1059
 	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1060 1060
 	} elseif ($value['format'] == 'pirepsjson' && 
1061
-	    (
1061
+		(
1062 1062
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1063 1063
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1064
-	    )
1064
+		)
1065 1065
 	) {
1066
-	    //$buffer = $Common->getData($hosts[$id]);
1067
-	    $buffer = $Common->getData($value['host'].'?'.time());
1068
-	    $all_data = json_decode(utf8_encode($buffer),true);
1066
+		//$buffer = $Common->getData($hosts[$id]);
1067
+		$buffer = $Common->getData($value['host'].'?'.time());
1068
+		$all_data = json_decode(utf8_encode($buffer),true);
1069 1069
 	    
1070
-	    if (isset($all_data['pireps'])) {
1070
+		if (isset($all_data['pireps'])) {
1071 1071
 		$reset = 0;
1072
-	        foreach ($all_data['pireps'] as $line) {
1073
-		    $data = array();
1074
-		    $data['id'] = $line['id'];
1075
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1076
-		    $data['ident'] = $line['callsign']; // ident
1077
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1078
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1079
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1080
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1081
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1082
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1083
-		    $data['latitude'] = $line['lat']; // lat
1084
-		    $data['longitude'] = $line['lon']; // long
1085
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1086
-		    //$data['squawk'] = $line['squawk']; // squawk
1087
-		    //$data['emergency'] = ''; // emergency
1088
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1089
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1090
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1091
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1092
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1093
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1094
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1095
-		    else $data['info'] = '';
1096
-		    $data['format_source'] = 'pireps';
1097
-    		    $data['id_source'] = $id_source;
1098
-		    $data['datetime'] = date('Y-m-d H:i:s');
1099
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1100
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1101
-		    if ($line['icon'] == 'plane') {
1072
+			foreach ($all_data['pireps'] as $line) {
1073
+			$data = array();
1074
+			$data['id'] = $line['id'];
1075
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1076
+			$data['ident'] = $line['callsign']; // ident
1077
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1078
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1079
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1080
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1081
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1082
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1083
+			$data['latitude'] = $line['lat']; // lat
1084
+			$data['longitude'] = $line['lon']; // long
1085
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1086
+			//$data['squawk'] = $line['squawk']; // squawk
1087
+			//$data['emergency'] = ''; // emergency
1088
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1089
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1090
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1091
+			//$data['arrival_airport_time'] = $line['arrtime'];
1092
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1093
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1094
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1095
+			else $data['info'] = '';
1096
+			$data['format_source'] = 'pireps';
1097
+				$data['id_source'] = $id_source;
1098
+			$data['datetime'] = date('Y-m-d H:i:s');
1099
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1100
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1101
+			if ($line['icon'] == 'plane') {
1102 1102
 			$SI->add($data);
1103
-		    //    print_r($data);
1104
-    		    } elseif ($line['icon'] == 'ct') {
1103
+			//    print_r($data);
1104
+				} elseif ($line['icon'] == 'ct') {
1105 1105
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1106 1106
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1107 1107
 			$typec = substr($data['ident'],-3);
@@ -1116,148 +1116,148 @@  discard block
 block discarded – undo
1116 1116
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1117 1117
 			else $data['type'] = 'Observer';
1118 1118
 			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']);
1119
-		    }
1120
-		    unset($data);
1119
+			}
1120
+			unset($data);
1121
+		}
1121 1122
 		}
1122
-	    }
1123
-	    //$last_exec['pirepsjson'] = time();
1124
-	    $last_exec[$id]['last'] = time();
1123
+		//$last_exec['pirepsjson'] = time();
1124
+		$last_exec[$id]['last'] = time();
1125 1125
 	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1126 1126
 	} elseif ($value['format'] == 'phpvmacars' && 
1127
-	    (
1127
+		(
1128 1128
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1129 1129
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1130
-	    )
1130
+		)
1131 1131
 	) {
1132
-	    //$buffer = $Common->getData($hosts[$id]);
1133
-	    if ($globalDebug) echo 'Get Data...'."\n";
1134
-	    $buffer = $Common->getData($value['host']);
1135
-	    $all_data = json_decode($buffer,true);
1136
-	    if ($buffer != '' && is_array($all_data)) {
1132
+		//$buffer = $Common->getData($hosts[$id]);
1133
+		if ($globalDebug) echo 'Get Data...'."\n";
1134
+		$buffer = $Common->getData($value['host']);
1135
+		$all_data = json_decode($buffer,true);
1136
+		if ($buffer != '' && is_array($all_data)) {
1137 1137
 		$reset = 0;
1138 1138
 		foreach ($all_data as $line) {
1139
-	    	    $data = array();
1140
-	    	    //$data['id'] = $line['id']; // id not usable
1141
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1142
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1143
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1144
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1145
-	    	    $data['ident'] = $line['flightnum']; // ident
1146
-	    	    $data['altitude'] = $line['alt']; // altitude
1147
-	    	    $data['speed'] = $line['gs']; // speed
1148
-	    	    $data['heading'] = $line['heading']; // heading
1149
-	    	    $data['latitude'] = $line['lat']; // lat
1150
-	    	    $data['longitude'] = $line['lng']; // long
1151
-	    	    $data['verticalrate'] = ''; // verticale rate
1152
-	    	    $data['squawk'] = ''; // squawk
1153
-	    	    $data['emergency'] = ''; // emergency
1154
-	    	    //$data['datetime'] = $line['lastupdate'];
1155
-	    	    //$data['last_update'] = $line['lastupdate'];
1156
-	    	    if (isset($value['timezone'])) {
1157
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1158
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1159
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1160
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1161
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1162
-	    	    $data['departure_airport_time'] = $line['deptime'];
1163
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1164
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1165
-    		    $data['registration'] = $line['aircraft'];
1166
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1167
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1168
-		    if (isset($line['aircraftname'])) {
1139
+				$data = array();
1140
+				//$data['id'] = $line['id']; // id not usable
1141
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1142
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1143
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1144
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1145
+				$data['ident'] = $line['flightnum']; // ident
1146
+				$data['altitude'] = $line['alt']; // altitude
1147
+				$data['speed'] = $line['gs']; // speed
1148
+				$data['heading'] = $line['heading']; // heading
1149
+				$data['latitude'] = $line['lat']; // lat
1150
+				$data['longitude'] = $line['lng']; // long
1151
+				$data['verticalrate'] = ''; // verticale rate
1152
+				$data['squawk'] = ''; // squawk
1153
+				$data['emergency'] = ''; // emergency
1154
+				//$data['datetime'] = $line['lastupdate'];
1155
+				//$data['last_update'] = $line['lastupdate'];
1156
+				if (isset($value['timezone'])) {
1157
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1158
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1159
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1160
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1161
+				$data['departure_airport_icao'] = $line['depicao'];
1162
+				$data['departure_airport_time'] = $line['deptime'];
1163
+				$data['arrival_airport_icao'] = $line['arricao'];
1164
+				$data['arrival_airport_time'] = $line['arrtime'];
1165
+				$data['registration'] = $line['aircraft'];
1166
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1167
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1168
+			if (isset($line['aircraftname'])) {
1169 1169
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1170 1170
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1171
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1172
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1173
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1174
-	    		else {
1175
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1176
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1177
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1178
-	    		}
1179
-	    	    }
1180
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1181
-    		    $data['id_source'] = $id_source;
1182
-	    	    $data['format_source'] = 'phpvmacars';
1183
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1184
-		    $SI->add($data);
1185
-		    unset($data);
1171
+				$aircraft_data = explode('-',$line['aircraftname']);
1172
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1173
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1174
+				else {
1175
+					$aircraft_data = explode(' ',$line['aircraftname']);
1176
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1177
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1178
+				}
1179
+				}
1180
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1181
+				$data['id_source'] = $id_source;
1182
+				$data['format_source'] = 'phpvmacars';
1183
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1184
+			$SI->add($data);
1185
+			unset($data);
1186 1186
 		}
1187 1187
 		if ($globalDebug) echo 'No more data...'."\n";
1188 1188
 		unset($buffer);
1189 1189
 		unset($all_data);
1190
-	    }
1191
-	    //$last_exec['phpvmacars'] = time();
1192
-	    $last_exec[$id]['last'] = time();
1190
+		}
1191
+		//$last_exec['phpvmacars'] = time();
1192
+		$last_exec[$id]['last'] = time();
1193 1193
 	} elseif ($value['format'] == 'vam' && 
1194
-	    (
1194
+		(
1195 1195
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1196 1196
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1197
-	    )
1197
+		)
1198 1198
 	) {
1199
-	    //$buffer = $Common->getData($hosts[$id]);
1200
-	    if ($globalDebug) echo 'Get Data...'."\n";
1201
-	    $buffer = $Common->getData($value['host']);
1202
-	    $all_data = json_decode($buffer,true);
1203
-	    if ($buffer != '' && is_array($all_data)) {
1199
+		//$buffer = $Common->getData($hosts[$id]);
1200
+		if ($globalDebug) echo 'Get Data...'."\n";
1201
+		$buffer = $Common->getData($value['host']);
1202
+		$all_data = json_decode($buffer,true);
1203
+		if ($buffer != '' && is_array($all_data)) {
1204 1204
 		$reset = 0;
1205 1205
 		foreach ($all_data as $line) {
1206
-	    	    $data = array();
1207
-	    	    //$data['id'] = $line['id']; // id not usable
1208
-	    	    $data['id'] = trim($line['flight_id']);
1209
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1210
-	    	    $data['pilot_name'] = $line['pilot_name'];
1211
-	    	    $data['pilot_id'] = $line['pilot_id'];
1212
-	    	    $data['ident'] = trim($line['callsign']); // ident
1213
-	    	    $data['altitude'] = $line['altitude']; // altitude
1214
-	    	    $data['speed'] = $line['gs']; // speed
1215
-	    	    $data['heading'] = $line['heading']; // heading
1216
-	    	    $data['latitude'] = $line['latitude']; // lat
1217
-	    	    $data['longitude'] = $line['longitude']; // long
1218
-	    	    $data['verticalrate'] = ''; // verticale rate
1219
-	    	    $data['squawk'] = ''; // squawk
1220
-	    	    $data['emergency'] = ''; // emergency
1221
-	    	    //$data['datetime'] = $line['lastupdate'];
1222
-	    	    $data['last_update'] = $line['last_update'];
1223
-		    $data['datetime'] = date('Y-m-d H:i:s');
1224
-	    	    $data['departure_airport_icao'] = $line['departure'];
1225
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1226
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1227
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1228
-    		    //$data['registration'] = $line['aircraft'];
1229
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1230
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1231
-    		    $data['id_source'] = $id_source;
1232
-	    	    $data['format_source'] = 'vam';
1233
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1234
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1235
-		    $SI->add($data);
1236
-		    unset($data);
1206
+				$data = array();
1207
+				//$data['id'] = $line['id']; // id not usable
1208
+				$data['id'] = trim($line['flight_id']);
1209
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1210
+				$data['pilot_name'] = $line['pilot_name'];
1211
+				$data['pilot_id'] = $line['pilot_id'];
1212
+				$data['ident'] = trim($line['callsign']); // ident
1213
+				$data['altitude'] = $line['altitude']; // altitude
1214
+				$data['speed'] = $line['gs']; // speed
1215
+				$data['heading'] = $line['heading']; // heading
1216
+				$data['latitude'] = $line['latitude']; // lat
1217
+				$data['longitude'] = $line['longitude']; // long
1218
+				$data['verticalrate'] = ''; // verticale rate
1219
+				$data['squawk'] = ''; // squawk
1220
+				$data['emergency'] = ''; // emergency
1221
+				//$data['datetime'] = $line['lastupdate'];
1222
+				$data['last_update'] = $line['last_update'];
1223
+			$data['datetime'] = date('Y-m-d H:i:s');
1224
+				$data['departure_airport_icao'] = $line['departure'];
1225
+				//$data['departure_airport_time'] = $line['departure_time'];
1226
+				$data['arrival_airport_icao'] = $line['arrival'];
1227
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1228
+				//$data['registration'] = $line['aircraft'];
1229
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1230
+				$data['aircraft_icao'] = $line['plane_type'];
1231
+				$data['id_source'] = $id_source;
1232
+				$data['format_source'] = 'vam';
1233
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1234
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1235
+			$SI->add($data);
1236
+			unset($data);
1237 1237
 		}
1238 1238
 		if ($globalDebug) echo 'No more data...'."\n";
1239 1239
 		unset($buffer);
1240 1240
 		unset($all_data);
1241
-	    }
1242
-	    //$last_exec['phpvmacars'] = time();
1243
-	    $last_exec[$id]['last'] = time();
1241
+		}
1242
+		//$last_exec['phpvmacars'] = time();
1243
+		$last_exec[$id]['last'] = time();
1244 1244
 	} elseif ($value['format'] == 'blitzortung' && 
1245
-	    (
1245
+		(
1246 1246
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1247 1247
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1248
-	    )
1248
+		)
1249 1249
 	) {
1250
-	    //$buffer = $Common->getData($hosts[$id]);
1251
-	    if ($globalDebug) echo 'Get Data...'."\n";
1252
-	    $buffer = $Common->getData($value['host']);
1253
-	    $all_data = json_decode($buffer,true);
1254
-	    if ($buffer != '') {
1250
+		//$buffer = $Common->getData($hosts[$id]);
1251
+		if ($globalDebug) echo 'Get Data...'."\n";
1252
+		$buffer = $Common->getData($value['host']);
1253
+		$all_data = json_decode($buffer,true);
1254
+		if ($buffer != '') {
1255 1255
 		$Source->deleteLocationBySource('blitzortung');
1256 1256
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1257 1257
 		$buffer = explode('\n',$buffer);
1258 1258
 		foreach ($buffer as $buffer_line) {
1259
-		    $line = json_decode($buffer_line,true);
1260
-		    if (isset($line['time'])) {
1259
+			$line = json_decode($buffer_line,true);
1260
+			if (isset($line['time'])) {
1261 1261
 			$data = array();
1262 1262
 			$data['altitude'] = $line['alt']; // altitude
1263 1263
 			$data['latitude'] = $line['lat']; // lat
@@ -1269,94 +1269,94 @@  discard block
 block discarded – undo
1269 1269
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1270 1270
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1271 1271
 			unset($data);
1272
-		    }
1272
+			}
1273 1273
 		}
1274 1274
 		if ($globalDebug) echo 'No more data...'."\n";
1275 1275
 		unset($buffer);
1276
-	    }
1277
-	    $last_exec[$id]['last'] = time();
1276
+		}
1277
+		$last_exec[$id]['last'] = time();
1278 1278
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1279 1279
 	} 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') {
1280
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1281
-    	    //$last_exec[$id]['last'] = time();
1280
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1281
+			//$last_exec[$id]['last'] = time();
1282 1282
 
1283
-	    //$read = array( $sockets[$id] );
1284
-	    $read = $sockets;
1285
-	    $write = NULL;
1286
-	    $e = NULL;
1287
-	    $n = socket_select($read, $write, $e, $timeout);
1288
-	    if ($e != NULL) var_dump($e);
1289
-	    if ($n > 0) {
1283
+		//$read = array( $sockets[$id] );
1284
+		$read = $sockets;
1285
+		$write = NULL;
1286
+		$e = NULL;
1287
+		$n = socket_select($read, $write, $e, $timeout);
1288
+		if ($e != NULL) var_dump($e);
1289
+		if ($n > 0) {
1290 1290
 		$reset = 0;
1291 1291
 		foreach ($read as $nb => $r) {
1292
-		    //$value = $formats[$nb];
1293
-		    $format = $globalSources[$nb]['format'];
1294
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1292
+			//$value = $formats[$nb];
1293
+			$format = $globalSources[$nb]['format'];
1294
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1295 1295
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1296
-		    } elseif ($format == 'vrstcp') {
1296
+			} elseif ($format == 'vrstcp') {
1297 1297
 			$buffer = @socket_read($r, 6000);
1298
-		    } else {
1298
+			} else {
1299 1299
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1300
-		    }
1301
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1302
-		    //echo $buffer."\n";
1303
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1304
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1305
-		    $error = false;
1306
-		    //$SI::del();
1307
-		    if ($format == 'vrstcp') {
1300
+			}
1301
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1302
+			//echo $buffer."\n";
1303
+			// lets play nice and handle signals such as ctrl-c/kill properly
1304
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1305
+			$error = false;
1306
+			//$SI::del();
1307
+			if ($format == 'vrstcp') {
1308 1308
 			$buffer = explode('},{',$buffer);
1309
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1310
-		    // SBS format is CSV format
1311
-		    if ($buffer !== FALSE && $buffer != '') {
1309
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1310
+			// SBS format is CSV format
1311
+			if ($buffer !== FALSE && $buffer != '') {
1312 1312
 			$tt[$format] = 0;
1313 1313
 			if ($format == 'acarssbs3') {
1314
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1315
-			    $ACARS->add(trim($buffer));
1316
-			    $ACARS->deleteLiveAcarsData();
1314
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1315
+				$ACARS->add(trim($buffer));
1316
+				$ACARS->deleteLiveAcarsData();
1317 1317
 			} elseif ($format == 'raw') {
1318
-			    // AVR format
1319
-			    $data = $SBS->parse($buffer);
1320
-			    if (is_array($data)) {
1318
+				// AVR format
1319
+				$data = $SBS->parse($buffer);
1320
+				if (is_array($data)) {
1321 1321
 				$data['datetime'] = date('Y-m-d H:i:s');
1322 1322
 				$data['format_source'] = 'raw';
1323 1323
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1324 1324
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1325 1325
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1326 1326
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1327
-			    }
1327
+				}
1328 1328
 			} elseif ($format == 'ais') {
1329
-			    $ais_data = $AIS->parse_line(trim($buffer));
1330
-			    $data = array();
1331
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1332
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1333
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1334
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1335
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1336
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1337
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1338
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1339
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1340
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1341
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1342
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1343
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1344
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1345
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1346
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1329
+				$ais_data = $AIS->parse_line(trim($buffer));
1330
+				$data = array();
1331
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1332
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1333
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1334
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1335
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1336
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1337
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1338
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1339
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1340
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1341
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1342
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1343
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1344
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1345
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1346
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1347 1347
 
1348
-			    if (isset($ais_data['timestamp'])) {
1348
+				if (isset($ais_data['timestamp'])) {
1349 1349
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1350
-			    } else {
1350
+				} else {
1351 1351
 				$data['datetime'] = date('Y-m-d H:i:s');
1352
-			    }
1353
-			    $data['format_source'] = 'aisnmea';
1354
-    			    $data['id_source'] = $id_source;
1355
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1356
-			    unset($data);
1357
-                        } elseif ($format == 'flightgearsp') {
1358
-                    	    //echo $buffer."\n";
1359
-                    	    if (strlen($buffer) > 5) {
1352
+				}
1353
+				$data['format_source'] = 'aisnmea';
1354
+					$data['id_source'] = $id_source;
1355
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1356
+				unset($data);
1357
+						} elseif ($format == 'flightgearsp') {
1358
+							//echo $buffer."\n";
1359
+							if (strlen($buffer) > 5) {
1360 1360
 				$line = explode(',',$buffer);
1361 1361
 				$data = array();
1362 1362
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1373,38 +1373,38 @@  discard block
 block discarded – undo
1373 1373
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1374 1374
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1375 1375
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1376
-			    }
1377
-                        } elseif ($format == 'acars') {
1378
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1379
-			    $ACARS->add(trim($buffer));
1380
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1381
-			    $ACARS->deleteLiveAcarsData();
1376
+				}
1377
+						} elseif ($format == 'acars') {
1378
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1379
+				$ACARS->add(trim($buffer));
1380
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1381
+				$ACARS->deleteLiveAcarsData();
1382 1382
 			} elseif ($format == 'flightgearmp') {
1383
-			    if (substr($buffer,0,1) != '#') {
1383
+				if (substr($buffer,0,1) != '#') {
1384 1384
 				$data = array();
1385 1385
 				//echo $buffer."\n";
1386 1386
 				$line = explode(' ',$buffer);
1387 1387
 				if (count($line) == 11) {
1388
-				    $userserver = explode('@',$line[0]);
1389
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1390
-				    $data['ident'] = $userserver[0];
1391
-				    $data['registration'] = $userserver[0];
1392
-				    $data['latitude'] = $line[4];
1393
-				    $data['longitude'] = $line[5];
1394
-				    $data['altitude'] = $line[6];
1395
-				    $data['datetime'] = date('Y-m-d H:i:s');
1396
-				    $aircraft_type = $line[10];
1397
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1398
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1399
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1400
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1388
+					$userserver = explode('@',$line[0]);
1389
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1390
+					$data['ident'] = $userserver[0];
1391
+					$data['registration'] = $userserver[0];
1392
+					$data['latitude'] = $line[4];
1393
+					$data['longitude'] = $line[5];
1394
+					$data['altitude'] = $line[6];
1395
+					$data['datetime'] = date('Y-m-d H:i:s');
1396
+					$aircraft_type = $line[10];
1397
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1398
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1399
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1400
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1401
+				}
1401 1402
 				}
1402
-			    }
1403 1403
 			} elseif ($format == 'beast') {
1404
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1405
-			    die;
1404
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1405
+				die;
1406 1406
 			} elseif ($format == 'vrstcp') {
1407
-			    foreach($buffer as $all_data) {
1407
+				foreach($buffer as $all_data) {
1408 1408
 				$line = json_decode('{'.$all_data.'}',true);
1409 1409
 				$data = array();
1410 1410
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1424,151 +1424,151 @@  discard block
 block discarded – undo
1424 1424
 				*/
1425 1425
 				$data['datetime'] = date('Y-m-d H:i:s');
1426 1426
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1427
-		    		$data['format_source'] = 'vrstcp';
1427
+					$data['format_source'] = 'vrstcp';
1428 1428
 				$data['id_source'] = $id_source;
1429 1429
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1430 1430
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1431 1431
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1432 1432
 				unset($data);
1433
-			    }
1433
+				}
1434 1434
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1435
-			    $line = explode("\t", $buffer);
1436
-			    for($k = 0; $k < count($line); $k=$k+2) {
1435
+				$line = explode("\t", $buffer);
1436
+				for($k = 0; $k < count($line); $k=$k+2) {
1437 1437
 				$key = $line[$k];
1438
-			        $lined[$key] = $line[$k+1];
1439
-			    }
1440
-    			    if (count($lined) > 3) {
1441
-    				$data['hex'] = $lined['hexid'];
1442
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1443
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1444
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1445
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1446
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1447
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1448
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1449
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1450
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1451
-    				$data['id_source'] = $id_source;
1452
-    				$data['format_source'] = 'tsv';
1453
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1454
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1438
+					$lined[$key] = $line[$k+1];
1439
+				}
1440
+					if (count($lined) > 3) {
1441
+					$data['hex'] = $lined['hexid'];
1442
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1443
+					$data['datetime'] = date('Y-m-d H:i:s');;
1444
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1445
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1446
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1447
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1448
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1449
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1450
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1451
+					$data['id_source'] = $id_source;
1452
+					$data['format_source'] = 'tsv';
1453
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1454
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1455 1455
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1456
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1457
-    				unset($lined);
1458
-    				unset($data);
1459
-    			    } else $error = true;
1456
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1457
+					unset($lined);
1458
+					unset($data);
1459
+					} else $error = true;
1460 1460
 			} elseif ($format == 'aprs' && $use_aprs) {
1461
-			    if ($aprs_connect == 0) {
1461
+				if ($aprs_connect == 0) {
1462 1462
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1463 1463
 				$aprs_connect = 1;
1464
-			    }
1464
+				}
1465 1465
 			    
1466
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1466
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1467 1467
 				$aprs_last_tx = time();
1468 1468
 				$data_aprs = "# Keep alive";
1469 1469
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1470
-			    }
1470
+				}
1471 1471
 			    
1472
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1473
-			    //echo 'APRS data : '.$buffer."\n";
1474
-			    $buffer = str_replace('APRS <- ','',$buffer);
1475
-			    $buffer = str_replace('APRS -> ','',$buffer);
1476
-			    //echo $buffer."\n";
1477
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1472
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1473
+				//echo 'APRS data : '.$buffer."\n";
1474
+				$buffer = str_replace('APRS <- ','',$buffer);
1475
+				$buffer = str_replace('APRS -> ','',$buffer);
1476
+				//echo $buffer."\n";
1477
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1478 1478
 				$line = $APRS->parse($buffer);
1479 1479
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1480 1480
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1481
-				    $aprs_last_tx = time();
1482
-				    $data = array();
1483
-				    //print_r($line);
1484
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1485
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1486
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1487
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1488
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1489
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1490
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1491
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1492
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1493
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1494
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1495
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1496
-				    $data['latitude'] = $line['latitude'];
1497
-				    $data['longitude'] = $line['longitude'];
1498
-				    //$data['verticalrate'] = $line[16];
1499
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1500
-				    //else $data['speed'] = 0;
1501
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1502
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1503
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1504
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1481
+					$aprs_last_tx = time();
1482
+					$data = array();
1483
+					//print_r($line);
1484
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1485
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1486
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1487
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1488
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1489
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1490
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1491
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1492
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1493
+					else $data['datetime'] = date('Y-m-d H:i:s');
1494
+					//$data['datetime'] = date('Y-m-d H:i:s');
1495
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1496
+					$data['latitude'] = $line['latitude'];
1497
+					$data['longitude'] = $line['longitude'];
1498
+					//$data['verticalrate'] = $line[16];
1499
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1500
+					//else $data['speed'] = 0;
1501
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1502
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1503
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1504
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1505 1505
 				    
1506
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1507
-				    //else echo 'No heading...'."\n";
1508
-				    //else $data['heading'] = 0;
1509
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1510
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1511
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1512
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1513
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1514
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1515
-    				    $data['id_source'] = $id_source;
1516
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1517
-				    else $data['format_source'] = 'aprs';
1518
-				    $data['source_name'] = $line['source'];
1519
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1520
-				    else $data['source_type'] = 'flarm';
1521
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1522
-				    $currentdate = date('Y-m-d H:i:s');
1523
-				    $aprsdate = strtotime($data['datetime']);
1524
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1525
-				    // Accept data if time <= system time + 20s
1526
-				    //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'])))) {
1527
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1506
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1507
+					//else echo 'No heading...'."\n";
1508
+					//else $data['heading'] = 0;
1509
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1510
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1511
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1512
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1513
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1514
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1515
+						$data['id_source'] = $id_source;
1516
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1517
+					else $data['format_source'] = 'aprs';
1518
+					$data['source_name'] = $line['source'];
1519
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1520
+					else $data['source_type'] = 'flarm';
1521
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1522
+					$currentdate = date('Y-m-d H:i:s');
1523
+					$aprsdate = strtotime($data['datetime']);
1524
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1525
+					// Accept data if time <= system time + 20s
1526
+					//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'])))) {
1527
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1528 1528
 					$send = $SI->add($data);
1529
-				    } elseif ($data['source_type'] == 'ais') {
1529
+					} elseif ($data['source_type'] == 'ais') {
1530 1530
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1531
-				    } elseif (isset($line['stealth'])) {
1531
+					} elseif (isset($line['stealth'])) {
1532 1532
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1533 1533
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1534
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1535
-					    //$line['symbol'] == 'Balloon' ||
1536
-					    $line['symbol'] == 'Glider' || 
1537
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1538
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1539
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1540
-					    $send = $SI->add($data);
1541
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1542
-					    $line['symbol'] == 'Yacht (Sail)' || 
1543
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1544
-					    $send = $MI->add($data);
1545
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1546
-					    $line['symbol'] == 'Car' || 
1547
-					    $line['symbol'] == 'Ambulance' || 
1548
-					    $line['symbol'] == 'Van' || 
1549
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1550
-					    $line['symbol'] == 'Motorcycle' || 
1551
-					    $line['symbol'] == 'Tractor' || 
1552
-					    $line['symbol'] == 'Police' || 
1553
-					    $line['symbol'] == 'Bike' || 
1554
-					    $line['symbol'] == 'Jogger' || 
1555
-					    $line['symbol'] == 'Horse' || 
1556
-					    $line['symbol'] == 'Bus' || 
1557
-					    $line['symbol'] == 'Jeep' || 
1558
-					    $line['symbol'] == 'Recreational Vehicle' || 
1559
-					    $line['symbol'] == 'Yacht (Sail)' || 
1560
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1561
-					    $line['symbol'] == 'Firetruck' || 
1562
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1563
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1564
-					    $line['symbol'] == 'SUV' ||
1565
-					    $line['symbol'] == 'Snowmobile' ||
1566
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1567
-				    //} 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') {
1534
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1535
+						//$line['symbol'] == 'Balloon' ||
1536
+						$line['symbol'] == 'Glider' || 
1537
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1538
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1539
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1540
+						$send = $SI->add($data);
1541
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1542
+						$line['symbol'] == 'Yacht (Sail)' || 
1543
+						$line['symbol'] == 'Ship (Power Boat)')) {
1544
+						$send = $MI->add($data);
1545
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1546
+						$line['symbol'] == 'Car' || 
1547
+						$line['symbol'] == 'Ambulance' || 
1548
+						$line['symbol'] == 'Van' || 
1549
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1550
+						$line['symbol'] == 'Motorcycle' || 
1551
+						$line['symbol'] == 'Tractor' || 
1552
+						$line['symbol'] == 'Police' || 
1553
+						$line['symbol'] == 'Bike' || 
1554
+						$line['symbol'] == 'Jogger' || 
1555
+						$line['symbol'] == 'Horse' || 
1556
+						$line['symbol'] == 'Bus' || 
1557
+						$line['symbol'] == 'Jeep' || 
1558
+						$line['symbol'] == 'Recreational Vehicle' || 
1559
+						$line['symbol'] == 'Yacht (Sail)' || 
1560
+						$line['symbol'] == 'Ship (Power Boat)' || 
1561
+						$line['symbol'] == 'Firetruck' || 
1562
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1563
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1564
+						$line['symbol'] == 'SUV' ||
1565
+						$line['symbol'] == 'Snowmobile' ||
1566
+						$line['symbol'] == 'Mobile Satellite Station')) {
1567
+					//} 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') {
1568 1568
 				//    } 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') {
1569 1569
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1570 1570
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1571
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1571
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1572 1572
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1573 1573
 					$Source->deleteOldLocationByType('gs');
1574 1574
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
 					} else {
1577 1577
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1578 1578
 					}
1579
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1579
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1580 1580
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1581 1581
 					if ($globalDebug) echo '# Weather Station added'."\n";
1582 1582
 					$Source->deleteOldLocationByType('wx');
@@ -1586,7 +1586,7 @@  discard block
 block discarded – undo
1586 1586
 					} else {
1587 1587
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1588 1588
 					}
1589
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1589
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1590 1590
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1591 1591
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1592 1592
 					$Source->deleteOldLocationByType('lightning');
@@ -1595,11 +1595,11 @@  discard block
 block discarded – undo
1595 1595
 					} else {
1596 1596
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1597 1597
 					}
1598
-				    } elseif ($globalDebug) {
1599
-				    	echo '/!\ Not added: '.$buffer."\n";
1600
-				    	print_r($line);
1601
-				    }
1602
-				    unset($data);
1598
+					} elseif ($globalDebug) {
1599
+						echo '/!\ Not added: '.$buffer."\n";
1600
+						print_r($line);
1601
+					}
1602
+					unset($data);
1603 1603
 				}
1604 1604
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1605 1605
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1618,12 +1618,12 @@  discard block
 block discarded – undo
1618 1618
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1619 1619
 					$globalSources[$nb]['last_weather_clean'] = time();
1620 1620
 				}
1621
-			    }
1621
+				}
1622 1622
 			} else {
1623
-			    $line = explode(',', $buffer);
1624
-    			    if (count($line) > 20) {
1625
-    			    	$data['hex'] = $line[4];
1626
-    				/*
1623
+				$line = explode(',', $buffer);
1624
+					if (count($line) > 20) {
1625
+						$data['hex'] = $line[4];
1626
+					/*
1627 1627
     				$data['datetime'] = $line[6].' '.$line[7];
1628 1628
     					date_default_timezone_set($globalTimezone);
1629 1629
     					$datetime = new DateTime($data['datetime']);
@@ -1631,30 +1631,30 @@  discard block
 block discarded – undo
1631 1631
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1632 1632
     					date_default_timezone_set('UTC');
1633 1633
     				*/
1634
-    				// Force datetime to current UTC datetime
1635
-    				date_default_timezone_set('UTC');
1636
-    				$data['datetime'] = date('Y-m-d H:i:s');
1637
-    				$data['ident'] = trim($line[10]);
1638
-    				$data['latitude'] = $line[14];
1639
-    				$data['longitude'] = $line[15];
1640
-    				$data['verticalrate'] = $line[16];
1641
-    				$data['emergency'] = $line[20];
1642
-    				$data['speed'] = $line[12];
1643
-    				$data['squawk'] = $line[17];
1644
-    				$data['altitude'] = $line[11];
1645
-    				$data['heading'] = $line[13];
1646
-    				$data['ground'] = $line[21];
1647
-    				$data['emergency'] = $line[19];
1648
-    				$data['format_source'] = 'sbs';
1634
+					// Force datetime to current UTC datetime
1635
+					date_default_timezone_set('UTC');
1636
+					$data['datetime'] = date('Y-m-d H:i:s');
1637
+					$data['ident'] = trim($line[10]);
1638
+					$data['latitude'] = $line[14];
1639
+					$data['longitude'] = $line[15];
1640
+					$data['verticalrate'] = $line[16];
1641
+					$data['emergency'] = $line[20];
1642
+					$data['speed'] = $line[12];
1643
+					$data['squawk'] = $line[17];
1644
+					$data['altitude'] = $line[11];
1645
+					$data['heading'] = $line[13];
1646
+					$data['ground'] = $line[21];
1647
+					$data['emergency'] = $line[19];
1648
+					$data['format_source'] = 'sbs';
1649 1649
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1650
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1651 1651
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1652
-    				$data['id_source'] = $id_source;
1653
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1654
-    				else $error = true;
1655
-    				unset($data);
1656
-    			    } else $error = true;
1657
-			    if ($error) {
1652
+					$data['id_source'] = $id_source;
1653
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1654
+					else $error = true;
1655
+					unset($data);
1656
+					} else $error = true;
1657
+				if ($error) {
1658 1658
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1659 1659
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1660 1660
 				} else {
@@ -1670,13 +1670,13 @@  discard block
 block discarded – undo
1670 1670
 					connect_all($sourceer);
1671 1671
 					$sourceer = array();
1672 1672
 				}
1673
-			    }
1673
+				}
1674 1674
 			}
1675 1675
 			// Sleep for xxx microseconds
1676 1676
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1677
-		    } else {
1677
+			} else {
1678 1678
 			if ($format == 'flightgearmp') {
1679
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1679
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1680 1680
 				//@socket_close($r);
1681 1681
 				sleep($globalMinFetch);
1682 1682
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1685,9 +1685,9 @@  discard block
 block discarded – undo
1685 1685
 				break;
1686 1686
 				
1687 1687
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1688
-			    if (isset($tt[$format])) $tt[$format]++;
1689
-			    else $tt[$format] = 0;
1690
-			    if ($tt[$format] > 30) {
1688
+				if (isset($tt[$format])) $tt[$format]++;
1689
+				else $tt[$format] = 0;
1690
+				if ($tt[$format] > 30) {
1691 1691
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1692 1692
 				//@socket_close($r);
1693 1693
 				sleep(2);
@@ -1698,23 +1698,23 @@  discard block
 block discarded – undo
1698 1698
 				//connect_all($globalSources);
1699 1699
 				$tt[$format]=0;
1700 1700
 				break;
1701
-			    }
1701
+				}
1702
+			}
1702 1703
 			}
1703
-		    }
1704 1704
 		}
1705
-	    } else {
1705
+		} else {
1706 1706
 		$error = socket_strerror(socket_last_error());
1707 1707
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1708 1708
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1709 1709
 			if (isset($globalDebug)) echo "Restarting...\n";
1710 1710
 			// Restart the script if possible
1711 1711
 			if (is_array($sockets)) {
1712
-			    if ($globalDebug) echo "Shutdown all sockets...";
1712
+				if ($globalDebug) echo "Shutdown all sockets...";
1713 1713
 			    
1714
-			    foreach ($sockets as $sock) {
1714
+				foreach ($sockets as $sock) {
1715 1715
 				@socket_shutdown($sock,2);
1716 1716
 				@socket_close($sock);
1717
-			    }
1717
+				}
1718 1718
 			    
1719 1719
 			}
1720 1720
 			if ($globalDebug) echo "Waiting...";
@@ -1729,15 +1729,15 @@  discard block
 block discarded – undo
1729 1729
 			if ($globalDebug) echo "Restart all connections...";
1730 1730
 			connect_all($globalSources);
1731 1731
 		}
1732
-	    }
1732
+		}
1733 1733
 	}
1734 1734
 	if ($globalDaemon === false) {
1735
-	    if ($globalDebug) echo 'Check all...'."\n";
1736
-	    if (isset($SI)) $SI->checkAll();
1737
-	    if (isset($TI)) $TI->checkAll();
1738
-	    if (isset($MI)) $MI->checkAll();
1735
+		if ($globalDebug) echo 'Check all...'."\n";
1736
+		if (isset($SI)) $SI->checkAll();
1737
+		if (isset($TI)) $TI->checkAll();
1738
+		if (isset($MI)) $MI->checkAll();
1739
+	}
1739 1740
 	}
1740
-    }
1741 1741
 }
1742 1742
 
1743 1743
 ?>
Please login to merge, or discard this patch.
Spacing   +182 added lines, -182 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'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 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'])) {
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 else $id_source = 1;
87 87
 if (isset($globalServer) && $globalServer) {
88 88
     if ($globalDebug) echo "Using Server Mode\n";
89
-    $SI=new SpotterServer();
89
+    $SI = new SpotterServer();
90 90
 /*
91 91
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
92 92
     $SI = new adsb2aprs();
93 93
     $SI->connect();
94 94
 */
95
-} else $SI=new SpotterImport($Connection->db);
95
+} else $SI = new SpotterImport($Connection->db);
96 96
 
97 97
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
98 98
 if (isset($globalMarine) && $globalMarine) {
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
     $MI = new MarineImport($Connection->db);
107 107
 }
108 108
 //$APRS=new APRS($Connection->db);
109
-$SBS=new SBS();
110
-$ACARS=new ACARS($Connection->db,true);
111
-$Source=new Source($Connection->db);
112
-$Common=new Common();
109
+$SBS = new SBS();
110
+$ACARS = new ACARS($Connection->db, true);
111
+$Source = new Source($Connection->db);
112
+$Common = new Common();
113 113
 date_default_timezone_set('UTC');
114 114
 //$servertz = system('date +%Z');
115 115
 // signal handler - playing nice with sockets and dump1090
116 116
 if (function_exists('pcntl_fork')) {
117
-    pcntl_signal(SIGINT,  function() {
117
+    pcntl_signal(SIGINT, function() {
118 118
         global $sockets;
119 119
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
120 120
         die("Bye!\n");
@@ -130,30 +130,30 @@  discard block
 block discarded – undo
130 130
 
131 131
 function connect_all($hosts) {
132 132
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
133
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
133
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
134 134
     $reset++;
135 135
     if ($globalDebug) echo 'Connect to all...'."\n";
136 136
     foreach ($hosts as $id => $value) {
137 137
 	$host = $value['host'];
138 138
 	$globalSources[$id]['last_exec'] = 0;
139 139
 	// Here we check type of source(s)
140
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
141
-            if (preg_match('/deltadb.txt$/i',$host)) {
140
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
141
+            if (preg_match('/deltadb.txt$/i', $host)) {
142 142
         	//$formats[$id] = 'deltadbtxt';
143 143
         	$globalSources[$id]['format'] = 'deltadbtxt';
144 144
         	//$last_exec['deltadbtxt'] = 0;
145 145
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
146
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
146
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
147 147
         	//$formats[$id] = 'vatsimtxt';
148 148
         	$globalSources[$id]['format'] = 'vatsimtxt';
149 149
         	//$last_exec['vatsimtxt'] = 0;
150 150
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
151
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
151
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
152 152
         	//$formats[$id] = 'aircraftlistjson';
153 153
         	$globalSources[$id]['format'] = 'aircraftlistjson';
154 154
         	//$last_exec['aircraftlistjson'] = 0;
155 155
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
156
-    	    } else if (preg_match('/opensky/i',$host)) {
156
+    	    } else if (preg_match('/opensky/i', $host)) {
157 157
         	//$formats[$id] = 'aircraftlistjson';
158 158
         	$globalSources[$id]['format'] = 'opensky';
159 159
         	//$last_exec['aircraftlistjson'] = 0;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         	    exit(0);
171 171
         	}
172 172
     	    */
173
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
173
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
174 174
         	//$formats[$id] = 'planeupdatefaa';
175 175
         	$globalSources[$id]['format'] = 'planeupdatefaa';
176 176
         	//$last_exec['planeupdatefaa'] = 0;
@@ -179,32 +179,32 @@  discard block
 block discarded – undo
179 179
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
180 180
         	    exit(0);
181 181
         	}
182
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
182
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
183 183
         	//$formats[$id] = 'phpvmacars';
184 184
         	$globalSources[$id]['format'] = 'phpvmacars';
185 185
         	//$last_exec['phpvmacars'] = 0;
186 186
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
187
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
187
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
188 188
         	//$formats[$id] = 'phpvmacars';
189 189
         	$globalSources[$id]['format'] = 'vam';
190 190
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
191
-            } else if (preg_match('/whazzup/i',$host)) {
191
+            } else if (preg_match('/whazzup/i', $host)) {
192 192
         	//$formats[$id] = 'whazzup';
193 193
         	$globalSources[$id]['format'] = 'whazzup';
194 194
         	//$last_exec['whazzup'] = 0;
195 195
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
196
-            } else if (preg_match('/blitzortung/i',$host)) {
196
+            } else if (preg_match('/blitzortung/i', $host)) {
197 197
         	$globalSources[$id]['format'] = 'blitzortung';
198 198
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
199
-            } else if (preg_match('/airwhere/i',$host)) {
199
+            } else if (preg_match('/airwhere/i', $host)) {
200 200
         	$globalSources[$id]['format'] = 'airwhere';
201 201
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
202
-            } else if (preg_match('/recentpireps/i',$host)) {
202
+            } else if (preg_match('/recentpireps/i', $host)) {
203 203
         	//$formats[$id] = 'pirepsjson';
204 204
         	$globalSources[$id]['format'] = 'pirepsjson';
205 205
         	//$last_exec['pirepsjson'] = 0;
206 206
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
207
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
207
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
208 208
         	//$formats[$id] = 'fr24json';
209 209
         	$globalSources[$id]['format'] = 'fr24json';
210 210
         	//$last_exec['fr24json'] = 0;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
214 214
         	    exit(0);
215 215
         	}
216
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
216
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
217 217
         	//$formats[$id] = 'fr24json';
218 218
         	$globalSources[$id]['format'] = 'myshiptracking';
219 219
         	//$last_exec['fr24json'] = 0;
@@ -223,22 +223,22 @@  discard block
 block discarded – undo
223 223
         	    exit(0);
224 224
         	}
225 225
             //} else if (preg_match('/10001/',$host)) {
226
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
226
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
227 227
         	//$formats[$id] = 'tsv';
228 228
         	$globalSources[$id]['format'] = 'tsv';
229 229
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
230 230
             }
231
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
231
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
232 232
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
233
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
233
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
234 234
     		    if ($idf !== false) {
235 235
     			$httpfeeds[$id] = $idf;
236 236
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
237 237
     		    }
238 238
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
239 239
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
241
-	    $hostport = explode(':',$host);
240
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
241
+	    $hostport = explode(':', $host);
242 242
 	    if (isset($hostport[1])) {
243 243
 		$port = $hostport[1];
244 244
 		$hostn = $hostport[0];
@@ -248,19 +248,19 @@  discard block
 block discarded – undo
248 248
 	    }
249 249
 	    $Common = new Common();
250 250
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
251
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
251
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
252 252
     	    } else {
253
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
253
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
254 254
 	    }
255 255
 	    if ($s) {
256 256
     	        $sockets[$id] = $s;
257 257
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
258
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
258
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
259 259
 			//$formats[$id] = 'aprs';
260 260
 			$globalSources[$id]['format'] = 'aprs';
261 261
 			//$aprs_connect = 0;
262 262
 			//$use_aprs = true;
263
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
263
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
264 264
 			$globalSources[$id]['format'] = 'vrstcp';
265 265
     		    } elseif ($port == '10001') {
266 266
         		//$formats[$id] = 'tsv';
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
300 300
 else $timeout = 20;
301 301
 $errno = '';
302
-$errstr='';
302
+$errstr = '';
303 303
 
304 304
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
305 305
 /* Initiate connections to all the hosts simultaneously */
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 //connect_all($globalSources);
308 308
 
309 309
 if (isset($globalProxy) && $globalProxy) {
310
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
310
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
311 311
 } else {
312 312
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
313 313
 }
@@ -337,16 +337,16 @@  discard block
 block discarded – undo
337 337
 
338 338
 if ($use_aprs) {
339 339
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
340
-	$APRS=new APRS();
340
+	$APRS = new APRS();
341 341
 	$aprs_connect = 0;
342 342
 	$aprs_keep = 120;
343 343
 	$aprs_last_tx = time();
344 344
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
345
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
345
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
346 346
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
347
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
347
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
348 348
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
349
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
349
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
350 350
 	if ($aprs_full) $aprs_filter = '';
351 351
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
352 352
 	else $aprs_pass = '-1';
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
 sleep(1);
361 361
 if ($globalDebug) echo "SCAN MODE \n\n";
362 362
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
363
-$endtime = time()+$globalCronEnd;
363
+$endtime = time() + $globalCronEnd;
364 364
 $i = 1;
365 365
 $tt = array();
366 366
 // Delete all ATC
367 367
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
368
-	$ATC=new ATC($Connection->db);
368
+	$ATC = new ATC($Connection->db);
369 369
 }
370 370
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
371 371
 	$ATC->deleteAll();
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 
374 374
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
375 375
 while ($i > 0) {
376
-    if (!$globalDaemon) $i = $endtime-time();
376
+    if (!$globalDaemon) $i = $endtime - time();
377 377
     // Delete old ATC
378 378
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
379 379
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	}
388 388
 	if ($max != $globalMinFetch) {
389 389
 	    if ($globalDebug) echo 'Sleeping...'."\n";
390
-	    sleep($globalMinFetch-$max+2);
390
+	    sleep($globalMinFetch - $max + 2);
391 391
 	}
392 392
     }
393 393
 
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 	    //$buffer = $Common->getData($hosts[$id]);
407 407
 	    $buffer = $Common->getData($value['host']);
408 408
 	    if ($buffer != '') $reset = 0;
409
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
410
-	    $buffer = explode('\n',$buffer);
409
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
410
+	    $buffer = explode('\n', $buffer);
411 411
 	    foreach ($buffer as $line) {
412 412
     		if ($line != '' && count($line) > 7) {
413 413
     		    $line = explode(',', $line);
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
 	    )
441 441
 	) {
442 442
 	    date_default_timezone_set('CET');
443
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
443
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
444 444
 	    date_default_timezone_set('UTC');
445 445
 	    if ($buffer != '') $reset = 0;
446
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
447
-	    $buffer = explode('\n',$buffer);
446
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
447
+	    $buffer = explode('\n', $buffer);
448 448
 	    foreach ($buffer as $line) {
449 449
 		if ($line != '') {
450 450
 		    //echo "'".$line."'\n";
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
463 463
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
464 464
 		    if (isset($ais_data['timestamp'])) {
465
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
465
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
466 466
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
467 467
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
468 468
 			    $add = true;
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 	    $w = $e = null;
486 486
 	    
487 487
 	    if (isset($arr[$id])) {
488
-		$nn = stream_select($arr,$w,$e,$timeout);
488
+		$nn = stream_select($arr, $w, $e, $timeout);
489 489
 		if ($nn > 0) {
490 490
 		    foreach ($httpfeeds as $feed) {
491
-			$buffer = stream_get_line($feed,2000,"\n");
492
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
493
-			$buffer = explode('\n',$buffer);
491
+			$buffer = stream_get_line($feed, 2000, "\n");
492
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
493
+			$buffer = explode('\n', $buffer);
494 494
 			foreach ($buffer as $line) {
495 495
 			    if ($line != '') {
496 496
 				$ais_data = $AIS->parse_line(trim($line));
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
509 509
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
510 510
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
511
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
511
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
512 512
 				if (isset($ais_data['timestamp'])) {
513
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
513
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
514 514
 				} else {
515 515
 				    $data['datetime'] = date('Y-m-d H:i:s');
516 516
 				}
@@ -541,10 +541,10 @@  discard block
 block discarded – undo
541 541
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
542 542
 	    )
543 543
 	) {
544
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
544
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
545 545
 	    if ($buffer != '') {
546 546
 		//echo $buffer;
547
-		$all_data = json_decode($buffer,true);
547
+		$all_data = json_decode($buffer, true);
548 548
 		//print_r($all_data);
549 549
 		if (isset($all_data[0]['DATA'])) {
550 550
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
560 560
 			    $data['imo'] = $line['IMO'];
561 561
 			    //$data['arrival_code'] = $ais_data['destination'];
562
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
562
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
563 563
 			    $data['format_source'] = 'myshiptracking';
564 564
 			    $data['id_source'] = $id_source;
565 565
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -576,9 +576,9 @@  discard block
 block discarded – undo
576 576
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
577 577
 	    )
578 578
 	) {
579
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
579
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
580 580
 	    if ($buffer != '') {
581
-		$all_data = json_decode($buffer,true);
581
+		$all_data = json_decode($buffer, true);
582 582
 		if (isset($all_data[0]['mmsi'])) {
583 583
 		    foreach ($all_data as $line) {
584 584
 			if ($line != '') {
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	) {
613 613
 	    $buffer = $Common->getData($value['host']);
614 614
 	    if ($buffer != '') {
615
-		$all_data = json_decode($buffer,true);
615
+		$all_data = json_decode($buffer, true);
616 616
 		if (isset($all_data['features'][0]['id'])) {
617 617
 		    foreach ($all_data['features'] as $line) {
618 618
 			$data = array();
@@ -645,27 +645,27 @@  discard block
 block discarded – undo
645 645
 	    )
646 646
 	) {
647 647
 	    echo 'download...';
648
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
648
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
649 649
 	    echo 'done !'."\n";
650 650
 	    if ($buffer != '') $reset = 0;
651
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
652
-	    $buffer = explode('\n',$buffer);
651
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
652
+	    $buffer = explode('\n', $buffer);
653 653
 	    foreach ($buffer as $line) {
654 654
 		if ($line != '') {
655 655
 		    $data = array();
656
-		    $data['mmsi'] = (int)substr($line,0,9);
657
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
656
+		    $data['mmsi'] = (int) substr($line, 0, 9);
657
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
658 658
 		    //$data['status'] = substr($line,21,2);
659 659
 		    //$data['type'] = substr($line,24,3);
660
-		    $data['latitude'] = substr($line,29,9);
661
-		    $data['longitude'] = substr($line,41,9);
662
-		    $data['speed'] = round(substr($line,51,5));
660
+		    $data['latitude'] = substr($line, 29, 9);
661
+		    $data['longitude'] = substr($line, 41, 9);
662
+		    $data['speed'] = round(substr($line, 51, 5));
663 663
 		    //$data['course'] = substr($line,57,5);
664
-		    $data['heading'] = round(substr($line,63,3));
664
+		    $data['heading'] = round(substr($line, 63, 3));
665 665
 		    //$data['draft'] = substr($line,67,4);
666 666
 		    //$data['length'] = substr($line,72,3);
667 667
 		    //$data['beam'] = substr($line,76,2);
668
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
668
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
669 669
 		    //$data['callsign'] = trim(substr($line,100,7);
670 670
 		    //$data['dest'] = substr($line,108,20);
671 671
 		    //$data['etaDate'] = substr($line,129,5);
@@ -698,8 +698,8 @@  discard block
 block discarded – undo
698 698
 	) {
699 699
 	    //$buffer = $Common->getData($hosts[$id]);
700 700
 	    $buffer = $Common->getData($value['host']);
701
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
702
-	    $buffer = explode('\n',$buffer);
701
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
702
+	    $buffer = explode('\n', $buffer);
703 703
 	    $reset = 0;
704 704
 	    foreach ($buffer as $line) {
705 705
     		if ($line != '') {
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
711 711
 			$data['pilot_id'] = $line[1];
712 712
 			$data['pilot_name'] = $line[2];
713
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
713
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
714 714
 			$data['ident'] = $line[0]; // ident
715 715
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
716 716
 			$data['speed'] = $line[8]; // speed
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
727 727
 			//if (isset($line[37])) $data['last_update'] = $line[37];
728 728
 		        $data['departure_airport_icao'] = $line[11];
729
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
729
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
730 730
 		        $data['arrival_airport_icao'] = $line[13];
731 731
 			$data['frequency'] = $line[4];
732 732
 			$data['type'] = $line[18];
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
     			$data['id_source'] = $id_source;
736 736
 	    		//$data['arrival_airport_time'] = ;
737 737
 	    		if ($line[9] != '') {
738
-	    		    $aircraft_data = explode('/',$line[9]);
738
+	    		    $aircraft_data = explode('/', $line[9]);
739 739
 	    		    if (isset($aircraft_data[1])) {
740 740
 	    			$data['aircraft_icao'] = $aircraft_data[1];
741 741
 	    		    }
@@ -750,9 +750,9 @@  discard block
 block discarded – undo
750 750
     			if ($line[3] == 'PILOT') $SI->add($data);
751 751
 			elseif ($line[3] == 'ATC') {
752 752
 				//print_r($data);
753
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
754
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
755
-				$typec = substr($data['ident'],-3);
753
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
754
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
755
+				$typec = substr($data['ident'], -3);
756 756
 				if ($typec == 'APP') $data['type'] = 'Approach';
757 757
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
758 758
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
765 765
 				if (!isset($data['source_name'])) $data['source_name'] = '';
766 766
 				if (isset($ATC)) {
767
-					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']);
768
-					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']);
767
+					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']);
768
+					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']);
769 769
 				}
770 770
 			}
771 771
     			unset($data);
@@ -781,24 +781,24 @@  discard block
 block discarded – undo
781 781
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
782 782
     	    )
783 783
     	) {
784
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
784
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
785 785
 	    if ($buffer != '') {
786 786
 		$all_data = simplexml_load_string($buffer);
787
-		foreach($all_data->children() as $childdata) {
787
+		foreach ($all_data->children() as $childdata) {
788 788
 			$data = array();
789 789
 			$line = $childdata;
790 790
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
791
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
792
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
793
-			$data['latitude'] = (float)$line['pktLatitude'];
794
-			$data['longitude'] = (float)$line['pktLongitude'];
795
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
796
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
797
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
791
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
792
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
793
+			$data['latitude'] = (float) $line['pktLatitude'];
794
+			$data['longitude'] = (float) $line['pktLongitude'];
795
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
796
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
797
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
798 798
 			$data['altitude_relative'] = 'AMSL';
799
-			$data['pilot_id'] = (int)$line['pktPilotID'];
799
+			$data['pilot_id'] = (int) $line['pktPilotID'];
800 800
 			$data['aircraft_icao'] = 'PARAGLIDER';
801
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
801
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
802 802
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
803 803
 			$data['format_source'] = $value['format'];
804 804
 			$SI->add($data);
@@ -806,22 +806,22 @@  discard block
 block discarded – undo
806 806
 		}
807 807
 	    }
808 808
 	    $Source->deleteOldLocationByType('gs');
809
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
809
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
810 810
 	    if ($buffer != '') {
811 811
 		$all_data = simplexml_load_string($buffer);
812
-		foreach($all_data->children() as $childdata) {
812
+		foreach ($all_data->children() as $childdata) {
813 813
 			$data = array();
814 814
 			$line = $childdata;
815
-			$data['id'] = (int)$line['gsID'];
816
-			$data['latitude'] = (float)$line['gsLatitude'];
817
-			$data['longitude'] = (float)$line['gsLongitude'];
818
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
815
+			$data['id'] = (int) $line['gsID'];
816
+			$data['latitude'] = (float) $line['gsLatitude'];
817
+			$data['longitude'] = (float) $line['gsLongitude'];
818
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
819 819
 			$data['altitude_relative'] = 'AMSL';
820
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
820
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
821 821
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
822
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
822
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
823 823
 			} else {
824
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
824
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
825 825
 			}
826 826
 			unset($data);
827 827
 		}
@@ -839,9 +839,9 @@  discard block
 block discarded – undo
839 839
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
840 840
 	    )
841 841
 	) {
842
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
842
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
843 843
 	    if ($buffer != '') {
844
-	        $all_data = json_decode($buffer,true);
844
+	        $all_data = json_decode($buffer, true);
845 845
 		if (isset($all_data['acList'])) {
846 846
 		    $reset = 0;
847 847
 		    foreach ($all_data['acList'] as $line) {
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
858 858
 			$data['emergency'] = ''; // emergency
859 859
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
860
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
860
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
861 861
 			else $data['datetime'] = date('Y-m-d H:i:s');
862 862
 			//$data['datetime'] = date('Y-m-d H:i:s');
863 863
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 			$data['verticalrate'] = $line['vrt']; // verticale rate
883 883
 			$data['squawk'] = $line['squawk']; // squawk
884 884
 			$data['emergency'] = ''; // emergency
885
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
885
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
886 886
 			else $data['datetime'] = date('Y-m-d H:i:s');
887 887
 			$data['format_source'] = 'aircraftlistjson';
888 888
 			$data['id_source'] = $id_source;
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
     	    )
904 904
     	) {
905 905
 	    $buffer = $Common->getData($value['host']);
906
-	    $all_data = json_decode($buffer,true);
906
+	    $all_data = json_decode($buffer, true);
907 907
 	    if (isset($all_data['planes'])) {
908 908
 		$reset = 0;
909 909
 		foreach ($all_data['planes'] as $key => $line) {
@@ -920,12 +920,12 @@  discard block
 block discarded – undo
920 920
 		    $data['emergency'] = ''; // emergency
921 921
 		    $data['registration'] = $line[2];
922 922
 		    $data['aircraft_icao'] = $line[0];
923
-		    $deparr = explode('-',$line[1]);
923
+		    $deparr = explode('-', $line[1]);
924 924
 		    if (count($deparr) == 2) {
925 925
 			$data['departure_airport_icao'] = $deparr[0];
926 926
 			$data['arrival_airport_icao'] = $deparr[1];
927 927
 		    }
928
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
928
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
929 929
 	    	    $data['format_source'] = 'planeupdatefaa';
930 930
     		    $data['id_source'] = $id_source;
931 931
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 	    )
944 944
 	) {
945 945
 	    $buffer = $Common->getData($value['host']);
946
-	    $all_data = json_decode($buffer,true);
946
+	    $all_data = json_decode($buffer, true);
947 947
 	    if (isset($all_data['states'])) {
948 948
 		$reset = 0;
949 949
 		foreach ($all_data['states'] as $key => $line) {
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
 		    //$data['emergency'] = ''; // emergency
961 961
 		    //$data['registration'] = $line[2];
962 962
 		    //$data['aircraft_icao'] = $line[0];
963
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
963
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
964 964
 		    $data['format_source'] = 'opensky';
965 965
 		    $data['id_source'] = $id_source;
966 966
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 	) {
980 980
 	    //$buffer = $Common->getData($hosts[$id]);
981 981
 	    $buffer = $Common->getData($value['host']);
982
-	    $all_data = json_decode($buffer,true);
982
+	    $all_data = json_decode($buffer, true);
983 983
 	    if (!empty($all_data)) $reset = 0;
984 984
 	    foreach ($all_data as $key => $line) {
985 985
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1017,11 +1017,11 @@  discard block
 block discarded – undo
1017 1017
 	    )
1018 1018
 	) {
1019 1019
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1020
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1020
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1021 1021
 	    //echo $buffer;
1022
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1023
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1024
-	    $all_data = json_decode($buffer,true);
1022
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1023
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1024
+	    $all_data = json_decode($buffer, true);
1025 1025
 	    if (json_last_error() != JSON_ERROR_NONE) {
1026 1026
 		die(json_last_error_msg());
1027 1027
 	    }
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 			//$data['departure_airport_iata'] = $line[11];
1045 1045
 			//$data['arrival_airport_iata'] = $line[12];
1046 1046
 	    		//$data['emergency'] = ''; // emergency
1047
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1047
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1048 1048
 	    		$data['format_source'] = 'radarvirtueljson';
1049 1049
     			$data['id_source'] = $id_source;
1050 1050
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1065,14 +1065,14 @@  discard block
 block discarded – undo
1065 1065
 	) {
1066 1066
 	    //$buffer = $Common->getData($hosts[$id]);
1067 1067
 	    $buffer = $Common->getData($value['host'].'?'.time());
1068
-	    $all_data = json_decode(utf8_encode($buffer),true);
1068
+	    $all_data = json_decode(utf8_encode($buffer), true);
1069 1069
 	    
1070 1070
 	    if (isset($all_data['pireps'])) {
1071 1071
 		$reset = 0;
1072 1072
 	        foreach ($all_data['pireps'] as $line) {
1073 1073
 		    $data = array();
1074 1074
 		    $data['id'] = $line['id'];
1075
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1075
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1076 1076
 		    $data['ident'] = $line['callsign']; // ident
1077 1077
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1078 1078
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1102,9 +1102,9 @@  discard block
 block discarded – undo
1102 1102
 			$SI->add($data);
1103 1103
 		    //    print_r($data);
1104 1104
     		    } elseif ($line['icon'] == 'ct') {
1105
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1106
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1107
-			$typec = substr($data['ident'],-3);
1105
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1106
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1107
+			$typec = substr($data['ident'], -3);
1108 1108
 			$data['type'] = '';
1109 1109
 			if ($typec == 'APP') $data['type'] = 'Approach';
1110 1110
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1116 1116
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1117 1117
 			else $data['type'] = 'Observer';
1118
-			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']);
1118
+			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']);
1119 1119
 		    }
1120 1120
 		    unset($data);
1121 1121
 		}
@@ -1132,14 +1132,14 @@  discard block
 block discarded – undo
1132 1132
 	    //$buffer = $Common->getData($hosts[$id]);
1133 1133
 	    if ($globalDebug) echo 'Get Data...'."\n";
1134 1134
 	    $buffer = $Common->getData($value['host']);
1135
-	    $all_data = json_decode($buffer,true);
1135
+	    $all_data = json_decode($buffer, true);
1136 1136
 	    if ($buffer != '' && is_array($all_data)) {
1137 1137
 		$reset = 0;
1138 1138
 		foreach ($all_data as $line) {
1139 1139
 	    	    $data = array();
1140 1140
 	    	    //$data['id'] = $line['id']; // id not usable
1141 1141
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1142
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1142
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1143 1143
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1144 1144
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1145 1145
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 	    	    //$data['datetime'] = $line['lastupdate'];
1155 1155
 	    	    //$data['last_update'] = $line['lastupdate'];
1156 1156
 	    	    if (isset($value['timezone'])) {
1157
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1157
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1158 1158
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1159 1159
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1160 1160
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1167,14 +1167,14 @@  discard block
 block discarded – undo
1167 1167
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1168 1168
 		    if (isset($line['aircraftname'])) {
1169 1169
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1170
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1171
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1170
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1171
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1172 1172
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1173 1173
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1174 1174
 	    		else {
1175
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1176
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1177
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1175
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1176
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1177
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1178 1178
 	    		}
1179 1179
 	    	    }
1180 1180
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1199,14 +1199,14 @@  discard block
 block discarded – undo
1199 1199
 	    //$buffer = $Common->getData($hosts[$id]);
1200 1200
 	    if ($globalDebug) echo 'Get Data...'."\n";
1201 1201
 	    $buffer = $Common->getData($value['host']);
1202
-	    $all_data = json_decode($buffer,true);
1202
+	    $all_data = json_decode($buffer, true);
1203 1203
 	    if ($buffer != '' && is_array($all_data)) {
1204 1204
 		$reset = 0;
1205 1205
 		foreach ($all_data as $line) {
1206 1206
 	    	    $data = array();
1207 1207
 	    	    //$data['id'] = $line['id']; // id not usable
1208 1208
 	    	    $data['id'] = trim($line['flight_id']);
1209
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1209
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1210 1210
 	    	    $data['pilot_name'] = $line['pilot_name'];
1211 1211
 	    	    $data['pilot_id'] = $line['pilot_id'];
1212 1212
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1250,24 +1250,24 @@  discard block
 block discarded – undo
1250 1250
 	    //$buffer = $Common->getData($hosts[$id]);
1251 1251
 	    if ($globalDebug) echo 'Get Data...'."\n";
1252 1252
 	    $buffer = $Common->getData($value['host']);
1253
-	    $all_data = json_decode($buffer,true);
1253
+	    $all_data = json_decode($buffer, true);
1254 1254
 	    if ($buffer != '') {
1255 1255
 		$Source->deleteLocationBySource('blitzortung');
1256
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1257
-		$buffer = explode('\n',$buffer);
1256
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1257
+		$buffer = explode('\n', $buffer);
1258 1258
 		foreach ($buffer as $buffer_line) {
1259
-		    $line = json_decode($buffer_line,true);
1259
+		    $line = json_decode($buffer_line, true);
1260 1260
 		    if (isset($line['time'])) {
1261 1261
 			$data = array();
1262 1262
 			$data['altitude'] = $line['alt']; // altitude
1263 1263
 			$data['latitude'] = $line['lat']; // lat
1264 1264
 			$data['longitude'] = $line['lon']; // long
1265
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1265
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1266 1266
 			$data['id_source'] = $id_source;
1267 1267
 			$data['format_source'] = 'blitzortung';
1268 1268
 			$SI->add($data);
1269 1269
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1270
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1270
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1271 1271
 			unset($data);
1272 1272
 		    }
1273 1273
 		}
@@ -1292,11 +1292,11 @@  discard block
 block discarded – undo
1292 1292
 		    //$value = $formats[$nb];
1293 1293
 		    $format = $globalSources[$nb]['format'];
1294 1294
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1295
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1295
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1296 1296
 		    } elseif ($format == 'vrstcp') {
1297 1297
 			$buffer = @socket_read($r, 6000);
1298 1298
 		    } else {
1299
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1299
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1300 1300
 		    }
1301 1301
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1302 1302
 		    //echo $buffer."\n";
@@ -1305,8 +1305,8 @@  discard block
 block discarded – undo
1305 1305
 		    $error = false;
1306 1306
 		    //$SI::del();
1307 1307
 		    if ($format == 'vrstcp') {
1308
-			$buffer = explode('},{',$buffer);
1309
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1308
+			$buffer = explode('},{', $buffer);
1309
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1310 1310
 		    // SBS format is CSV format
1311 1311
 		    if ($buffer !== FALSE && $buffer != '') {
1312 1312
 			$tt[$format] = 0;
@@ -1340,13 +1340,13 @@  discard block
 block discarded – undo
1340 1340
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1341 1341
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1342 1342
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1343
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1343
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1344 1344
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1345 1345
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1346 1346
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1347 1347
 
1348 1348
 			    if (isset($ais_data['timestamp'])) {
1349
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1349
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1350 1350
 			    } else {
1351 1351
 				$data['datetime'] = date('Y-m-d H:i:s');
1352 1352
 			    }
@@ -1357,10 +1357,10 @@  discard block
 block discarded – undo
1357 1357
                         } elseif ($format == 'flightgearsp') {
1358 1358
                     	    //echo $buffer."\n";
1359 1359
                     	    if (strlen($buffer) > 5) {
1360
-				$line = explode(',',$buffer);
1360
+				$line = explode(',', $buffer);
1361 1361
 				$data = array();
1362 1362
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1363
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1363
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1364 1364
 				$data['ident'] = $line[6];
1365 1365
 				$data['aircraft_name'] = $line[7];
1366 1366
 				$data['longitude'] = $line[1];
@@ -1377,16 +1377,16 @@  discard block
 block discarded – undo
1377 1377
                         } elseif ($format == 'acars') {
1378 1378
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1379 1379
 			    $ACARS->add(trim($buffer));
1380
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1380
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1381 1381
 			    $ACARS->deleteLiveAcarsData();
1382 1382
 			} elseif ($format == 'flightgearmp') {
1383
-			    if (substr($buffer,0,1) != '#') {
1383
+			    if (substr($buffer, 0, 1) != '#') {
1384 1384
 				$data = array();
1385 1385
 				//echo $buffer."\n";
1386
-				$line = explode(' ',$buffer);
1386
+				$line = explode(' ', $buffer);
1387 1387
 				if (count($line) == 11) {
1388
-				    $userserver = explode('@',$line[0]);
1389
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1388
+				    $userserver = explode('@', $line[0]);
1389
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1390 1390
 				    $data['ident'] = $userserver[0];
1391 1391
 				    $data['registration'] = $userserver[0];
1392 1392
 				    $data['latitude'] = $line[4];
@@ -1394,8 +1394,8 @@  discard block
 block discarded – undo
1394 1394
 				    $data['altitude'] = $line[6];
1395 1395
 				    $data['datetime'] = date('Y-m-d H:i:s');
1396 1396
 				    $aircraft_type = $line[10];
1397
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1398
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1397
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1398
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1399 1399
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1400 1400
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1401 1401
 				}
@@ -1404,8 +1404,8 @@  discard block
 block discarded – undo
1404 1404
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1405 1405
 			    die;
1406 1406
 			} elseif ($format == 'vrstcp') {
1407
-			    foreach($buffer as $all_data) {
1408
-				$line = json_decode('{'.$all_data.'}',true);
1407
+			    foreach ($buffer as $all_data) {
1408
+				$line = json_decode('{'.$all_data.'}', true);
1409 1409
 				$data = array();
1410 1410
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1411 1411
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1431,16 +1431,16 @@  discard block
 block discarded – undo
1431 1431
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1432 1432
 				unset($data);
1433 1433
 			    }
1434
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1434
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1435 1435
 			    $line = explode("\t", $buffer);
1436
-			    for($k = 0; $k < count($line); $k=$k+2) {
1436
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1437 1437
 				$key = $line[$k];
1438
-			        $lined[$key] = $line[$k+1];
1438
+			        $lined[$key] = $line[$k + 1];
1439 1439
 			    }
1440 1440
     			    if (count($lined) > 3) {
1441 1441
     				$data['hex'] = $lined['hexid'];
1442 1442
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1443
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1443
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1444 1444
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1445 1445
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1446 1446
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1459,22 +1459,22 @@  discard block
 block discarded – undo
1459 1459
     			    } else $error = true;
1460 1460
 			} elseif ($format == 'aprs' && $use_aprs) {
1461 1461
 			    if ($aprs_connect == 0) {
1462
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1462
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1463 1463
 				$aprs_connect = 1;
1464 1464
 			    }
1465 1465
 			    
1466
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1466
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1467 1467
 				$aprs_last_tx = time();
1468 1468
 				$data_aprs = "# Keep alive";
1469
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1469
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1470 1470
 			    }
1471 1471
 			    
1472 1472
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1473 1473
 			    //echo 'APRS data : '.$buffer."\n";
1474
-			    $buffer = str_replace('APRS <- ','',$buffer);
1475
-			    $buffer = str_replace('APRS -> ','',$buffer);
1474
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1475
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1476 1476
 			    //echo $buffer."\n";
1477
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1477
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1478 1478
 				$line = $APRS->parse($buffer);
1479 1479
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1480 1480
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1490 1490
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1491 1491
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1492
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1492
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1493 1493
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1494 1494
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1495 1495
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1571,29 +1571,29 @@  discard block
 block discarded – undo
1571 1571
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1572 1572
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1573 1573
 					$Source->deleteOldLocationByType('gs');
1574
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1575
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1574
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1575
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1576 1576
 					} else {
1577
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1577
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1578 1578
 					}
1579 1579
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1580 1580
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1581 1581
 					if ($globalDebug) echo '# Weather Station added'."\n";
1582 1582
 					$Source->deleteOldLocationByType('wx');
1583 1583
 					$weather_data = json_encode($line);
1584
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1585
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1584
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1585
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1586 1586
 					} else {
1587
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1587
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1588 1588
 					}
1589 1589
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1590 1590
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1591 1591
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1592 1592
 					$Source->deleteOldLocationByType('lightning');
1593
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1594
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1593
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1594
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1595 1595
 					} else {
1596
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1596
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1597 1597
 					}
1598 1598
 				    } elseif ($globalDebug) {
1599 1599
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 				    unset($data);
1603 1603
 				}
1604 1604
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1605
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1605
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1606 1606
 				}
1607 1607
 				/*
1608 1608
 				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')) {
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
 				*/
1612 1612
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1613 1613
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1614
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1614
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1615 1615
 					$Source->deleteOldLocationByType('lightning');
1616 1616
 					$Source->deleteOldLocationByType('wx');
1617 1617
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 				connect_all($sourceee);
1697 1697
 				$sourceee = array();
1698 1698
 				//connect_all($globalSources);
1699
-				$tt[$format]=0;
1699
+				$tt[$format] = 0;
1700 1700
 				break;
1701 1701
 			    }
1702 1702
 			}
@@ -1705,14 +1705,14 @@  discard block
 block discarded – undo
1705 1705
 	    } else {
1706 1706
 		$error = socket_strerror(socket_last_error());
1707 1707
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1708
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1708
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1709 1709
 			if (isset($globalDebug)) echo "Restarting...\n";
1710 1710
 			// Restart the script if possible
1711 1711
 			if (is_array($sockets)) {
1712 1712
 			    if ($globalDebug) echo "Shutdown all sockets...";
1713 1713
 			    
1714 1714
 			    foreach ($sockets as $sock) {
1715
-				@socket_shutdown($sock,2);
1715
+				@socket_shutdown($sock, 2);
1716 1716
 				@socket_close($sock);
1717 1717
 			    }
1718 1718
 			    
Please login to merge, or discard this patch.
Braces   +1049 added lines, -358 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,48 +63,89 @@  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; 
77
-if (isset($options['enable_aircraft'])) $globalAircraft = TRUE; 
78
-if (isset($options['disable_aircraft'])) $globalAircraft = FALSE; 
79
-if (isset($options['enable_tracker'])) $globalTracker = TRUE; 
80
-if (isset($options['disable_tracker'])) $globalTracker = FALSE; 
81
-if (isset($options['enable_marine'])) $globalMarine = TRUE; 
82
-if (isset($options['disable_marine'])) $globalMarine = FALSE; 
83
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
84
-if (isset($options['server'])) $globalServer = TRUE;
85
-if (isset($options['idsource'])) $id_source = $options['idsource'];
86
-else $id_source = 1;
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
+}
95
+if (isset($options['enable_aircraft'])) {
96
+	$globalAircraft = TRUE;
97
+}
98
+if (isset($options['disable_aircraft'])) {
99
+	$globalAircraft = FALSE;
100
+}
101
+if (isset($options['enable_tracker'])) {
102
+	$globalTracker = TRUE;
103
+}
104
+if (isset($options['disable_tracker'])) {
105
+	$globalTracker = FALSE;
106
+}
107
+if (isset($options['enable_marine'])) {
108
+	$globalMarine = TRUE;
109
+}
110
+if (isset($options['disable_marine'])) {
111
+	$globalMarine = FALSE;
112
+}
113
+if (isset($options['nodaemon'])) {
114
+	$globalDaemon = FALSE;
115
+}
116
+if (isset($options['server'])) {
117
+	$globalServer = TRUE;
118
+}
119
+if (isset($options['idsource'])) {
120
+	$id_source = $options['idsource'];
121
+} else {
122
+	$id_source = 1;
123
+}
87 124
 if (isset($globalServer) && $globalServer) {
88
-    if ($globalDebug) echo "Using Server Mode\n";
125
+    if ($globalDebug) {
126
+    	echo "Using Server Mode\n";
127
+    }
89 128
     $SI=new SpotterServer();
90 129
 /*
91 130
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
92 131
     $SI = new adsb2aprs();
93 132
     $SI->connect();
94 133
 */
95
-} else $SI=new SpotterImport($Connection->db);
134
+} else {
135
+	$SI=new SpotterImport($Connection->db);
136
+}
96 137
 
97
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
138
+if (isset($globalTracker) && $globalTracker) {
139
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
140
+}
98 141
 if (isset($globalMarine) && $globalMarine) {
99 142
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
100 143
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
101 144
 }
102 145
 
103
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
146
+if (isset($globalTracker) && $globalTracker) {
147
+	$TI = new TrackerImport($Connection->db);
148
+}
104 149
 if (isset($globalMarine) && $globalMarine) {
105 150
     $AIS = new AIS();
106 151
     $MI = new MarineImport($Connection->db);
@@ -123,7 +168,9 @@  discard block
 block discarded – undo
123 168
 }
124 169
 
125 170
 // let's try and connect
126
-if ($globalDebug) echo "Connecting...\n";
171
+if ($globalDebug) {
172
+	echo "Connecting...\n";
173
+}
127 174
 $use_aprs = false;
128 175
 $aprs_full = false;
129 176
 $reset = 0;
@@ -132,7 +179,9 @@  discard block
 block discarded – undo
132 179
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
133 180
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
134 181
     $reset++;
135
-    if ($globalDebug) echo 'Connect to all...'."\n";
182
+    if ($globalDebug) {
183
+    	echo 'Connect to all...'."\n";
184
+    }
136 185
     foreach ($hosts as $id => $value) {
137 186
 	$host = $value['host'];
138 187
 	$globalSources[$id]['last_exec'] = 0;
@@ -142,22 +191,30 @@  discard block
 block discarded – undo
142 191
         	//$formats[$id] = 'deltadbtxt';
143 192
         	$globalSources[$id]['format'] = 'deltadbtxt';
144 193
         	//$last_exec['deltadbtxt'] = 0;
145
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
194
+        	if ($globalDebug) {
195
+        		echo "Connect to deltadb source (".$host.")...\n";
196
+        	}
146 197
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
147 198
         	//$formats[$id] = 'vatsimtxt';
148 199
         	$globalSources[$id]['format'] = 'vatsimtxt';
149 200
         	//$last_exec['vatsimtxt'] = 0;
150
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
201
+        	if ($globalDebug) {
202
+        		echo "Connect to vatsim source (".$host.")...\n";
203
+        	}
151 204
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
152 205
         	//$formats[$id] = 'aircraftlistjson';
153 206
         	$globalSources[$id]['format'] = 'aircraftlistjson';
154 207
         	//$last_exec['aircraftlistjson'] = 0;
155
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
208
+        	if ($globalDebug) {
209
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
210
+        	}
156 211
     	    } else if (preg_match('/opensky/i',$host)) {
157 212
         	//$formats[$id] = 'aircraftlistjson';
158 213
         	$globalSources[$id]['format'] = 'opensky';
159 214
         	//$last_exec['aircraftlistjson'] = 0;
160
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
215
+        	if ($globalDebug) {
216
+        		echo "Connect to opensky source (".$host.")...\n";
217
+        	}
161 218
     	    /*
162 219
     	    // Disabled for now, site change source format
163 220
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -174,7 +231,9 @@  discard block
 block discarded – undo
174 231
         	//$formats[$id] = 'planeupdatefaa';
175 232
         	$globalSources[$id]['format'] = 'planeupdatefaa';
176 233
         	//$last_exec['planeupdatefaa'] = 0;
177
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
234
+        	if ($globalDebug) {
235
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
236
+        	}
178 237
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
179 238
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
180 239
         	    exit(0);
@@ -183,32 +242,46 @@  discard block
 block discarded – undo
183 242
         	//$formats[$id] = 'phpvmacars';
184 243
         	$globalSources[$id]['format'] = 'phpvmacars';
185 244
         	//$last_exec['phpvmacars'] = 0;
186
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
245
+        	if ($globalDebug) {
246
+        		echo "Connect to phpvmacars source (".$host.")...\n";
247
+        	}
187 248
             } else if (preg_match('/VAM-json.php$/i',$host)) {
188 249
         	//$formats[$id] = 'phpvmacars';
189 250
         	$globalSources[$id]['format'] = 'vam';
190
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
251
+        	if ($globalDebug) {
252
+        		echo "Connect to Vam source (".$host.")...\n";
253
+        	}
191 254
             } else if (preg_match('/whazzup/i',$host)) {
192 255
         	//$formats[$id] = 'whazzup';
193 256
         	$globalSources[$id]['format'] = 'whazzup';
194 257
         	//$last_exec['whazzup'] = 0;
195
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
258
+        	if ($globalDebug) {
259
+        		echo "Connect to whazzup source (".$host.")...\n";
260
+        	}
196 261
             } else if (preg_match('/blitzortung/i',$host)) {
197 262
         	$globalSources[$id]['format'] = 'blitzortung';
198
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
263
+        	if ($globalDebug) {
264
+        		echo "Connect to blitzortung source (".$host.")...\n";
265
+        	}
199 266
             } else if (preg_match('/airwhere/i',$host)) {
200 267
         	$globalSources[$id]['format'] = 'airwhere';
201
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to airwhere source (".$host.")...\n";
270
+        	}
202 271
             } else if (preg_match('/recentpireps/i',$host)) {
203 272
         	//$formats[$id] = 'pirepsjson';
204 273
         	$globalSources[$id]['format'] = 'pirepsjson';
205 274
         	//$last_exec['pirepsjson'] = 0;
206
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
275
+        	if ($globalDebug) {
276
+        		echo "Connect to pirepsjson source (".$host.")...\n";
277
+        	}
207 278
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
208 279
         	//$formats[$id] = 'fr24json';
209 280
         	$globalSources[$id]['format'] = 'fr24json';
210 281
         	//$last_exec['fr24json'] = 0;
211
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
282
+        	if ($globalDebug) {
283
+        		echo "Connect to fr24 source (".$host.")...\n";
284
+        	}
212 285
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
213 286
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
214 287
         	    exit(0);
@@ -217,7 +290,9 @@  discard block
 block discarded – undo
217 290
         	//$formats[$id] = 'fr24json';
218 291
         	$globalSources[$id]['format'] = 'myshiptracking';
219 292
         	//$last_exec['fr24json'] = 0;
220
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
293
+        	if ($globalDebug) {
294
+        		echo "Connect to myshiptracking source (".$host.")...\n";
295
+        	}
221 296
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
222 297
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
223 298
         	    exit(0);
@@ -226,17 +301,24 @@  discard block
 block discarded – undo
226 301
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
227 302
         	//$formats[$id] = 'tsv';
228 303
         	$globalSources[$id]['format'] = 'tsv';
229
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
304
+        	if ($globalDebug) {
305
+        		echo "Connect to tsv source (".$host.")...\n";
306
+        	}
230 307
             }
231 308
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
232 309
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
233 310
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
234 311
     		    if ($idf !== false) {
235 312
     			$httpfeeds[$id] = $idf;
236
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
313
+        		if ($globalDebug) {
314
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
315
+        		}
316
+    		    } elseif ($globalDebug) {
317
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
237 318
     		    }
238
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
239
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
319
+    		} elseif ($globalDebug) {
320
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
321
+    		}
240 322
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
241 323
 	    $hostport = explode(':',$host);
242 324
 	    if (isset($hostport[1])) {
@@ -276,17 +358,25 @@  discard block
 block discarded – undo
276 358
         		//$formats[$id] = 'beast';
277 359
         		$globalSources[$id]['format'] = 'beast';
278 360
 		    //} else $formats[$id] = 'sbs';
279
-		    } else $globalSources[$id]['format'] = 'sbs';
361
+		    } else {
362
+		    	$globalSources[$id]['format'] = 'sbs';
363
+		    }
280 364
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
281 365
 		}
282
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
366
+		if ($globalDebug) {
367
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
368
+		}
283 369
             } else {
284
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
370
+		if ($globalDebug) {
371
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
372
+		}
285 373
     	    }
286 374
         }
287 375
     }
288 376
 }
289
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
377
+if (!isset($globalMinFetch)) {
378
+	$globalMinFetch = 15;
379
+}
290 380
 
291 381
 // Initialize all
292 382
 $status = array();
@@ -295,13 +385,19 @@  discard block
 block discarded – undo
295 385
 $formats = array();
296 386
 $last_exec = array();
297 387
 $time = time();
298
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
299
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
300
-else $timeout = 20;
388
+if (isset($globalSourcesTimeout)) {
389
+	$timeout = $globalSourcesTimeOut;
390
+} else if (isset($globalSBS1TimeOut)) {
391
+	$timeout = $globalSBS1TimeOut;
392
+} else {
393
+	$timeout = 20;
394
+}
301 395
 $errno = '';
302 396
 $errstr='';
303 397
 
304
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
398
+if (!isset($globalDaemon)) {
399
+	$globalDaemon = TRUE;
400
+}
305 401
 /* Initiate connections to all the hosts simultaneously */
306 402
 //connect_all($hosts);
307 403
 //connect_all($globalSources);
@@ -330,7 +426,9 @@  discard block
 block discarded – undo
330 426
     if (isset($source['format']) && $source['format'] == 'aprs') {
331 427
 	$aprs_connect = 0;
332 428
 	$use_aprs = true;
333
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
429
+	if (isset($source['port']) && $source['port'] == '10152') {
430
+		$aprs_full = true;
431
+	}
334 432
 	break;
335 433
     }
336 434
 }
@@ -341,25 +439,48 @@  discard block
 block discarded – undo
341 439
 	$aprs_connect = 0;
342 440
 	$aprs_keep = 120;
343 441
 	$aprs_last_tx = time();
344
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
345
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
346
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
347
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
348
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
349
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
350
-	if ($aprs_full) $aprs_filter = '';
351
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
352
-	else $aprs_pass = '-1';
442
+	if (isset($globalAPRSversion)) {
443
+		$aprs_version = $globalAPRSversion;
444
+	} else {
445
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
446
+	}
447
+	if (isset($globalAPRSssid)) {
448
+		$aprs_ssid = $globalAPRSssid;
449
+	} else {
450
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
451
+	}
452
+	if (isset($globalAPRSfilter)) {
453
+		$aprs_filter = $globalAPRSfilter;
454
+	} else {
455
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
456
+	}
457
+	if ($aprs_full) {
458
+		$aprs_filter = '';
459
+	}
460
+	if (isset($globalAPRSpass)) {
461
+		$aprs_pass = $globalAPRSpass;
462
+	} else {
463
+		$aprs_pass = '-1';
464
+	}
353 465
 
354
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
355
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
356
-}
466
+	if ($aprs_filter != '') {
467
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
468
+	} else {
469
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
470
+	}
471
+	}
357 472
 
358 473
 // connected - lets do some work
359
-if ($globalDebug) echo "Connected!\n";
474
+if ($globalDebug) {
475
+	echo "Connected!\n";
476
+}
360 477
 sleep(1);
361
-if ($globalDebug) echo "SCAN MODE \n\n";
362
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
478
+if ($globalDebug) {
479
+	echo "SCAN MODE \n\n";
480
+}
481
+if (!isset($globalCronEnd)) {
482
+	$globalCronEnd = 60;
483
+}
363 484
 $endtime = time()+$globalCronEnd;
364 485
 $i = 1;
365 486
 $tt = array();
@@ -373,20 +494,28 @@  discard block
 block discarded – undo
373 494
 
374 495
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
375 496
 while ($i > 0) {
376
-    if (!$globalDaemon) $i = $endtime-time();
497
+    if (!$globalDaemon) {
498
+    	$i = $endtime-time();
499
+    }
377 500
     // Delete old ATC
378 501
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
379
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
502
+	if ($globalDebug) {
503
+		echo 'Delete old ATC...'."\n";
504
+	}
380 505
         $ATC->deleteOldATC();
381 506
     }
382 507
     
383 508
     if (count($last_exec) == count($globalSources)) {
384 509
 	$max = $globalMinFetch;
385 510
 	foreach ($last_exec as $last) {
386
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
511
+	    if ((time() - $last['last']) < $max) {
512
+	    	$max = time() - $last['last'];
513
+	    }
387 514
 	}
388 515
 	if ($max != $globalMinFetch) {
389
-	    if ($globalDebug) echo 'Sleeping...'."\n";
516
+	    if ($globalDebug) {
517
+	    	echo 'Sleeping...'."\n";
518
+	    }
390 519
 	    sleep($globalMinFetch-$max+2);
391 520
 	}
392 521
     }
@@ -396,7 +525,9 @@  discard block
 block discarded – undo
396 525
     foreach ($globalSources as $id => $value) {
397 526
 	date_default_timezone_set('UTC');
398 527
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
399
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
528
+	if (!isset($last_exec[$id]['last'])) {
529
+		$last_exec[$id]['last'] = 0;
530
+	}
400 531
 	if ($value['format'] == 'deltadbtxt' && 
401 532
 	    (
402 533
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -405,7 +536,9 @@  discard block
 block discarded – undo
405 536
 	) {
406 537
 	    //$buffer = $Common->getData($hosts[$id]);
407 538
 	    $buffer = $Common->getData($value['host']);
408
-	    if ($buffer != '') $reset = 0;
539
+	    if ($buffer != '') {
540
+	    	$reset = 0;
541
+	    }
409 542
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
410 543
 	    $buffer = explode('\n',$buffer);
411 544
 	    foreach ($buffer as $line) {
@@ -414,20 +547,41 @@  discard block
 block discarded – undo
414 547
 	            $data = array();
415 548
 	            $data['hex'] = $line[1]; // hex
416 549
 	            $data['ident'] = $line[2]; // ident
417
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
418
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
419
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
420
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
421
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
550
+	            if (isset($line[3])) {
551
+	            	$data['altitude'] = $line[3];
552
+	            }
553
+	            // altitude
554
+	            if (isset($line[4])) {
555
+	            	$data['speed'] = $line[4];
556
+	            }
557
+	            // speed
558
+	            if (isset($line[5])) {
559
+	            	$data['heading'] = $line[5];
560
+	            }
561
+	            // heading
562
+	            if (isset($line[6])) {
563
+	            	$data['latitude'] = $line[6];
564
+	            }
565
+	            // lat
566
+	            if (isset($line[7])) {
567
+	            	$data['longitude'] = $line[7];
568
+	            }
569
+	            // long
422 570
 	            $data['verticalrate'] = ''; // vertical rate
423 571
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
424 572
 	            $data['emergency'] = ''; // emergency
425 573
 		    $data['datetime'] = date('Y-m-d H:i:s');
426 574
 		    $data['format_source'] = 'deltadbtxt';
427 575
     		    $data['id_source'] = $id_source;
428
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
429
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
430
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
576
+		    if (isset($value['name']) && $value['name'] != '') {
577
+		    	$data['source_name'] = $value['name'];
578
+		    }
579
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
580
+		    	$data['noarchive'] = true;
581
+		    }
582
+		    if (isset($value['sourcestats'])) {
583
+		    	$data['sourcestats'] = $value['sourcestats'];
584
+		    }
431 585
     		    $SI->add($data);
432 586
 		    unset($data);
433 587
     		}
@@ -442,7 +596,9 @@  discard block
 block discarded – undo
442 596
 	    date_default_timezone_set('CET');
443 597
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
444 598
 	    date_default_timezone_set('UTC');
445
-	    if ($buffer != '') $reset = 0;
599
+	    if ($buffer != '') {
600
+	    	$reset = 0;
601
+	    }
446 602
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
447 603
 	    $buffer = explode('\n',$buffer);
448 604
 	    foreach ($buffer as $line) {
@@ -451,16 +607,36 @@  discard block
 block discarded – undo
451 607
 		    $add = false;
452 608
 		    $ais_data = $AIS->parse_line(trim($line));
453 609
 		    $data = array();
454
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
455
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
456
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
457
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
458
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
459
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
460
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
461
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
462
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
463
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
610
+		    if (isset($ais_data['ident'])) {
611
+		    	$data['ident'] = $ais_data['ident'];
612
+		    }
613
+		    if (isset($ais_data['mmsi'])) {
614
+		    	$data['mmsi'] = $ais_data['mmsi'];
615
+		    }
616
+		    if (isset($ais_data['speed'])) {
617
+		    	$data['speed'] = $ais_data['speed'];
618
+		    }
619
+		    if (isset($ais_data['heading'])) {
620
+		    	$data['heading'] = $ais_data['heading'];
621
+		    }
622
+		    if (isset($ais_data['latitude'])) {
623
+		    	$data['latitude'] = $ais_data['latitude'];
624
+		    }
625
+		    if (isset($ais_data['longitude'])) {
626
+		    	$data['longitude'] = $ais_data['longitude'];
627
+		    }
628
+		    if (isset($ais_data['status'])) {
629
+		    	$data['status'] = $ais_data['status'];
630
+		    }
631
+		    if (isset($ais_data['type'])) {
632
+		    	$data['type'] = $ais_data['type'];
633
+		    }
634
+		    if (isset($ais_data['imo'])) {
635
+		    	$data['imo'] = $ais_data['imo'];
636
+		    }
637
+		    if (isset($ais_data['callsign'])) {
638
+		    	$data['callsign'] = $ais_data['callsign'];
639
+		    }
464 640
 		    if (isset($ais_data['timestamp'])) {
465 641
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
466 642
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -474,8 +650,12 @@  discard block
 block discarded – undo
474 650
 		    $data['format_source'] = 'aisnmeatxt';
475 651
     		    $data['id_source'] = $id_source;
476 652
 		    //print_r($data);
477
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
653
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
654
+		    	$data['noarchive'] = true;
655
+		    }
656
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
657
+		    	$MI->add($data);
658
+		    }
479 659
 		    unset($data);
480 660
 		}
481 661
     	    }
@@ -495,20 +675,48 @@  discard block
 block discarded – undo
495 675
 			    if ($line != '') {
496 676
 				$ais_data = $AIS->parse_line(trim($line));
497 677
 				$data = array();
498
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
499
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
500
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
501
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
502
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
503
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
504
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
505
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
506
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
507
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
508
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
509
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
510
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
511
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
678
+				if (isset($ais_data['ident'])) {
679
+					$data['ident'] = $ais_data['ident'];
680
+				}
681
+				if (isset($ais_data['mmsi'])) {
682
+					$data['mmsi'] = $ais_data['mmsi'];
683
+				}
684
+				if (isset($ais_data['speed'])) {
685
+					$data['speed'] = $ais_data['speed'];
686
+				}
687
+				if (isset($ais_data['heading'])) {
688
+					$data['heading'] = $ais_data['heading'];
689
+				}
690
+				if (isset($ais_data['latitude'])) {
691
+					$data['latitude'] = $ais_data['latitude'];
692
+				}
693
+				if (isset($ais_data['longitude'])) {
694
+					$data['longitude'] = $ais_data['longitude'];
695
+				}
696
+				if (isset($ais_data['status'])) {
697
+					$data['status'] = $ais_data['status'];
698
+				}
699
+				if (isset($ais_data['statusid'])) {
700
+					$data['status_id'] = $ais_data['statusid'];
701
+				}
702
+				if (isset($ais_data['type'])) {
703
+					$data['type'] = $ais_data['type'];
704
+				}
705
+				if (isset($ais_data['typeid'])) {
706
+					$data['type_id'] = $ais_data['typeid'];
707
+				}
708
+				if (isset($ais_data['imo'])) {
709
+					$data['imo'] = $ais_data['imo'];
710
+				}
711
+				if (isset($ais_data['callsign'])) {
712
+					$data['callsign'] = $ais_data['callsign'];
713
+				}
714
+				if (isset($ais_data['destination'])) {
715
+					$data['arrival_code'] = $ais_data['destination'];
716
+				}
717
+				if (isset($ais_data['eta_ts'])) {
718
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
719
+				}
512 720
 				if (isset($ais_data['timestamp'])) {
513 721
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
514 722
 				} else {
@@ -516,18 +724,27 @@  discard block
 block discarded – undo
516 724
 				}
517 725
 				$data['format_source'] = 'aisnmeahttp';
518 726
 				$data['id_source'] = $id_source;
519
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
727
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
728
+					$data['noarchive'] = true;
729
+				}
730
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
731
+					$MI->add($data);
732
+				}
521 733
 				unset($data);
522 734
 			    }
523 735
 			}
524 736
 		    }
525 737
 		} else {
526 738
 		    $format = $value['format'];
527
-		    if (isset($tt[$format])) $tt[$format]++;
528
-		    else $tt[$format] = 0;
739
+		    if (isset($tt[$format])) {
740
+		    	$tt[$format]++;
741
+		    } else {
742
+		    	$tt[$format] = 0;
743
+		    }
529 744
 		    if ($tt[$format] > 30) {
530
-			if ($globalDebug) echo 'Reconnect...'."\n";
745
+			if ($globalDebug) {
746
+				echo 'Reconnect...'."\n";
747
+			}
531 748
 			sleep(2);
532 749
 			$sourceeen[] = $value;
533 750
 			connect_all($sourceeen);
@@ -562,7 +779,9 @@  discard block
 block discarded – undo
562 779
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
563 780
 			    $data['format_source'] = 'myshiptracking';
564 781
 			    $data['id_source'] = $id_source;
565
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
782
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
783
+			    	$data['noarchive'] = true;
784
+			    }
566 785
 			    $MI->add($data);
567 786
 			    unset($data);
568 787
 			}
@@ -587,7 +806,9 @@  discard block
 block discarded – undo
587 806
 			    $data['callsign'] = $line['callsign'];
588 807
 			    $data['mmsi'] = $line['mmsi'];
589 808
 			    $data['speed'] = $line['sog'];
590
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
809
+			    if ($line['heading'] != '511') {
810
+			    	$data['heading'] = $line['heading'];
811
+			    }
591 812
 			    $data['latitude'] = $line['latitude'];
592 813
 			    $data['longitude'] = $line['longitude'];
593 814
 			    $data['type_id'] = $line['shiptype'];
@@ -595,7 +816,9 @@  discard block
 block discarded – undo
595 816
 			    $data['datetime'] = $line['time'];
596 817
 			    $data['format_source'] = 'boatbeaconapp';
597 818
 			    $data['id_source'] = $id_source;
598
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
819
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
820
+			    	$data['noarchive'] = true;
821
+			    }
599 822
 			    $MI->add($data);
600 823
 			    unset($data);
601 824
 			}
@@ -616,22 +839,44 @@  discard block
 block discarded – undo
616 839
 		if (isset($all_data['features'][0]['id'])) {
617 840
 		    foreach ($all_data['features'] as $line) {
618 841
 			$data = array();
619
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
620
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
621
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
622
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
623
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
624
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
842
+			if (isset($line['properties']['name'])) {
843
+				$data['ident'] = $line['properties']['name'];
844
+			}
845
+			if (isset($line['properties']['callsign'])) {
846
+				$data['callsign'] = $line['properties']['callsign'];
847
+			}
848
+			if (isset($line['properties']['mmsi'])) {
849
+				$data['mmsi'] = $line['properties']['mmsi'];
850
+			}
851
+			if (isset($line['properties']['imo'])) {
852
+				$data['mmsi'] = $line['properties']['imo'];
853
+			}
854
+			if (isset($line['properties']['speed'])) {
855
+				$data['speed'] = $line['properties']['speed'];
856
+			}
857
+			if (isset($line['properties']['heading'])) {
858
+				$data['heading'] = $line['properties']['heading'];
859
+			}
625 860
 			$data['latitude'] = $line['geometry']['coordinates'][1];
626 861
 			$data['longitude'] = $line['geometry']['coordinates'][0];
627
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
628
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
629
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
862
+			if (isset($line['properties']['vesselType'])) {
863
+				$data['type'] = $line['properties']['vesselType'];
864
+			}
865
+			if (isset($line['properties']['destination'])) {
866
+				$data['arrival_code'] = $line['properties']['destination'];
867
+			}
868
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
869
+				$data['arrival_date'] = $line['properties']['eta'];
870
+			}
630 871
 			$data['format_source'] = 'boatnerd';
631 872
 			$data['id_source'] = $id_source;
632 873
 			$data['datetime'] = date('Y-m-d H:i:s');
633
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
634
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
874
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
875
+				$data['noarchive'] = true;
876
+			}
877
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
878
+				$MI->add($data);
879
+			}
635 880
 			unset($data);
636 881
 		    }
637 882
 		}
@@ -647,7 +892,9 @@  discard block
 block discarded – undo
647 892
 	    echo 'download...';
648 893
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
649 894
 	    echo 'done !'."\n";
650
-	    if ($buffer != '') $reset = 0;
895
+	    if ($buffer != '') {
896
+	    	$reset = 0;
897
+	    }
651 898
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
652 899
 	    $buffer = explode('\n',$buffer);
653 900
 	    foreach ($buffer as $line) {
@@ -672,7 +919,9 @@  discard block
 block discarded – undo
672 919
 		    //$data['etaTime'] = substr($line,135,5);
673 920
 		    $data['format_source'] = 'shipplotter';
674 921
     		    $data['id_source'] = $id_source;
675
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
922
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
923
+		    	$data['noarchive'] = true;
924
+		    }
676 925
 		    //print_r($data);
677 926
 		    echo 'Add...'."\n";
678 927
 		    $MI->add($data);
@@ -706,16 +955,28 @@  discard block
 block discarded – undo
706 955
     		    $line = explode(':', $line);
707 956
     		    if (count($line) > 30 && $line[0] != 'callsign') {
708 957
 			$data = array();
709
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
710
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
958
+			if (isset($line[37]) && $line[37] != '') {
959
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
960
+			} else {
961
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
962
+			}
711 963
 			$data['pilot_id'] = $line[1];
712 964
 			$data['pilot_name'] = $line[2];
713 965
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
714 966
 			$data['ident'] = $line[0]; // ident
715
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
967
+			if ($line[7] != '' && $line[7] != 0) {
968
+				$data['altitude'] = $line[7];
969
+			}
970
+			// altitude
716 971
 			$data['speed'] = $line[8]; // speed
717
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
718
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
972
+			if (isset($line[45])) {
973
+				$data['heading'] = $line[45];
974
+			}
975
+			// heading
976
+			elseif (isset($line[38])) {
977
+				$data['heading'] = $line[38];
978
+			}
979
+			// heading
719 980
 			$data['latitude'] = $line[5]; // lat
720 981
 	        	$data['longitude'] = $line[6]; // long
721 982
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -731,7 +992,9 @@  discard block
 block discarded – undo
731 992
 			$data['frequency'] = $line[4];
732 993
 			$data['type'] = $line[18];
733 994
 			$data['range'] = $line[19];
734
-			if (isset($line[35])) $data['info'] = $line[35];
995
+			if (isset($line[35])) {
996
+				$data['info'] = $line[35];
997
+			}
735 998
     			$data['id_source'] = $id_source;
736 999
 	    		//$data['arrival_airport_time'] = ;
737 1000
 	    		if ($line[9] != '') {
@@ -745,27 +1008,47 @@  discard block
 block discarded – undo
745 1008
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
746 1009
 	    		*/
747 1010
 	    		$data['format_source'] = $value['format'];
748
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
749
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
750
-    			if ($line[3] == 'PILOT') $SI->add($data);
751
-			elseif ($line[3] == 'ATC') {
1011
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1012
+				$data['noarchive'] = true;
1013
+			}
1014
+			if (isset($value['name']) && $value['name'] != '') {
1015
+				$data['source_name'] = $value['name'];
1016
+			}
1017
+    			if ($line[3] == 'PILOT') {
1018
+    				$SI->add($data);
1019
+    			} elseif ($line[3] == 'ATC') {
752 1020
 				//print_r($data);
753 1021
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
754 1022
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
755 1023
 				$typec = substr($data['ident'],-3);
756
-				if ($typec == 'APP') $data['type'] = 'Approach';
757
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
758
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
759
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
760
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
761
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
762
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
763
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
764
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
765
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1024
+				if ($typec == 'APP') {
1025
+					$data['type'] = 'Approach';
1026
+				} elseif ($typec == 'TWR') {
1027
+					$data['type'] = 'Tower';
1028
+				} elseif ($typec == 'OBS') {
1029
+					$data['type'] = 'Observer';
1030
+				} elseif ($typec == 'GND') {
1031
+					$data['type'] = 'Ground';
1032
+				} elseif ($typec == 'DEL') {
1033
+					$data['type'] = 'Delivery';
1034
+				} elseif ($typec == 'DEP') {
1035
+					$data['type'] = 'Departure';
1036
+				} elseif ($typec == 'FSS') {
1037
+					$data['type'] = 'Flight Service Station';
1038
+				} elseif ($typec == 'CTR') {
1039
+					$data['type'] = 'Control Radar or Centre';
1040
+				} elseif ($data['type'] == '') {
1041
+					$data['type'] = 'Observer';
1042
+				}
1043
+				if (!isset($data['source_name'])) {
1044
+					$data['source_name'] = '';
1045
+				}
766 1046
 				if (isset($ATC)) {
767
-					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']);
768
-					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']);
1047
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1048
+						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']);
1049
+					} else {
1050
+						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']);
1051
+					}
769 1052
 				}
770 1053
 			}
771 1054
     			unset($data);
@@ -792,14 +1075,20 @@  discard block
 block discarded – undo
792 1075
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
793 1076
 			$data['latitude'] = (float)$line['pktLatitude'];
794 1077
 			$data['longitude'] = (float)$line['pktLongitude'];
795
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
796
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1078
+			if ((float)$line['pktTrack'] != 0) {
1079
+				$data['heading'] = (float)$line['pktTrack'];
1080
+			}
1081
+			if ((int)$line['pktSpeed'] != 0) {
1082
+				$data['speed'] = (int)$line['pktSpeed'];
1083
+			}
797 1084
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
798 1085
 			$data['altitude_relative'] = 'AMSL';
799 1086
 			$data['pilot_id'] = (int)$line['pktPilotID'];
800 1087
 			$data['aircraft_icao'] = 'PARAGLIDER';
801 1088
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
802
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1089
+			if (isset($pilot_data[4])) {
1090
+				$data['pilot_name'] = $pilot_data[4];
1091
+			}
803 1092
 			$data['format_source'] = $value['format'];
804 1093
 			$SI->add($data);
805 1094
 			unset($data);
@@ -847,25 +1136,59 @@  discard block
 block discarded – undo
847 1136
 		    foreach ($all_data['acList'] as $line) {
848 1137
 			$data = array();
849 1138
 			$data['hex'] = $line['Icao']; // hex
850
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
851
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
852
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
853
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
854
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
855
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1139
+			if (isset($line['Call'])) {
1140
+				$data['ident'] = $line['Call'];
1141
+			}
1142
+			// ident
1143
+			if (isset($line['Alt'])) {
1144
+				$data['altitude'] = $line['Alt'];
1145
+			}
1146
+			// altitude
1147
+			if (isset($line['Spd'])) {
1148
+				$data['speed'] = $line['Spd'];
1149
+			}
1150
+			// speed
1151
+			if (isset($line['Trak'])) {
1152
+				$data['heading'] = $line['Trak'];
1153
+			}
1154
+			// heading
1155
+			if (isset($line['Lat'])) {
1156
+				$data['latitude'] = $line['Lat'];
1157
+			}
1158
+			// lat
1159
+			if (isset($line['Long'])) {
1160
+				$data['longitude'] = $line['Long'];
1161
+			}
1162
+			// long
856 1163
 			//$data['verticalrate'] = $line['']; // verticale rate
857
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1164
+			if (isset($line['Sqk'])) {
1165
+				$data['squawk'] = $line['Sqk'];
1166
+			}
1167
+			// squawk
858 1168
 			$data['emergency'] = ''; // emergency
859
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
860
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
861
-			else $data['datetime'] = date('Y-m-d H:i:s');
1169
+			if (isset($line['Reg'])) {
1170
+				$data['registration'] = $line['Reg'];
1171
+			}
1172
+			if (isset($line['PosTime'])) {
1173
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1174
+			} else {
1175
+				$data['datetime'] = date('Y-m-d H:i:s');
1176
+			}
862 1177
 			//$data['datetime'] = date('Y-m-d H:i:s');
863
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1178
+			if (isset($line['Type'])) {
1179
+				$data['aircraft_icao'] = $line['Type'];
1180
+			}
864 1181
 			$data['format_source'] = 'aircraftlistjson';
865 1182
 			$data['id_source'] = $id_source;
866
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
867
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
868
-			if (isset($data['latitude'])) $SI->add($data);
1183
+			if (isset($value['name']) && $value['name'] != '') {
1184
+				$data['source_name'] = $value['name'];
1185
+			}
1186
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1187
+				$data['noarchive'] = true;
1188
+			}
1189
+			if (isset($data['latitude'])) {
1190
+				$SI->add($data);
1191
+			}
869 1192
 			unset($data);
870 1193
 		    }
871 1194
 		} elseif (is_array($all_data)) {
@@ -882,17 +1205,26 @@  discard block
 block discarded – undo
882 1205
 			$data['verticalrate'] = $line['vrt']; // verticale rate
883 1206
 			$data['squawk'] = $line['squawk']; // squawk
884 1207
 			$data['emergency'] = ''; // emergency
885
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
886
-			else $data['datetime'] = date('Y-m-d H:i:s');
1208
+			if (isset($line['PosTime'])) {
1209
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1210
+			} else {
1211
+				$data['datetime'] = date('Y-m-d H:i:s');
1212
+			}
887 1213
 			$data['format_source'] = 'aircraftlistjson';
888 1214
 			$data['id_source'] = $id_source;
889
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
890
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1215
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1216
+				$data['noarchive'] = true;
1217
+			}
1218
+			if (isset($value['name']) && $value['name'] != '') {
1219
+				$data['source_name'] = $value['name'];
1220
+			}
891 1221
 			$SI->add($data);
892 1222
 			unset($data);
893 1223
 		    }
894 1224
 		}
895
-	    } elseif ($globalDebug) echo 'No data'."\n";
1225
+	    } elseif ($globalDebug) {
1226
+	    	echo 'No data'."\n";
1227
+	    }
896 1228
     	    //$last_exec['aircraftlistjson'] = time();
897 1229
     	    $last_exec[$id]['last'] = time();
898 1230
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -928,8 +1260,12 @@  discard block
 block discarded – undo
928 1260
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
929 1261
 	    	    $data['format_source'] = 'planeupdatefaa';
930 1262
     		    $data['id_source'] = $id_source;
931
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
932
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1263
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1264
+		    	$data['noarchive'] = true;
1265
+		    }
1266
+		    if (isset($value['name']) && $value['name'] != '') {
1267
+		    	$data['source_name'] = $value['name'];
1268
+		    }
933 1269
 		    $SI->add($data);
934 1270
 		    unset($data);
935 1271
 		}
@@ -963,7 +1299,9 @@  discard block
 block discarded – undo
963 1299
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
964 1300
 		    $data['format_source'] = 'opensky';
965 1301
 		    $data['id_source'] = $id_source;
966
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1302
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1303
+		    	$data['noarchive'] = true;
1304
+		    }
967 1305
 		    $SI->add($data);
968 1306
 		    unset($data);
969 1307
 		}
@@ -980,7 +1318,9 @@  discard block
 block discarded – undo
980 1318
 	    //$buffer = $Common->getData($hosts[$id]);
981 1319
 	    $buffer = $Common->getData($value['host']);
982 1320
 	    $all_data = json_decode($buffer,true);
983
-	    if (!empty($all_data)) $reset = 0;
1321
+	    if (!empty($all_data)) {
1322
+	    	$reset = 0;
1323
+	    }
984 1324
 	    foreach ($all_data as $key => $line) {
985 1325
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
986 1326
 		    $data = array();
@@ -1001,8 +1341,12 @@  discard block
 block discarded – undo
1001 1341
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1002 1342
 	    	    $data['format_source'] = 'fr24json';
1003 1343
     		    $data['id_source'] = $id_source;
1004
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1005
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1344
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1345
+		    	$data['noarchive'] = true;
1346
+		    }
1347
+		    if (isset($value['name']) && $value['name'] != '') {
1348
+		    	$data['source_name'] = $value['name'];
1349
+		    }
1006 1350
 		    $SI->add($data);
1007 1351
 		    unset($data);
1008 1352
 		}
@@ -1031,24 +1375,42 @@  discard block
 block discarded – undo
1031 1375
 		    if (isset($line['inf'])) {
1032 1376
 			$data = array();
1033 1377
 			$data['hex'] = $line['inf']['ia'];
1034
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1378
+			if (isset($line['inf']['cs'])) {
1379
+				$data['ident'] = $line['inf']['cs'];
1380
+			}
1381
+			//$line[13]
1035 1382
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1036
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1037
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1383
+	    		if (isset($line['inf']['gs'])) {
1384
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1385
+	    		}
1386
+	    		// speed
1387
+	    		if (isset($line['inf']['tr'])) {
1388
+	    			$data['heading'] = $line['inf']['tr'];
1389
+	    		}
1390
+	    		// heading
1038 1391
 	    		$data['latitude'] = $line['pt'][0]; // lat
1039 1392
 	    		$data['longitude'] = $line['pt'][1]; // long
1040 1393
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1041
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1394
+	    		if (isset($line['inf']['sq'])) {
1395
+	    			$data['squawk'] = $line['inf']['sq'];
1396
+	    		}
1397
+	    		// squawk
1042 1398
 	    		//$data['aircraft_icao'] = $line[8];
1043
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1399
+	    		if (isset($line['inf']['rc'])) {
1400
+	    			$data['registration'] = $line['inf']['rc'];
1401
+	    		}
1044 1402
 			//$data['departure_airport_iata'] = $line[11];
1045 1403
 			//$data['arrival_airport_iata'] = $line[12];
1046 1404
 	    		//$data['emergency'] = ''; // emergency
1047 1405
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1048 1406
 	    		$data['format_source'] = 'radarvirtueljson';
1049 1407
     			$data['id_source'] = $id_source;
1050
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1051
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1408
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1409
+				$data['noarchive'] = true;
1410
+			}
1411
+			if (isset($value['name']) && $value['name'] != '') {
1412
+				$data['source_name'] = $value['name'];
1413
+			}
1052 1414
 			$SI->add($data);
1053 1415
 			unset($data);
1054 1416
 		    }
@@ -1074,30 +1436,65 @@  discard block
 block discarded – undo
1074 1436
 		    $data['id'] = $line['id'];
1075 1437
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1076 1438
 		    $data['ident'] = $line['callsign']; // ident
1077
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1078
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1079
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1080
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1081
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1082
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1439
+		    if (isset($line['pilotid'])) {
1440
+		    	$data['pilot_id'] = $line['pilotid'];
1441
+		    }
1442
+		    // pilot id
1443
+		    if (isset($line['name'])) {
1444
+		    	$data['pilot_name'] = $line['name'];
1445
+		    }
1446
+		    // pilot name
1447
+		    if (isset($line['alt'])) {
1448
+		    	$data['altitude'] = $line['alt'];
1449
+		    }
1450
+		    // altitude
1451
+		    if (isset($line['gs'])) {
1452
+		    	$data['speed'] = $line['gs'];
1453
+		    }
1454
+		    // speed
1455
+		    if (isset($line['heading'])) {
1456
+		    	$data['heading'] = $line['heading'];
1457
+		    }
1458
+		    // heading
1459
+		    if (isset($line['route'])) {
1460
+		    	$data['waypoints'] = $line['route'];
1461
+		    }
1462
+		    // route
1083 1463
 		    $data['latitude'] = $line['lat']; // lat
1084 1464
 		    $data['longitude'] = $line['lon']; // long
1085 1465
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1086 1466
 		    //$data['squawk'] = $line['squawk']; // squawk
1087 1467
 		    //$data['emergency'] = ''; // emergency
1088
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1089
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1090
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1468
+		    if (isset($line['depicao'])) {
1469
+		    	$data['departure_airport_icao'] = $line['depicao'];
1470
+		    }
1471
+		    if (isset($line['deptime'])) {
1472
+		    	$data['departure_airport_time'] = $line['deptime'];
1473
+		    }
1474
+		    if (isset($line['arricao'])) {
1475
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1476
+		    }
1091 1477
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1092
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1093
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1094
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1095
-		    else $data['info'] = '';
1478
+		    if (isset($line['aircraft'])) {
1479
+		    	$data['aircraft_icao'] = $line['aircraft'];
1480
+		    }
1481
+		    if (isset($line['transponder'])) {
1482
+		    	$data['squawk'] = $line['transponder'];
1483
+		    }
1484
+		    if (isset($line['atis'])) {
1485
+		    	$data['info'] = $line['atis'];
1486
+		    } else {
1487
+		    	$data['info'] = '';
1488
+		    }
1096 1489
 		    $data['format_source'] = 'pireps';
1097 1490
     		    $data['id_source'] = $id_source;
1098 1491
 		    $data['datetime'] = date('Y-m-d H:i:s');
1099
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1100
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1492
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1493
+		    	$data['noarchive'] = true;
1494
+		    }
1495
+		    if (isset($value['name']) && $value['name'] != '') {
1496
+		    	$data['source_name'] = $value['name'];
1497
+		    }
1101 1498
 		    if ($line['icon'] == 'plane') {
1102 1499
 			$SI->add($data);
1103 1500
 		    //    print_r($data);
@@ -1106,16 +1503,28 @@  discard block
 block discarded – undo
1106 1503
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1107 1504
 			$typec = substr($data['ident'],-3);
1108 1505
 			$data['type'] = '';
1109
-			if ($typec == 'APP') $data['type'] = 'Approach';
1110
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1111
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1112
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1113
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1114
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1115
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1116
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1117
-			else $data['type'] = 'Observer';
1118
-			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']);
1506
+			if ($typec == 'APP') {
1507
+				$data['type'] = 'Approach';
1508
+			} elseif ($typec == 'TWR') {
1509
+				$data['type'] = 'Tower';
1510
+			} elseif ($typec == 'OBS') {
1511
+				$data['type'] = 'Observer';
1512
+			} elseif ($typec == 'GND') {
1513
+				$data['type'] = 'Ground';
1514
+			} elseif ($typec == 'DEL') {
1515
+				$data['type'] = 'Delivery';
1516
+			} elseif ($typec == 'DEP') {
1517
+				$data['type'] = 'Departure';
1518
+			} elseif ($typec == 'FSS') {
1519
+				$data['type'] = 'Flight Service Station';
1520
+			} elseif ($typec == 'CTR') {
1521
+				$data['type'] = 'Control Radar or Centre';
1522
+			} else {
1523
+				$data['type'] = 'Observer';
1524
+			}
1525
+			if (isset($ATC)) {
1526
+				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']);
1527
+			}
1119 1528
 		    }
1120 1529
 		    unset($data);
1121 1530
 		}
@@ -1130,7 +1539,9 @@  discard block
 block discarded – undo
1130 1539
 	    )
1131 1540
 	) {
1132 1541
 	    //$buffer = $Common->getData($hosts[$id]);
1133
-	    if ($globalDebug) echo 'Get Data...'."\n";
1542
+	    if ($globalDebug) {
1543
+	    	echo 'Get Data...'."\n";
1544
+	    }
1134 1545
 	    $buffer = $Common->getData($value['host']);
1135 1546
 	    $all_data = json_decode($buffer,true);
1136 1547
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1138,10 +1549,16 @@  discard block
 block discarded – undo
1138 1549
 		foreach ($all_data as $line) {
1139 1550
 	    	    $data = array();
1140 1551
 	    	    //$data['id'] = $line['id']; // id not usable
1141
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1552
+	    	    if (isset($line['pilotid'])) {
1553
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1554
+	    	    }
1142 1555
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1143
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1144
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1556
+	    	    if (isset($line['pilotname'])) {
1557
+	    	    	$data['pilot_name'] = $line['pilotname'];
1558
+	    	    }
1559
+	    	    if (isset($line['pilotid'])) {
1560
+	    	    	$data['pilot_id'] = $line['pilotid'];
1561
+	    	    }
1145 1562
 	    	    $data['ident'] = $line['flightnum']; // ident
1146 1563
 	    	    $data['altitude'] = $line['alt']; // altitude
1147 1564
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1157,34 +1574,52 @@  discard block
 block discarded – undo
1157 1574
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1158 1575
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1159 1576
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1160
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1577
+	    	    } else {
1578
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1579
+	    	    }
1161 1580
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1162 1581
 	    	    $data['departure_airport_time'] = $line['deptime'];
1163 1582
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1164 1583
     		    $data['arrival_airport_time'] = $line['arrtime'];
1165 1584
     		    $data['registration'] = $line['aircraft'];
1166
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1167
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1585
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1586
+		    	$data['noarchive'] = true;
1587
+		    }
1588
+		    if (isset($line['route'])) {
1589
+		    	$data['waypoints'] = $line['route'];
1590
+		    }
1591
+		    // route
1168 1592
 		    if (isset($line['aircraftname'])) {
1169 1593
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1170 1594
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1171 1595
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1172
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1173
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1174
-	    		else {
1596
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1597
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1598
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1599
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1600
+	    		} else {
1175 1601
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1176
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1177
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1602
+	    		    if (isset($aircraft_data[1])) {
1603
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1604
+	    		    } else {
1605
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1606
+	    		    }
1178 1607
 	    		}
1179 1608
 	    	    }
1180
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1609
+    		    if (isset($line['route'])) {
1610
+    		    	$data['waypoints'] = $line['route'];
1611
+    		    }
1181 1612
     		    $data['id_source'] = $id_source;
1182 1613
 	    	    $data['format_source'] = 'phpvmacars';
1183
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1614
+		    if (isset($value['name']) && $value['name'] != '') {
1615
+		    	$data['source_name'] = $value['name'];
1616
+		    }
1184 1617
 		    $SI->add($data);
1185 1618
 		    unset($data);
1186 1619
 		}
1187
-		if ($globalDebug) echo 'No more data...'."\n";
1620
+		if ($globalDebug) {
1621
+			echo 'No more data...'."\n";
1622
+		}
1188 1623
 		unset($buffer);
1189 1624
 		unset($all_data);
1190 1625
 	    }
@@ -1197,7 +1632,9 @@  discard block
 block discarded – undo
1197 1632
 	    )
1198 1633
 	) {
1199 1634
 	    //$buffer = $Common->getData($hosts[$id]);
1200
-	    if ($globalDebug) echo 'Get Data...'."\n";
1635
+	    if ($globalDebug) {
1636
+	    	echo 'Get Data...'."\n";
1637
+	    }
1201 1638
 	    $buffer = $Common->getData($value['host']);
1202 1639
 	    $all_data = json_decode($buffer,true);
1203 1640
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1226,16 +1663,25 @@  discard block
 block discarded – undo
1226 1663
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1227 1664
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1228 1665
     		    //$data['registration'] = $line['aircraft'];
1229
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1666
+		    if (isset($line['route'])) {
1667
+		    	$data['waypoints'] = $line['route'];
1668
+		    }
1669
+		    // route
1230 1670
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1231 1671
     		    $data['id_source'] = $id_source;
1232 1672
 	    	    $data['format_source'] = 'vam';
1233
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1234
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1673
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1674
+		    	$data['noarchive'] = true;
1675
+		    }
1676
+		    if (isset($value['name']) && $value['name'] != '') {
1677
+		    	$data['source_name'] = $value['name'];
1678
+		    }
1235 1679
 		    $SI->add($data);
1236 1680
 		    unset($data);
1237 1681
 		}
1238
-		if ($globalDebug) echo 'No more data...'."\n";
1682
+		if ($globalDebug) {
1683
+			echo 'No more data...'."\n";
1684
+		}
1239 1685
 		unset($buffer);
1240 1686
 		unset($all_data);
1241 1687
 	    }
@@ -1248,7 +1694,9 @@  discard block
 block discarded – undo
1248 1694
 	    )
1249 1695
 	) {
1250 1696
 	    //$buffer = $Common->getData($hosts[$id]);
1251
-	    if ($globalDebug) echo 'Get Data...'."\n";
1697
+	    if ($globalDebug) {
1698
+	    	echo 'Get Data...'."\n";
1699
+	    }
1252 1700
 	    $buffer = $Common->getData($value['host']);
1253 1701
 	    $all_data = json_decode($buffer,true);
1254 1702
 	    if ($buffer != '') {
@@ -1266,18 +1714,24 @@  discard block
 block discarded – undo
1266 1714
 			$data['id_source'] = $id_source;
1267 1715
 			$data['format_source'] = 'blitzortung';
1268 1716
 			$SI->add($data);
1269
-			if ($globalDebug) echo '☈ Lightning added'."\n";
1717
+			if ($globalDebug) {
1718
+				echo '☈ Lightning added'."\n";
1719
+			}
1270 1720
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1271 1721
 			unset($data);
1272 1722
 		    }
1273 1723
 		}
1274
-		if ($globalDebug) echo 'No more data...'."\n";
1724
+		if ($globalDebug) {
1725
+			echo 'No more data...'."\n";
1726
+		}
1275 1727
 		unset($buffer);
1276 1728
 	    }
1277 1729
 	    $last_exec[$id]['last'] = time();
1278 1730
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1279 1731
 	} 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') {
1280
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1732
+	    if (function_exists('pcntl_fork')) {
1733
+	    	pcntl_signal_dispatch();
1734
+	    }
1281 1735
     	    //$last_exec[$id]['last'] = time();
1282 1736
 
1283 1737
 	    //$read = array( $sockets[$id] );
@@ -1285,7 +1739,9 @@  discard block
 block discarded – undo
1285 1739
 	    $write = NULL;
1286 1740
 	    $e = NULL;
1287 1741
 	    $n = socket_select($read, $write, $e, $timeout);
1288
-	    if ($e != NULL) var_dump($e);
1742
+	    if ($e != NULL) {
1743
+	    	var_dump($e);
1744
+	    }
1289 1745
 	    if ($n > 0) {
1290 1746
 		$reset = 0;
1291 1747
 		foreach ($read as $nb => $r) {
@@ -1306,12 +1762,16 @@  discard block
 block discarded – undo
1306 1762
 		    //$SI::del();
1307 1763
 		    if ($format == 'vrstcp') {
1308 1764
 			$buffer = explode('},{',$buffer);
1309
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1765
+		    } else {
1766
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1767
+		    }
1310 1768
 		    // SBS format is CSV format
1311 1769
 		    if ($buffer !== FALSE && $buffer != '') {
1312 1770
 			$tt[$format] = 0;
1313 1771
 			if ($format == 'acarssbs3') {
1314
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1772
+			    if ($globalDebug) {
1773
+			    	echo 'ACARS : '.$buffer."\n";
1774
+			    }
1315 1775
 			    $ACARS->add(trim($buffer));
1316 1776
 			    $ACARS->deleteLiveAcarsData();
1317 1777
 			} elseif ($format == 'raw') {
@@ -1320,30 +1780,70 @@  discard block
 block discarded – undo
1320 1780
 			    if (is_array($data)) {
1321 1781
 				$data['datetime'] = date('Y-m-d H:i:s');
1322 1782
 				$data['format_source'] = 'raw';
1323
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1324
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1325
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1326
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1783
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1784
+					$data['source_name'] = $globalSources[$nb]['name'];
1785
+				}
1786
+				if (isset($globalSources[$nb]['sourcestats'])) {
1787
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1788
+				}
1789
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1790
+					$data['noarchive'] = true;
1791
+				}
1792
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1793
+					$SI->add($data);
1794
+				}
1327 1795
 			    }
1328 1796
 			} elseif ($format == 'ais') {
1329 1797
 			    $ais_data = $AIS->parse_line(trim($buffer));
1330 1798
 			    $data = array();
1331
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1332
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1333
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1334
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1335
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1336
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1337
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1338
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1339
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1340
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1341
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1342
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1343
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1344
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1345
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1346
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1799
+			    if (isset($ais_data['ident'])) {
1800
+			    	$data['ident'] = $ais_data['ident'];
1801
+			    }
1802
+			    if (isset($ais_data['mmsi'])) {
1803
+			    	$data['mmsi'] = $ais_data['mmsi'];
1804
+			    }
1805
+			    if (isset($ais_data['speed'])) {
1806
+			    	$data['speed'] = $ais_data['speed'];
1807
+			    }
1808
+			    if (isset($ais_data['heading'])) {
1809
+			    	$data['heading'] = $ais_data['heading'];
1810
+			    }
1811
+			    if (isset($ais_data['latitude'])) {
1812
+			    	$data['latitude'] = $ais_data['latitude'];
1813
+			    }
1814
+			    if (isset($ais_data['longitude'])) {
1815
+			    	$data['longitude'] = $ais_data['longitude'];
1816
+			    }
1817
+			    if (isset($ais_data['status'])) {
1818
+			    	$data['status'] = $ais_data['status'];
1819
+			    }
1820
+			    if (isset($ais_data['statusid'])) {
1821
+			    	$data['status_id'] = $ais_data['statusid'];
1822
+			    }
1823
+			    if (isset($ais_data['type'])) {
1824
+			    	$data['type'] = $ais_data['type'];
1825
+			    }
1826
+			    if (isset($ais_data['imo'])) {
1827
+			    	$data['imo'] = $ais_data['imo'];
1828
+			    }
1829
+			    if (isset($ais_data['callsign'])) {
1830
+			    	$data['callsign'] = $ais_data['callsign'];
1831
+			    }
1832
+			    if (isset($ais_data['destination'])) {
1833
+			    	$data['arrival_code'] = $ais_data['destination'];
1834
+			    }
1835
+			    if (isset($ais_data['eta_ts'])) {
1836
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1837
+			    }
1838
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1839
+			    	$data['noarchive'] = true;
1840
+			    }
1841
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1842
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1843
+			    }
1844
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1845
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1846
+			    }
1347 1847
 
1348 1848
 			    if (isset($ais_data['timestamp'])) {
1349 1849
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1352,7 +1852,9 @@  discard block
 block discarded – undo
1352 1852
 			    }
1353 1853
 			    $data['format_source'] = 'aisnmea';
1354 1854
     			    $data['id_source'] = $id_source;
1355
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1855
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1856
+			    	$MI->add($data);
1857
+			    }
1356 1858
 			    unset($data);
1357 1859
                         } elseif ($format == 'flightgearsp') {
1358 1860
                     	    //echo $buffer."\n";
@@ -1370,12 +1872,18 @@  discard block
 block discarded – undo
1370 1872
 				$data['speed'] = round($line[5]*1.94384);
1371 1873
 				$data['datetime'] = date('Y-m-d H:i:s');
1372 1874
 				$data['format_source'] = 'flightgearsp';
1373
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1374
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1875
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1876
+					$data['noarchive'] = true;
1877
+				}
1878
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1879
+					$SI->add($data);
1880
+				}
1375 1881
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1376 1882
 			    }
1377 1883
                         } elseif ($format == 'acars') {
1378
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1884
+                    	    if ($globalDebug) {
1885
+                    	    	echo 'ACARS : '.$buffer."\n";
1886
+                    	    }
1379 1887
 			    $ACARS->add(trim($buffer));
1380 1888
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1381 1889
 			    $ACARS->deleteLiveAcarsData();
@@ -1396,8 +1904,12 @@  discard block
 block discarded – undo
1396 1904
 				    $aircraft_type = $line[10];
1397 1905
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1398 1906
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1399
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1400
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1907
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1908
+				    	$data['noarchive'] = true;
1909
+				    }
1910
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1911
+				    	$SI->add($data);
1912
+				    }
1401 1913
 				}
1402 1914
 			    }
1403 1915
 			} elseif ($format == 'beast') {
@@ -1407,28 +1919,62 @@  discard block
 block discarded – undo
1407 1919
 			    foreach($buffer as $all_data) {
1408 1920
 				$line = json_decode('{'.$all_data.'}',true);
1409 1921
 				$data = array();
1410
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1411
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1412
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1413
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1414
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1415
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1416
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1922
+				if (isset($line['Icao'])) {
1923
+					$data['hex'] = $line['Icao'];
1924
+				}
1925
+				// hex
1926
+				if (isset($line['Call'])) {
1927
+					$data['ident'] = $line['Call'];
1928
+				}
1929
+				// ident
1930
+				if (isset($line['Alt'])) {
1931
+					$data['altitude'] = $line['Alt'];
1932
+				}
1933
+				// altitude
1934
+				if (isset($line['Spd'])) {
1935
+					$data['speed'] = $line['Spd'];
1936
+				}
1937
+				// speed
1938
+				if (isset($line['Trak'])) {
1939
+					$data['heading'] = $line['Trak'];
1940
+				}
1941
+				// heading
1942
+				if (isset($line['Lat'])) {
1943
+					$data['latitude'] = $line['Lat'];
1944
+				}
1945
+				// lat
1946
+				if (isset($line['Long'])) {
1947
+					$data['longitude'] = $line['Long'];
1948
+				}
1949
+				// long
1417 1950
 				//$data['verticalrate'] = $line['']; // verticale rate
1418
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1951
+				if (isset($line['Sqk'])) {
1952
+					$data['squawk'] = $line['Sqk'];
1953
+				}
1954
+				// squawk
1419 1955
 				$data['emergency'] = ''; // emergency
1420
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1956
+				if (isset($line['Reg'])) {
1957
+					$data['registration'] = $line['Reg'];
1958
+				}
1421 1959
 				/*
1422 1960
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1423 1961
 				else $data['datetime'] = date('Y-m-d H:i:s');
1424 1962
 				*/
1425 1963
 				$data['datetime'] = date('Y-m-d H:i:s');
1426
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1964
+				if (isset($line['Type'])) {
1965
+					$data['aircraft_icao'] = $line['Type'];
1966
+				}
1427 1967
 		    		$data['format_source'] = 'vrstcp';
1428 1968
 				$data['id_source'] = $id_source;
1429
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1430
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1431
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1969
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1970
+					$data['noarchive'] = true;
1971
+				}
1972
+				if (isset($value['name']) && $value['name'] != '') {
1973
+					$data['source_name'] = $value['name'];
1974
+				}
1975
+				if (isset($data['latitude']) && isset($data['hex'])) {
1976
+					$SI->add($data);
1977
+				}
1432 1978
 				unset($data);
1433 1979
 			    }
1434 1980
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1441,22 +1987,46 @@  discard block
 block discarded – undo
1441 1987
     				$data['hex'] = $lined['hexid'];
1442 1988
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1443 1989
     				$data['datetime'] = date('Y-m-d H:i:s');;
1444
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1445
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1446
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1447
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1448
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1449
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1450
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1990
+    				if (isset($lined['ident'])) {
1991
+    					$data['ident'] = $lined['ident'];
1992
+    				}
1993
+    				if (isset($lined['lat'])) {
1994
+    					$data['latitude'] = $lined['lat'];
1995
+    				}
1996
+    				if (isset($lined['lon'])) {
1997
+    					$data['longitude'] = $lined['lon'];
1998
+    				}
1999
+    				if (isset($lined['speed'])) {
2000
+    					$data['speed'] = $lined['speed'];
2001
+    				}
2002
+    				if (isset($lined['squawk'])) {
2003
+    					$data['squawk'] = $lined['squawk'];
2004
+    				}
2005
+    				if (isset($lined['alt'])) {
2006
+    					$data['altitude'] = $lined['alt'];
2007
+    				}
2008
+    				if (isset($lined['heading'])) {
2009
+    					$data['heading'] = $lined['heading'];
2010
+    				}
1451 2011
     				$data['id_source'] = $id_source;
1452 2012
     				$data['format_source'] = 'tsv';
1453
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1454
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1455
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1456
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2013
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2014
+    					$data['source_name'] = $globalSources[$nb]['name'];
2015
+    				}
2016
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2017
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2018
+    				}
2019
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2020
+					$data['noarchive'] = true;
2021
+				}
2022
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2023
+    					$SI->add($data);
2024
+    				}
1457 2025
     				unset($lined);
1458 2026
     				unset($data);
1459
-    			    } else $error = true;
2027
+    			    } else {
2028
+    			    	$error = true;
2029
+    			    }
1460 2030
 			} elseif ($format == 'aprs' && $use_aprs) {
1461 2031
 			    if ($aprs_connect == 0) {
1462 2032
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1481,62 +2051,120 @@  discard block
 block discarded – undo
1481 2051
 				    $aprs_last_tx = time();
1482 2052
 				    $data = array();
1483 2053
 				    //print_r($line);
1484
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1485
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1486
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1487
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1488
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1489
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1490
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1491
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1492
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1493
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2054
+				    if (isset($line['address'])) {
2055
+				    	$data['hex'] = $line['address'];
2056
+				    }
2057
+				    if (isset($line['mmsi'])) {
2058
+				    	$data['mmsi'] = $line['mmsi'];
2059
+				    }
2060
+				    if (isset($line['imo'])) {
2061
+				    	$data['imo'] = $line['imo'];
2062
+				    }
2063
+				    if (isset($line['squawk'])) {
2064
+				    	$data['squawk'] = $line['squawk'];
2065
+				    }
2066
+				    if (isset($line['arrival_code'])) {
2067
+				    	$data['arrical_code'] = $line['arrival_code'];
2068
+				    }
2069
+				    if (isset($line['arrival_date'])) {
2070
+				    	$data['arrical_date'] = $line['arrival_date'];
2071
+				    }
2072
+				    if (isset($line['type_id'])) {
2073
+				    	$data['type_id'] = $line['typeid'];
2074
+				    }
2075
+				    if (isset($line['status_id'])) {
2076
+				    	$data['status_id'] = $line['statusid'];
2077
+				    }
2078
+				    if (isset($line['timestamp'])) {
2079
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2080
+				    } else {
2081
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2082
+				    }
1494 2083
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1495
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2084
+				    if (isset($line['ident'])) {
2085
+				    	$data['ident'] = $line['ident'];
2086
+				    }
1496 2087
 				    $data['latitude'] = $line['latitude'];
1497 2088
 				    $data['longitude'] = $line['longitude'];
1498 2089
 				    //$data['verticalrate'] = $line[16];
1499
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2090
+				    if (isset($line['speed'])) {
2091
+				    	$data['speed'] = $line['speed'];
2092
+				    }
1500 2093
 				    //else $data['speed'] = 0;
1501
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1502
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1503
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2094
+				    if (isset($line['altitude'])) {
2095
+				    	$data['altitude'] = $line['altitude'];
2096
+				    }
2097
+				    if (isset($line['comment'])) {
2098
+				    	$data['comment'] = $line['comment'];
2099
+				    }
2100
+				    if (isset($line['symbol'])) {
2101
+				    	$data['type'] = $line['symbol'];
2102
+				    }
1504 2103
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1505 2104
 				    
1506
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2105
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2106
+				    	$data['heading'] = $line['heading'];
2107
+				    }
1507 2108
 				    //else echo 'No heading...'."\n";
1508 2109
 				    //else $data['heading'] = 0;
1509
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2110
+				    if (isset($line['stealth'])) {
2111
+				    	$data['aircraft_type'] = $line['stealth'];
2112
+				    }
1510 2113
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1511
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1512
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1513
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1514
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2114
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2115
+				    	$data['noarchive'] = true;
2116
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2117
+				    	$data['noarchive'] = false;
2118
+				    }
2119
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2120
+				    	$data['noarchive'] = true;
2121
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2122
+				    	$data['noarchive'] = false;
2123
+				    }
1515 2124
     				    $data['id_source'] = $id_source;
1516
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1517
-				    else $data['format_source'] = 'aprs';
2125
+    				    if (isset($line['format_source'])) {
2126
+    				    	$data['format_source'] = $line['format_source'];
2127
+    				    } else {
2128
+				    	$data['format_source'] = 'aprs';
2129
+				    }
1518 2130
 				    $data['source_name'] = $line['source'];
1519
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1520
-				    else $data['source_type'] = 'flarm';
1521
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2131
+				    if (isset($line['source_type'])) {
2132
+				    	$data['source_type'] = $line['source_type'];
2133
+				    } else {
2134
+				    	$data['source_type'] = 'flarm';
2135
+				    }
2136
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2137
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2138
+    				    }
1522 2139
 				    $currentdate = date('Y-m-d H:i:s');
1523 2140
 				    $aprsdate = strtotime($data['datetime']);
1524
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2141
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2142
+				    	$data['altitude_relative'] = 'AMSL';
2143
+				    }
1525 2144
 				    // Accept data if time <= system time + 20s
1526 2145
 				    //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'])))) {
1527 2146
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1528 2147
 					$send = $SI->add($data);
1529 2148
 				    } elseif ($data['source_type'] == 'ais') {
1530
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2149
+					if (isset($globalMarine) && $globalMarine) {
2150
+						$send = $MI->add($data);
2151
+					}
1531 2152
 				    } elseif (isset($line['stealth'])) {
1532
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1533
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2153
+					if ($line['stealth'] != 0) {
2154
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2155
+					} else {
2156
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2157
+					}
1534 2158
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1535 2159
 					    //$line['symbol'] == 'Balloon' ||
1536 2160
 					    $line['symbol'] == 'Glider' || 
1537 2161
 					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1538
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1539
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2162
+					    if ($line['symbol'] == 'Ballon') {
2163
+					    	$data['aircraft_icao'] = 'BALL';
2164
+					    }
2165
+					    if ($line['symbol'] == 'Glider') {
2166
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2167
+					    }
1540 2168
 					    $send = $SI->add($data);
1541 2169
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1542 2170
 					    $line['symbol'] == 'Yacht (Sail)' || 
@@ -1567,9 +2195,13 @@  discard block
 block discarded – undo
1567 2195
 				    //} 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') {
1568 2196
 				//    } 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') {
1569 2197
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1570
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2198
+					if (isset($globalTracker) && $globalTracker) {
2199
+						$send = $TI->add($data);
2200
+					}
1571 2201
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1572
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2202
+					if (!isset($data['altitude'])) {
2203
+						$data['altitude'] = 0;
2204
+					}
1573 2205
 					$Source->deleteOldLocationByType('gs');
1574 2206
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1575 2207
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1578,7 +2210,9 @@  discard block
 block discarded – undo
1578 2210
 					}
1579 2211
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1580 2212
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1581
-					if ($globalDebug) echo '# Weather Station added'."\n";
2213
+					if ($globalDebug) {
2214
+						echo '# Weather Station added'."\n";
2215
+					}
1582 2216
 					$Source->deleteOldLocationByType('wx');
1583 2217
 					$weather_data = json_encode($line);
1584 2218
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1588,7 +2222,9 @@  discard block
 block discarded – undo
1588 2222
 					}
1589 2223
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1590 2224
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1591
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2225
+					if ($globalDebug) {
2226
+						echo '☈ Lightning added'."\n";
2227
+					}
1592 2228
 					$Source->deleteOldLocationByType('lightning');
1593 2229
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1594 2230
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1600,8 +2236,7 @@  discard block
 block discarded – undo
1600 2236
 				    	print_r($line);
1601 2237
 				    }
1602 2238
 				    unset($data);
1603
-				}
1604
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2239
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1605 2240
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1606 2241
 				}
1607 2242
 				/*
@@ -1610,7 +2245,9 @@  discard block
 block discarded – undo
1610 2245
 				}
1611 2246
 				*/
1612 2247
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1613
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2248
+				elseif ($line == true && $globalDebug) {
2249
+					echo '!! Failed : '.$buffer."!!\n";
2250
+				}
1614 2251
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1615 2252
 					$Source->deleteOldLocationByType('lightning');
1616 2253
 					$Source->deleteOldLocationByType('wx');
@@ -1646,26 +2283,45 @@  discard block
 block discarded – undo
1646 2283
     				$data['ground'] = $line[21];
1647 2284
     				$data['emergency'] = $line[19];
1648 2285
     				$data['format_source'] = 'sbs';
1649
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1651
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2286
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2287
+					$data['source_name'] = $globalSources[$nb]['name'];
2288
+				}
2289
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2290
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2291
+    				}
2292
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2293
+					$data['noarchive'] = true;
2294
+				}
1652 2295
     				$data['id_source'] = $id_source;
1653
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1654
-    				else $error = true;
2296
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2297
+    					$send = $SI->add($data);
2298
+    				} else {
2299
+    					$error = true;
2300
+    				}
1655 2301
     				unset($data);
1656
-    			    } else $error = true;
2302
+    			    } else {
2303
+    			    	$error = true;
2304
+    			    }
1657 2305
 			    if ($error) {
1658 2306
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1659
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2307
+					if ($globalDebug) {
2308
+						echo "Not a message. Ignoring... \n";
2309
+					}
1660 2310
 				} else {
1661
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2311
+					if ($globalDebug) {
2312
+						echo "Wrong line format. Ignoring... \n";
2313
+					}
1662 2314
 					if ($globalDebug) {
1663 2315
 						echo $buffer;
1664 2316
 						//print_r($line);
1665 2317
 					}
1666 2318
 					//socket_close($r);
1667
-					if ($globalDebug) echo "Reconnect after an error...\n";
1668
-					if ($format == 'aprs') $aprs_connect = 0;
2319
+					if ($globalDebug) {
2320
+						echo "Reconnect after an error...\n";
2321
+					}
2322
+					if ($format == 'aprs') {
2323
+						$aprs_connect = 0;
2324
+					}
1669 2325
 					$sourceer[$nb] = $globalSources[$nb];
1670 2326
 					connect_all($sourceer);
1671 2327
 					$sourceer = array();
@@ -1673,10 +2329,14 @@  discard block
 block discarded – undo
1673 2329
 			    }
1674 2330
 			}
1675 2331
 			// Sleep for xxx microseconds
1676
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2332
+			if (isset($globalSBSSleep)) {
2333
+				usleep($globalSBSSleep);
2334
+			}
1677 2335
 		    } else {
1678 2336
 			if ($format == 'flightgearmp') {
1679
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2337
+			    	if ($globalDebug) {
2338
+			    		echo "Reconnect FlightGear MP...";
2339
+			    	}
1680 2340
 				//@socket_close($r);
1681 2341
 				sleep($globalMinFetch);
1682 2342
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1685,10 +2345,15 @@  discard block
 block discarded – undo
1685 2345
 				break;
1686 2346
 				
1687 2347
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1688
-			    if (isset($tt[$format])) $tt[$format]++;
1689
-			    else $tt[$format] = 0;
2348
+			    if (isset($tt[$format])) {
2349
+			    	$tt[$format]++;
2350
+			    } else {
2351
+			    	$tt[$format] = 0;
2352
+			    }
1690 2353
 			    if ($tt[$format] > 30) {
1691
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2354
+				if ($globalDebug) {
2355
+					echo "ERROR : Reconnect ".$format."...";
2356
+				}
1692 2357
 				//@socket_close($r);
1693 2358
 				sleep(2);
1694 2359
 				$aprs_connect = 0;
@@ -1705,11 +2370,17 @@  discard block
 block discarded – undo
1705 2370
 	    } else {
1706 2371
 		$error = socket_strerror(socket_last_error());
1707 2372
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1708
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1709
-			if (isset($globalDebug)) echo "Restarting...\n";
2373
+			if ($globalDebug) {
2374
+				echo "ERROR : socket_select give this error ".$error . "\n";
2375
+			}
2376
+			if (isset($globalDebug)) {
2377
+				echo "Restarting...\n";
2378
+			}
1710 2379
 			// Restart the script if possible
1711 2380
 			if (is_array($sockets)) {
1712
-			    if ($globalDebug) echo "Shutdown all sockets...";
2381
+			    if ($globalDebug) {
2382
+			    	echo "Shutdown all sockets...";
2383
+			    }
1713 2384
 			    
1714 2385
 			    foreach ($sockets as $sock) {
1715 2386
 				@socket_shutdown($sock,2);
@@ -1717,25 +2388,45 @@  discard block
 block discarded – undo
1717 2388
 			    }
1718 2389
 			    
1719 2390
 			}
1720
-			if ($globalDebug) echo "Waiting...";
2391
+			if ($globalDebug) {
2392
+				echo "Waiting...";
2393
+			}
1721 2394
 			sleep(2);
1722 2395
 			$time = time();
1723 2396
 			//connect_all($hosts);
1724 2397
 			$aprs_connect = 0;
1725
-			if ($reset%5 == 0) sleep(20);
1726
-			if ($reset%10 == 0) sleep(100);
1727
-			if ($reset%20 == 0) sleep(200);
1728
-			if ($reset > 100) exit('Too many attempts...');
1729
-			if ($globalDebug) echo "Restart all connections...";
2398
+			if ($reset%5 == 0) {
2399
+				sleep(20);
2400
+			}
2401
+			if ($reset%10 == 0) {
2402
+				sleep(100);
2403
+			}
2404
+			if ($reset%20 == 0) {
2405
+				sleep(200);
2406
+			}
2407
+			if ($reset > 100) {
2408
+				exit('Too many attempts...');
2409
+			}
2410
+			if ($globalDebug) {
2411
+				echo "Restart all connections...";
2412
+			}
1730 2413
 			connect_all($globalSources);
1731 2414
 		}
1732 2415
 	    }
1733 2416
 	}
1734 2417
 	if ($globalDaemon === false) {
1735
-	    if ($globalDebug) echo 'Check all...'."\n";
1736
-	    if (isset($SI)) $SI->checkAll();
1737
-	    if (isset($TI)) $TI->checkAll();
1738
-	    if (isset($MI)) $MI->checkAll();
2418
+	    if ($globalDebug) {
2419
+	    	echo 'Check all...'."\n";
2420
+	    }
2421
+	    if (isset($SI)) {
2422
+	    	$SI->checkAll();
2423
+	    }
2424
+	    if (isset($TI)) {
2425
+	    	$TI->checkAll();
2426
+	    }
2427
+	    if (isset($MI)) {
2428
+	    	$MI->checkAll();
2429
+	    }
1739 2430
 	}
1740 2431
     }
1741 2432
 }
Please login to merge, or discard this patch.