Completed
Push — master ( 6c0d65...2769c1 )
by Yannick
47:12
created
scripts/daemon-spotter.php 3 patches
Indentation   +1158 added lines, -1158 removed lines patch added patch discarded remove patch
@@ -15,65 +15,65 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) {
18
-    require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19 19
 }
20 20
 if (isset($globalMarine) && $globalMarine) {
21
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25 25
 if (!isset($globalDebug)) $globalDebug = FALSE;
26 26
 
27 27
 if ($globalInstalled === FALSE) {
28
-    echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
-    sleep(5);
30
-    die();
28
+	echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
+	sleep(5);
30
+	die();
31 31
 }
32 32
 
33 33
 
34 34
 // Check if schema is at latest version
35 35
 $Connection = new Connection();
36 36
 if ($Connection->connectionExists() === false) {
37
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
-    exit();
37
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
+	exit();
39 39
 }
40 40
 if ($Connection->latest() === false) {
41
-    echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
-    exit();
41
+	echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
+	exit();
43 43
 }
44 44
 if (PHP_SAPI != 'cli') {
45
-    echo "This script MUST be called from console, not a web browser.";
45
+	echo "This script MUST be called from console, not a web browser.";
46 46
 //    exit();
47 47
 }
48 48
 
49 49
 // This is to be compatible with old version of settings.php
50 50
 if (!isset($globalSources)) {
51
-    if (isset($globalSBS1Hosts)) {
52
-        //$hosts = $globalSBS1Hosts;
53
-        foreach ($globalSBS1Hosts as $host) {
54
-	    $globalSources[] = array('host' => $host);
55
-    	}
56
-    } else {
57
-        if (!isset($globalSBS1Host)) {
58
-	    echo '$globalSources MUST be defined !';
59
-	    die;
51
+	if (isset($globalSBS1Hosts)) {
52
+		//$hosts = $globalSBS1Hosts;
53
+		foreach ($globalSBS1Hosts as $host) {
54
+		$globalSources[] = array('host' => $host);
55
+		}
56
+	} else {
57
+		if (!isset($globalSBS1Host)) {
58
+		echo '$globalSources MUST be defined !';
59
+		die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62 62
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
63
-    }
63
+	}
64 64
 }
65 65
 
66 66
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70
-    $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
70
+	$globalSources = array();
71
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
+	else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74
-    $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
74
+	$globalSources = array();
75
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
+	else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
79 79
 	$globalServerAPRS = TRUE;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 if (isset($options['idsource'])) $id_source = $options['idsource'];
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
115
+	if ($globalDebug) echo "Using Server Mode\n";
116
+	$SI=new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
126
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
126
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 128
 }
129 129
 
130 130
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
131 131
 if (isset($globalMarine) && $globalMarine) {
132
-    $AIS = new AIS();
133
-    $MI = new MarineImport($Connection->db);
132
+	$AIS = new AIS();
133
+	$MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136 136
 $SBS=new SBS();
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
147
-        global $sockets;
148
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
-        die("Bye!\n");
150
-    });
151
-    pcntl_signal_dispatch();
146
+	pcntl_signal(SIGINT,  function() {
147
+		global $sockets;
148
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
+		die("Bye!\n");
150
+	});
151
+	pcntl_signal_dispatch();
152 152
 }
153 153
 
154 154
 // let's try and connect
@@ -158,46 +158,46 @@  discard block
 block discarded – undo
158 158
 $reset = 0;
159 159
 
160 160
 function connect_all($hosts) {
161
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
-    $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
165
-    foreach ($hosts as $id => $value) {
161
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
+	$reset++;
164
+	if ($globalDebug) echo 'Connect to all...'."\n";
165
+	foreach ($hosts as $id => $value) {
166 166
 	$host = $value['host'];
167 167
 	$globalSources[$id]['last_exec'] = 0;
168 168
 	// Here we check type of source(s)
169 169
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
170
-            if (preg_match('/deltadb.txt$/i',$host)) {
171
-        	//$formats[$id] = 'deltadbtxt';
172
-        	$globalSources[$id]['format'] = 'deltadbtxt';
173
-        	//$last_exec['deltadbtxt'] = 0;
174
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
175
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176
-        	//$formats[$id] = 'vatsimtxt';
177
-        	$globalSources[$id]['format'] = 'vatsimtxt';
178
-        	//$last_exec['vatsimtxt'] = 0;
179
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
180
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181
-        	//$formats[$id] = 'aircraftlistjson';
182
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
183
-        	//$last_exec['aircraftlistjson'] = 0;
184
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
185
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
186
-        	//$formats[$id] = 'aircraftjson';
187
-        	$globalSources[$id]['format'] = 'aircraftjson';
188
-        	//$last_exec['aircraftlistjson'] = 0;
189
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
190
-    	    } else if (preg_match('/aircraft$/i',$host)) {
191
-        	//$formats[$id] = 'planefinderclient';
192
-        	$globalSources[$id]['format'] = 'planefinderclient';
193
-        	//$last_exec['aircraftlistjson'] = 0;
194
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
195
-    	    } else if (preg_match('/opensky/i',$host)) {
196
-        	//$formats[$id] = 'aircraftlistjson';
197
-        	$globalSources[$id]['format'] = 'opensky';
198
-        	//$last_exec['aircraftlistjson'] = 0;
199
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
200
-    	    /*
170
+			if (preg_match('/deltadb.txt$/i',$host)) {
171
+			//$formats[$id] = 'deltadbtxt';
172
+			$globalSources[$id]['format'] = 'deltadbtxt';
173
+			//$last_exec['deltadbtxt'] = 0;
174
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
175
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
176
+			//$formats[$id] = 'vatsimtxt';
177
+			$globalSources[$id]['format'] = 'vatsimtxt';
178
+			//$last_exec['vatsimtxt'] = 0;
179
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
180
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
181
+			//$formats[$id] = 'aircraftlistjson';
182
+			$globalSources[$id]['format'] = 'aircraftlistjson';
183
+			//$last_exec['aircraftlistjson'] = 0;
184
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
185
+			} else if (preg_match('/aircraft.json$/i',$host)) {
186
+			//$formats[$id] = 'aircraftjson';
187
+			$globalSources[$id]['format'] = 'aircraftjson';
188
+			//$last_exec['aircraftlistjson'] = 0;
189
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
190
+			} else if (preg_match('/aircraft$/i',$host)) {
191
+			//$formats[$id] = 'planefinderclient';
192
+			$globalSources[$id]['format'] = 'planefinderclient';
193
+			//$last_exec['aircraftlistjson'] = 0;
194
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
195
+			} else if (preg_match('/opensky/i',$host)) {
196
+			//$formats[$id] = 'aircraftlistjson';
197
+			$globalSources[$id]['format'] = 'opensky';
198
+			//$last_exec['aircraftlistjson'] = 0;
199
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
200
+			/*
201 201
     	    // Disabled for now, site change source format
202 202
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
203 203
         	//$formats[$id] = 'radarvirtueljson';
@@ -209,128 +209,128 @@  discard block
 block discarded – undo
209 209
         	    exit(0);
210 210
         	}
211 211
     	    */
212
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
213
-        	//$formats[$id] = 'planeupdatefaa';
214
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
215
-        	//$last_exec['planeupdatefaa'] = 0;
216
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
217
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
218
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
219
-        	    exit(0);
220
-        	}
221
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
222
-        	//$formats[$id] = 'phpvmacars';
223
-        	$globalSources[$id]['format'] = 'phpvmacars';
224
-        	//$last_exec['phpvmacars'] = 0;
225
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
226
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227
-        	//$formats[$id] = 'phpvmacars';
228
-        	$globalSources[$id]['format'] = 'vaos';
229
-        	//$last_exec['phpvmacars'] = 0;
230
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
231
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
232
-        	//$formats[$id] = 'phpvmacars';
233
-        	$globalSources[$id]['format'] = 'vam';
234
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
235
-            } else if (preg_match('/whazzup/i',$host)) {
236
-        	//$formats[$id] = 'whazzup';
237
-        	$globalSources[$id]['format'] = 'whazzup';
238
-        	//$last_exec['whazzup'] = 0;
239
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
240
-            } else if (preg_match('/blitzortung/i',$host)) {
241
-        	$globalSources[$id]['format'] = 'blitzortung';
242
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
243
-            } else if (preg_match('/airwhere/i',$host)) {
244
-        	$globalSources[$id]['format'] = 'airwhere';
245
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
246
-            } else if (preg_match('/recentpireps/i',$host)) {
247
-        	//$formats[$id] = 'pirepsjson';
248
-        	$globalSources[$id]['format'] = 'pirepsjson';
249
-        	//$last_exec['pirepsjson'] = 0;
250
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
251
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252
-        	//$formats[$id] = 'fr24json';
253
-        	$globalSources[$id]['format'] = 'fr24json';
254
-        	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
256
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
-        	    exit(0);
259
-        	}
260
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
261
-        	//$formats[$id] = 'fr24json';
262
-        	$globalSources[$id]['format'] = 'myshiptracking';
263
-        	//$last_exec['fr24json'] = 0;
264
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
265
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
266
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
267
-        	    exit(0);
268
-        	}
269
-            //} else if (preg_match('/10001/',$host)) {
270
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271
-        	//$formats[$id] = 'tsv';
272
-        	$globalSources[$id]['format'] = 'tsv';
273
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
274
-            }
275
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
277
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278
-    		    if ($idf !== false) {
279
-    			$httpfeeds[$id] = $idf;
280
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
281
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
282
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
283
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
284
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
285
-	    $hostport = explode(':',$host);
286
-	    if (isset($hostport[1])) {
212
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
213
+			//$formats[$id] = 'planeupdatefaa';
214
+			$globalSources[$id]['format'] = 'planeupdatefaa';
215
+			//$last_exec['planeupdatefaa'] = 0;
216
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
217
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
218
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
219
+				exit(0);
220
+			}
221
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
222
+			//$formats[$id] = 'phpvmacars';
223
+			$globalSources[$id]['format'] = 'phpvmacars';
224
+			//$last_exec['phpvmacars'] = 0;
225
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
226
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227
+			//$formats[$id] = 'phpvmacars';
228
+			$globalSources[$id]['format'] = 'vaos';
229
+			//$last_exec['phpvmacars'] = 0;
230
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
231
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
232
+			//$formats[$id] = 'phpvmacars';
233
+			$globalSources[$id]['format'] = 'vam';
234
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
235
+			} else if (preg_match('/whazzup/i',$host)) {
236
+			//$formats[$id] = 'whazzup';
237
+			$globalSources[$id]['format'] = 'whazzup';
238
+			//$last_exec['whazzup'] = 0;
239
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
240
+			} else if (preg_match('/blitzortung/i',$host)) {
241
+			$globalSources[$id]['format'] = 'blitzortung';
242
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
243
+			} else if (preg_match('/airwhere/i',$host)) {
244
+			$globalSources[$id]['format'] = 'airwhere';
245
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
246
+			} else if (preg_match('/recentpireps/i',$host)) {
247
+			//$formats[$id] = 'pirepsjson';
248
+			$globalSources[$id]['format'] = 'pirepsjson';
249
+			//$last_exec['pirepsjson'] = 0;
250
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
251
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252
+			//$formats[$id] = 'fr24json';
253
+			$globalSources[$id]['format'] = 'fr24json';
254
+			//$last_exec['fr24json'] = 0;
255
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
256
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
+				exit(0);
259
+			}
260
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
261
+			//$formats[$id] = 'fr24json';
262
+			$globalSources[$id]['format'] = 'myshiptracking';
263
+			//$last_exec['fr24json'] = 0;
264
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
265
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
266
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
267
+				exit(0);
268
+			}
269
+			//} else if (preg_match('/10001/',$host)) {
270
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271
+			//$formats[$id] = 'tsv';
272
+			$globalSources[$id]['format'] = 'tsv';
273
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
274
+			}
275
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276
+			if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
277
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
278
+				if ($idf !== false) {
279
+				$httpfeeds[$id] = $idf;
280
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
281
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
282
+			} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
283
+			elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
284
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
285
+		$hostport = explode(':',$host);
286
+		if (isset($hostport[1])) {
287 287
 		$port = $hostport[1];
288 288
 		$hostn = $hostport[0];
289
-	    } else {
289
+		} else {
290 290
 		$port = $globalSources[$id]['port'];
291 291
 		$hostn = $globalSources[$id]['host'];
292
-	    }
293
-	    $Common = new Common();
294
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
295
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
296
-    	    } else {
297
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
298
-	    }
299
-	    if ($s) {
300
-    	        $sockets[$id] = $s;
301
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
302
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
292
+		}
293
+		$Common = new Common();
294
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
295
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
296
+			} else {
297
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
298
+		}
299
+		if ($s) {
300
+				$sockets[$id] = $s;
301
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
302
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
303 303
 			//$formats[$id] = 'aprs';
304 304
 			$globalSources[$id]['format'] = 'aprs';
305 305
 			//$aprs_connect = 0;
306 306
 			//$use_aprs = true;
307
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
307
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
308 308
 			$globalSources[$id]['format'] = 'vrstcp';
309
-    		    } elseif ($port == '10001') {
310
-        		//$formats[$id] = 'tsv';
311
-        		$globalSources[$id]['format'] = 'tsv';
312
-		    } elseif ($port == '30002') {
313
-        		//$formats[$id] = 'raw';
314
-        		$globalSources[$id]['format'] = 'raw';
315
-		    } elseif ($port == '5001') {
316
-        		//$formats[$id] = 'raw';
317
-        		$globalSources[$id]['format'] = 'flightgearmp';
318
-		    } elseif ($port == '30005') {
309
+				} elseif ($port == '10001') {
310
+				//$formats[$id] = 'tsv';
311
+				$globalSources[$id]['format'] = 'tsv';
312
+			} elseif ($port == '30002') {
313
+				//$formats[$id] = 'raw';
314
+				$globalSources[$id]['format'] = 'raw';
315
+			} elseif ($port == '5001') {
316
+				//$formats[$id] = 'raw';
317
+				$globalSources[$id]['format'] = 'flightgearmp';
318
+			} elseif ($port == '30005') {
319 319
 			// Not yet supported
320
-        		//$formats[$id] = 'beast';
321
-        		$globalSources[$id]['format'] = 'beast';
322
-		    //} else $formats[$id] = 'sbs';
323
-		    } else $globalSources[$id]['format'] = 'sbs';
324
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
320
+				//$formats[$id] = 'beast';
321
+				$globalSources[$id]['format'] = 'beast';
322
+			//} else $formats[$id] = 'sbs';
323
+			} else $globalSources[$id]['format'] = 'sbs';
324
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
325 325
 		}
326 326
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
327
-            } else {
327
+			} else {
328 328
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
329 329
 		sleep(10);
330 330
 		connect_all($hosts);
331
-    	    }
332
-        }
333
-    }
331
+			}
332
+		}
333
+	}
334 334
 }
335 335
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
336 336
 
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 //connect_all($globalSources);
354 354
 
355 355
 if (isset($globalProxy) && $globalProxy) {
356
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
356
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
357 357
 } else {
358
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
358
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
359 359
 }
360 360
 
361 361
 // APRS Configuration
@@ -364,21 +364,21 @@  discard block
 block discarded – undo
364 364
 	die;
365 365
 }
366 366
 foreach ($globalSources as $key => $source) {
367
-    if (!isset($source['format'])) {
368
-        $globalSources[$key]['format'] = 'auto';
369
-    }
370
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
371
-        unset($globalSources[$key]);
372
-    }
367
+	if (!isset($source['format'])) {
368
+		$globalSources[$key]['format'] = 'auto';
369
+	}
370
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
371
+		unset($globalSources[$key]);
372
+	}
373 373
 }
374 374
 connect_all($globalSources);
375 375
 foreach ($globalSources as $key => $source) {
376
-    if (isset($source['format']) && $source['format'] == 'aprs') {
376
+	if (isset($source['format']) && $source['format'] == 'aprs') {
377 377
 	$aprs_connect = 0;
378 378
 	$use_aprs = true;
379 379
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
380 380
 	break;
381
-    }
381
+	}
382 382
 }
383 383
 
384 384
 if ($use_aprs) {
@@ -419,133 +419,133 @@  discard block
 block discarded – undo
419 419
 
420 420
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
421 421
 while ($i > 0) {
422
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
422
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
423 423
 
424
-    if (!$globalDaemon) $i = $endtime-time();
425
-    // Delete old ATC
426
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
424
+	if (!$globalDaemon) $i = $endtime-time();
425
+	// Delete old ATC
426
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
427 427
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
428
-        $ATC->deleteOldATC();
429
-    }
428
+		$ATC->deleteOldATC();
429
+	}
430 430
     
431
-    if (count($last_exec) == count($globalSources)) {
431
+	if (count($last_exec) == count($globalSources)) {
432 432
 	$max = $globalMinFetch;
433 433
 	foreach ($last_exec as $last) {
434
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
434
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
435 435
 	}
436 436
 	if ($max < $globalMinFetch) {
437
-	    if ($globalDebug) echo 'Sleeping...'."\n";
438
-	    sleep($globalMinFetch-$max+2);
437
+		if ($globalDebug) echo 'Sleeping...'."\n";
438
+		sleep($globalMinFetch-$max+2);
439
+	}
439 440
 	}
440
-    }
441 441
 
442 442
     
443
-    //foreach ($formats as $id => $value) {
444
-    foreach ($globalSources as $id => $value) {
443
+	//foreach ($formats as $id => $value) {
444
+	foreach ($globalSources as $id => $value) {
445 445
 	date_default_timezone_set('UTC');
446 446
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
447 447
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
448 448
 	if ($value['format'] === 'deltadbtxt' && 
449
-	    (
449
+		(
450 450
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
451 451
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
452
-	    )
452
+		)
453 453
 	) {
454
-	    //$buffer = $Common->getData($hosts[$id]);
455
-	    $buffer = $Common->getData($value['host']);
456
-	    if ($buffer != '') $reset = 0;
457
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
458
-	    $buffer = explode('\n',$buffer);
459
-	    foreach ($buffer as $line) {
460
-    		if ($line != '' && count($line) > 7) {
461
-    		    $line = explode(',', $line);
462
-	            $data = array();
463
-	            $data['hex'] = $line[1]; // hex
464
-	            $data['ident'] = $line[2]; // ident
465
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
466
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
467
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
468
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
469
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
470
-	            $data['verticalrate'] = ''; // vertical rate
471
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
472
-	            $data['emergency'] = ''; // emergency
473
-		    $data['datetime'] = date('Y-m-d H:i:s');
474
-		    $data['format_source'] = 'deltadbtxt';
475
-    		    $data['id_source'] = $id_source;
476
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
477
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
479
-    		    $SI->add($data);
480
-		    unset($data);
481
-    		}
482
-    	    }
483
-    	    $last_exec[$id]['last'] = time();
454
+		//$buffer = $Common->getData($hosts[$id]);
455
+		$buffer = $Common->getData($value['host']);
456
+		if ($buffer != '') $reset = 0;
457
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
458
+		$buffer = explode('\n',$buffer);
459
+		foreach ($buffer as $line) {
460
+			if ($line != '' && count($line) > 7) {
461
+				$line = explode(',', $line);
462
+				$data = array();
463
+				$data['hex'] = $line[1]; // hex
464
+				$data['ident'] = $line[2]; // ident
465
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
466
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
467
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
468
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
469
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
470
+				$data['verticalrate'] = ''; // vertical rate
471
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
472
+				$data['emergency'] = ''; // emergency
473
+			$data['datetime'] = date('Y-m-d H:i:s');
474
+			$data['format_source'] = 'deltadbtxt';
475
+				$data['id_source'] = $id_source;
476
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
477
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
479
+				$SI->add($data);
480
+			unset($data);
481
+			}
482
+			}
483
+			$last_exec[$id]['last'] = time();
484 484
 	} elseif ($value['format'] === 'aisnmeatxt' && 
485
-	    (
485
+		(
486 486
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
487 487
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
488
-	    )
488
+		)
489 489
 	) {
490
-	    date_default_timezone_set('CET');
491
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
492
-	    date_default_timezone_set('UTC');
493
-	    if ($buffer != '') $reset = 0;
494
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
495
-	    $buffer = explode('\n',$buffer);
496
-	    foreach ($buffer as $line) {
490
+		date_default_timezone_set('CET');
491
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
492
+		date_default_timezone_set('UTC');
493
+		if ($buffer != '') $reset = 0;
494
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
495
+		$buffer = explode('\n',$buffer);
496
+		foreach ($buffer as $line) {
497 497
 		if ($line != '') {
498
-		    //echo "'".$line."'\n";
499
-		    $add = false;
500
-		    $ais_data = $AIS->parse_line(trim($line));
501
-		    $data = array();
502
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
503
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
504
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
505
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
506
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
507
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
508
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
509
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
510
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
511
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
512
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
513
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
514
-		    if (isset($ais_data['timestamp'])) {
498
+			//echo "'".$line."'\n";
499
+			$add = false;
500
+			$ais_data = $AIS->parse_line(trim($line));
501
+			$data = array();
502
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
503
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
504
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
505
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
506
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
507
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
508
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
509
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
510
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
511
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
512
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
513
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
514
+			if (isset($ais_data['timestamp'])) {
515 515
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
516 516
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
517
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
518
-			    $add = true;
517
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
518
+				$add = true;
519 519
 			}
520
-		    } else {
520
+			} else {
521 521
 			$data['datetime'] = date('Y-m-d H:i:s');
522 522
 			$add = true;
523
-		    }
524
-		    $data['format_source'] = 'aisnmeatxt';
525
-    		    $data['id_source'] = $id_source;
526
-		    //print_r($data);
527
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
528
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
529
-		    unset($data);
523
+			}
524
+			$data['format_source'] = 'aisnmeatxt';
525
+				$data['id_source'] = $id_source;
526
+			//print_r($data);
527
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
528
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
529
+			unset($data);
530 530
 		}
531
-    	    }
532
-    	    $last_exec[$id]['last'] = time();
531
+			}
532
+			$last_exec[$id]['last'] = time();
533 533
 	} elseif ($value['format'] === 'aisnmeahttp') {
534
-	    $arr = $httpfeeds;
535
-	    $w = $e = null;
534
+		$arr = $httpfeeds;
535
+		$w = $e = null;
536 536
 	    
537
-	    if (isset($arr[$id])) {
537
+		if (isset($arr[$id])) {
538 538
 		$nn = stream_select($arr,$w,$e,$timeout);
539 539
 		if ($nn > 0) {
540
-		    foreach ($httpfeeds as $feed) {
540
+			foreach ($httpfeeds as $feed) {
541 541
 			$buffer = stream_get_line($feed,2000,"\n");
542 542
 			if ($buffer === FALSE) {
543
-			    connect_all($globalSources);
543
+				connect_all($globalSources);
544 544
 			}
545 545
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
546 546
 			$buffer = explode('\n',$buffer);
547 547
 			foreach ($buffer as $line) {
548
-			    if ($line != '') {
548
+				if ($line != '') {
549 549
 				$ais_data = $AIS->parse_line(trim($line));
550 550
 				$data = array();
551 551
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -563,117 +563,117 @@  discard block
 block discarded – undo
563 563
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
564 564
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
565 565
 				if (isset($ais_data['timestamp'])) {
566
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
566
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
567 567
 				} else {
568
-				    $data['datetime'] = date('Y-m-d H:i:s');
568
+					$data['datetime'] = date('Y-m-d H:i:s');
569 569
 				}
570 570
 				$data['format_source'] = 'aisnmeahttp';
571 571
 				$data['id_source'] = $id_source;
572 572
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
573 573
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
574 574
 				unset($data);
575
-			    }
575
+				}
576
+			}
576 577
 			}
577
-		    }
578 578
 		} else {
579
-		    $format = $value['format'];
580
-		    if (isset($tt[$format])) $tt[$format]++;
581
-		    else $tt[$format] = 0;
582
-		    if ($tt[$format] > 30) {
579
+			$format = $value['format'];
580
+			if (isset($tt[$format])) $tt[$format]++;
581
+			else $tt[$format] = 0;
582
+			if ($tt[$format] > 30) {
583 583
 			if ($globalDebug) echo 'Reconnect...'."\n";
584 584
 			sleep(2);
585 585
 			//$sourceeen[] = $value;
586 586
 			//connect_all($sourceeen);
587 587
 			//$sourceeen = array();
588 588
 			connect_all($globalSources);
589
-		    }
589
+			}
590
+		}
590 591
 		}
591
-	    }
592 592
 	} elseif ($value['format'] === 'myshiptracking' && 
593
-	    (
593
+		(
594 594
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
595 595
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
596
-	    )
596
+		)
597 597
 	) {
598
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
599
-	    if ($buffer != '') {
598
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
599
+		if ($buffer != '') {
600 600
 		//echo $buffer;
601 601
 		$all_data = json_decode($buffer,true);
602 602
 		//print_r($all_data);
603 603
 		if (isset($all_data[0]['DATA'])) {
604
-		    foreach ($all_data[0]['DATA'] as $line) {
604
+			foreach ($all_data[0]['DATA'] as $line) {
605 605
 			if ($line != '') {
606
-			    $data = array();
607
-			    $data['ident'] = $line['NAME'];
608
-			    $data['mmsi'] = $line['MMSI'];
609
-			    if (strlen($data['mmsi']) > 9) {
606
+				$data = array();
607
+				$data['ident'] = $line['NAME'];
608
+				$data['mmsi'] = $line['MMSI'];
609
+				if (strlen($data['mmsi']) > 9) {
610 610
 				$data['mmsi'] = substr($data['mmsi'],-9);
611
-			    }
612
-			    $data['speed'] = $line['SOG'];
613
-			    $data['heading'] = $line['COG'];
614
-			    $data['latitude'] = $line['LAT'];
615
-			    $data['longitude'] = $line['LNG'];
616
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
617
-			    //$data['type_id'] = $line['TYPE'];
618
-			    $data['imo'] = $line['IMO'];
619
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
620
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
621
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
622
-			    $data['format_source'] = 'myshiptracking';
623
-			    $data['id_source'] = $id_source;
624
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
625
-			    $MI->add($data);
626
-			    unset($data);
611
+				}
612
+				$data['speed'] = $line['SOG'];
613
+				$data['heading'] = $line['COG'];
614
+				$data['latitude'] = $line['LAT'];
615
+				$data['longitude'] = $line['LNG'];
616
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
617
+				//$data['type_id'] = $line['TYPE'];
618
+				$data['imo'] = $line['IMO'];
619
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
620
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
621
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
622
+				$data['format_source'] = 'myshiptracking';
623
+				$data['id_source'] = $id_source;
624
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
625
+				$MI->add($data);
626
+				unset($data);
627
+			}
627 628
 			}
628
-		    }
629 629
 		}
630
-	    }
631
-	    $last_exec[$id]['last'] = time();
630
+		}
631
+		$last_exec[$id]['last'] = time();
632 632
 	} elseif ($value['format'] === 'boatbeaconapp' && 
633
-	    (
633
+		(
634 634
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
635 635
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
636
-	    )
636
+		)
637 637
 	) {
638
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
639
-	    if ($buffer != '') {
638
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
639
+		if ($buffer != '') {
640 640
 		$all_data = json_decode($buffer,true);
641 641
 		if (isset($all_data[0]['mmsi'])) {
642
-		    foreach ($all_data as $line) {
642
+			foreach ($all_data as $line) {
643 643
 			if ($line != '') {
644
-			    $data = array();
645
-			    $data['ident'] = $line['shipname'];
646
-			    $data['callsign'] = $line['callsign'];
647
-			    $data['mmsi'] = substr($line['mmsi'],-9);
648
-			    $data['speed'] = $line['sog'];
649
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
650
-			    $data['latitude'] = $line['latitude'];
651
-			    $data['longitude'] = $line['longitude'];
652
-			    $data['type_id'] = $line['shiptype'];
653
-			    $data['arrival_code'] = $line['destination'];
654
-			    $data['datetime'] = $line['time'];
655
-			    $data['format_source'] = 'boatbeaconapp';
656
-			    $data['id_source'] = $id_source;
657
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
658
-			    $MI->add($data);
659
-			    unset($data);
644
+				$data = array();
645
+				$data['ident'] = $line['shipname'];
646
+				$data['callsign'] = $line['callsign'];
647
+				$data['mmsi'] = substr($line['mmsi'],-9);
648
+				$data['speed'] = $line['sog'];
649
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
650
+				$data['latitude'] = $line['latitude'];
651
+				$data['longitude'] = $line['longitude'];
652
+				$data['type_id'] = $line['shiptype'];
653
+				$data['arrival_code'] = $line['destination'];
654
+				$data['datetime'] = $line['time'];
655
+				$data['format_source'] = 'boatbeaconapp';
656
+				$data['id_source'] = $id_source;
657
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
658
+				$MI->add($data);
659
+				unset($data);
660
+			}
660 661
 			}
661
-		    }
662 662
 		}
663 663
 		
664
-	    }
665
-    	    $last_exec[$id]['last'] = time();
664
+		}
665
+			$last_exec[$id]['last'] = time();
666 666
 	} elseif ($value['format'] === 'boatnerd' && 
667
-	    (
667
+		(
668 668
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
669 669
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
670
-	    )
670
+		)
671 671
 	) {
672
-	    $buffer = $Common->getData($value['host']);
673
-	    if ($buffer != '') {
672
+		$buffer = $Common->getData($value['host']);
673
+		if ($buffer != '') {
674 674
 		$all_data = json_decode($buffer,true);
675 675
 		if (isset($all_data['features'][0]['id'])) {
676
-		    foreach ($all_data['features'] as $line) {
676
+			foreach ($all_data['features'] as $line) {
677 677
 			print_r($line);
678 678
 			$data = array();
679 679
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -693,76 +693,76 @@  discard block
 block discarded – undo
693 693
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
694 694
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
695 695
 			unset($data);
696
-		    }
696
+			}
697 697
 		}
698 698
 		
699
-	    }
700
-    	    $last_exec[$id]['last'] = time();
699
+		}
700
+			$last_exec[$id]['last'] = time();
701 701
 	} elseif ($value['format'] === 'shipplotter' && 
702
-	    (
702
+		(
703 703
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
704 704
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
705
-	    )
705
+		)
706 706
 	) {
707
-	    if ($globalDebug) echo 'download...';
708
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
709
-	    if ($globalDebug) echo 'done !'."\n";
710
-	    // FIXME: Need more work
711
-	    if ($buffer != '') $reset = 0;
712
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
713
-	    $buffer = explode('\n',$buffer);
714
-	    foreach ($buffer as $line) {
707
+		if ($globalDebug) echo 'download...';
708
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
709
+		if ($globalDebug) echo 'done !'."\n";
710
+		// FIXME: Need more work
711
+		if ($buffer != '') $reset = 0;
712
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
713
+		$buffer = explode('\n',$buffer);
714
+		foreach ($buffer as $line) {
715 715
 		if ($line != '') {
716
-		    $data = array();
717
-		    //echo $line."\n";
718
-		    $data['mmsi'] = (int)substr($line,0,9);
719
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
720
-		    $data['status_id'] = substr($line,21,2);
721
-		    $data['type_id'] = substr($line,24,3);
722
-		    $data['latitude'] = substr($line,29,9);
723
-		    $data['longitude'] = substr($line,41,9);
724
-		    $data['speed'] = round(substr($line,51,5));
725
-		    //$data['course'] = substr($line,57,5);
726
-		    $data['heading'] = round(substr($line,63,3));
727
-		    //$data['draft'] = substr($line,67,4);
728
-		    //$data['length'] = substr($line,72,3);
729
-		    //$data['beam'] = substr($line,76,2);
730
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
731
-		    //$data['callsign'] = trim(substr($line,100,7);
732
-		    $data['arrival_code'] = substr($line,108,20);
733
-		    //$data['etaDate'] = substr($line,129,5);
734
-		    //$data['etaTime'] = substr($line,135,5);
735
-		    $data['format_source'] = 'shipplotter';
736
-    		    $data['id_source'] = $id_source;
737
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
738
-		    //print_r($data);
739
-		    //echo 'Add...'."\n";
740
-		    $MI->add($data);
741
-		    unset($data);
716
+			$data = array();
717
+			//echo $line."\n";
718
+			$data['mmsi'] = (int)substr($line,0,9);
719
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
720
+			$data['status_id'] = substr($line,21,2);
721
+			$data['type_id'] = substr($line,24,3);
722
+			$data['latitude'] = substr($line,29,9);
723
+			$data['longitude'] = substr($line,41,9);
724
+			$data['speed'] = round(substr($line,51,5));
725
+			//$data['course'] = substr($line,57,5);
726
+			$data['heading'] = round(substr($line,63,3));
727
+			//$data['draft'] = substr($line,67,4);
728
+			//$data['length'] = substr($line,72,3);
729
+			//$data['beam'] = substr($line,76,2);
730
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
731
+			//$data['callsign'] = trim(substr($line,100,7);
732
+			$data['arrival_code'] = substr($line,108,20);
733
+			//$data['etaDate'] = substr($line,129,5);
734
+			//$data['etaTime'] = substr($line,135,5);
735
+			$data['format_source'] = 'shipplotter';
736
+				$data['id_source'] = $id_source;
737
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
738
+			//print_r($data);
739
+			//echo 'Add...'."\n";
740
+			$MI->add($data);
741
+			unset($data);
742 742
 		}
743
-    	    }
744
-    	    $last_exec[$id]['last'] = time();
743
+			}
744
+			$last_exec[$id]['last'] = time();
745 745
 	} elseif ($value['format'] === 'sailaway' && 
746
-	    (
746
+		(
747 747
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
748 748
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
749
-	    )
749
+		)
750 750
 	) {
751
-	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
751
+		if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
752 752
 		$authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
753 753
 		//echo $authsailaway;
754 754
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
755 755
 		if (isset($setcookie[1][0])) {
756
-		    $sailaway_authcookie = $setcookie[1][0];
756
+			$sailaway_authcookie = $setcookie[1][0];
757
+		}
757 758
 		}
758
-	    }
759 759
 
760
-	    if ($globalDebug) echo '! Download... ';
761
-	    for ($i =0; $i <= 1; $i++) {
760
+		if ($globalDebug) echo '! Download... ';
761
+		for ($i =0; $i <= 1; $i++) {
762 762
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
763 763
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
764
-	    if ($globalDebug) echo 'done'."\n";
765
-	    if ($buffer != '') {
764
+		if ($globalDebug) echo 'done'."\n";
765
+		if ($buffer != '') {
766 766
 		$all_data = json_decode($buffer,true);
767 767
 		if (isset($all_data['missions'])) {
768 768
 			foreach ($all_data['missions'] as $mission) {
@@ -781,19 +781,19 @@  discard block
 block discarded – undo
781 781
 					//print_r($race_data);
782 782
 					unset($racebuffer);
783 783
 					if (isset($race_data['mission'])) {
784
-					    $datar = array();
785
-					    $datar['id'] = $mission['misnr'];
786
-					    $datar['desc'] = $race_data['mission']['misdescr'];
787
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
788
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
789
-					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
790
-					    $markers = array();
791
-					    foreach ($race_data['mission']['course'] as $course) {
784
+						$datar = array();
785
+						$datar['id'] = $mission['misnr'];
786
+						$datar['desc'] = $race_data['mission']['misdescr'];
787
+						$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
788
+						$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
789
+						$datar['startdate'] = $race_data['mission']['misstartdatetime'];
790
+						$markers = array();
791
+						foreach ($race_data['mission']['course'] as $course) {
792 792
 						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
793
-					    }
794
-					    $datar['markers'] = json_encode($markers);
795
-					    //print_r($datar);
796
-					    $MI->race_add($datar);
793
+						}
794
+						$datar['markers'] = json_encode($markers);
795
+						//print_r($datar);
796
+						$MI->race_add($datar);
797 797
 					}
798 798
 				}
799 799
 				if ($bufferm != '') {
@@ -857,34 +857,34 @@  discard block
 block discarded – undo
857 857
 				}
858 858
 			}
859 859
 		}
860
-	    }
861
-	    }
862
-    	    $last_exec[$id]['last'] = time();
860
+		}
861
+		}
862
+			$last_exec[$id]['last'] = time();
863 863
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
864 864
 	} elseif (
865
-	    (
865
+		(
866 866
 		$value['format'] === 'whazzup' && 
867 867
 		(
868
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
869
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
868
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
869
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
870 870
 		)
871
-	    ) || (
871
+		) || (
872 872
 		$value['format'] === 'vatsimtxt' && 
873 873
 		(
874
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
875
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
874
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
875
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
876
+		)
876 877
 		)
877
-	    )
878 878
 	) {
879
-	    //$buffer = $Common->getData($hosts[$id]);
880
-	    $buffer = $Common->getData($value['host']);
881
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
882
-	    $buffer = explode('\n',$buffer);
883
-	    $reset = 0;
884
-	    foreach ($buffer as $line) {
885
-    		if ($line != '') {
886
-    		    $line = explode(':', $line);
887
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
879
+		//$buffer = $Common->getData($hosts[$id]);
880
+		$buffer = $Common->getData($value['host']);
881
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
882
+		$buffer = explode('\n',$buffer);
883
+		$reset = 0;
884
+		foreach ($buffer as $line) {
885
+			if ($line != '') {
886
+				$line = explode(':', $line);
887
+				if (count($line) > 30 && $line[0] != 'callsign') {
888 888
 			$data = array();
889 889
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
890 890
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -897,37 +897,37 @@  discard block
 block discarded – undo
897 897
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
898 898
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
899 899
 			$data['latitude'] = $line[5]; // lat
900
-	        	$data['longitude'] = $line[6]; // long
901
-	        	$data['verticalrate'] = ''; // vertical rate
902
-	        	$data['squawk'] = ''; // squawk
903
-	        	$data['emergency'] = ''; // emergency
904
-	        	$data['waypoints'] = $line[30];
900
+				$data['longitude'] = $line[6]; // long
901
+				$data['verticalrate'] = ''; // vertical rate
902
+				$data['squawk'] = ''; // squawk
903
+				$data['emergency'] = ''; // emergency
904
+				$data['waypoints'] = $line[30];
905 905
 			$data['datetime'] = date('Y-m-d H:i:s');
906 906
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
907 907
 			//if (isset($line[37])) $data['last_update'] = $line[37];
908
-		        $data['departure_airport_icao'] = $line[11];
909
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
910
-		        $data['arrival_airport_icao'] = $line[13];
908
+				$data['departure_airport_icao'] = $line[11];
909
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
910
+				$data['arrival_airport_icao'] = $line[13];
911 911
 			$data['frequency'] = $line[4];
912 912
 			$data['type'] = $line[18];
913 913
 			$data['range'] = $line[19];
914 914
 			if (isset($line[35])) $data['info'] = $line[35];
915
-    			$data['id_source'] = $id_source;
916
-	    		//$data['arrival_airport_time'] = ;
917
-	    		if ($line[9] != '') {
918
-	    		    $aircraft_data = explode('/',$line[9]);
919
-	    		    if (isset($aircraft_data[1])) {
920
-	    			$data['aircraft_icao'] = $aircraft_data[1];
921
-	    		    }
922
-        		}
923
-	    		/*
915
+				$data['id_source'] = $id_source;
916
+				//$data['arrival_airport_time'] = ;
917
+				if ($line[9] != '') {
918
+					$aircraft_data = explode('/',$line[9]);
919
+					if (isset($aircraft_data[1])) {
920
+					$data['aircraft_icao'] = $aircraft_data[1];
921
+					}
922
+				}
923
+				/*
924 924
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
925 925
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
926 926
 	    		*/
927
-	    		$data['format_source'] = $value['format'];
927
+				$data['format_source'] = $value['format'];
928 928
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
929 929
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
930
-    			if ($line[3] === 'PILOT') $SI->add($data);
930
+				if ($line[3] === 'PILOT') $SI->add($data);
931 931
 			elseif ($line[3] === 'ATC') {
932 932
 				//print_r($data);
933 933
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -948,21 +948,21 @@  discard block
 block discarded – undo
948 948
 					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']);
949 949
 				}
950 950
 			}
951
-    			unset($data);
952
-    		    }
953
-    		}
954
-    	    }
955
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
956
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
957
-    	    $last_exec[$id]['last'] = time();
958
-    	} elseif ($value['format'] === 'airwhere' && 
959
-    	    (
960
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
961
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
962
-    	    )
963
-    	) {
964
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
965
-	    if ($buffer != '') {
951
+				unset($data);
952
+				}
953
+			}
954
+			}
955
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
956
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
957
+			$last_exec[$id]['last'] = time();
958
+		} elseif ($value['format'] === 'airwhere' && 
959
+			(
960
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
961
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
962
+			)
963
+		) {
964
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
965
+		if ($buffer != '') {
966 966
 		$all_data = simplexml_load_string($buffer);
967 967
 		foreach($all_data->children() as $childdata) {
968 968
 			$data = array();
@@ -984,10 +984,10 @@  discard block
 block discarded – undo
984 984
 			$SI->add($data);
985 985
 			unset($data);
986 986
 		}
987
-	    }
988
-	    $Source->deleteOldLocationByType('gs');
989
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
990
-	    if ($buffer != '') {
987
+		}
988
+		$Source->deleteOldLocationByType('gs');
989
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
990
+		if ($buffer != '') {
991 991
 		$all_data = simplexml_load_string($buffer);
992 992
 		foreach($all_data->children() as $childdata) {
993 993
 			$data = array();
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
 			}
1006 1006
 			unset($data);
1007 1007
 		}
1008
-	    }
1009
-	    $last_exec[$id]['last'] = time();
1008
+		}
1009
+		$last_exec[$id]['last'] = time();
1010 1010
 	/*
1011 1011
 	} if ($value['format'] === 'aircraftlistjson') {
1012 1012
 	    print_r($globalSources);
@@ -1014,17 +1014,17 @@  discard block
 block discarded – undo
1014 1014
 	    echo $globalMinFetch;
1015 1015
 	*/
1016 1016
 	} elseif ($value['format'] === 'aircraftlistjson' && 
1017
-	    (
1017
+		(
1018 1018
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1019 1019
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1020
-	    )
1020
+		)
1021 1021
 	) {
1022
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1023
-	    if ($buffer != '') {
1024
-	        $all_data = json_decode($buffer,true);
1022
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
1023
+		if ($buffer != '') {
1024
+			$all_data = json_decode($buffer,true);
1025 1025
 		if (isset($all_data['acList'])) {
1026
-		    $reset = 0;
1027
-		    foreach ($all_data['acList'] as $line) {
1026
+			$reset = 0;
1027
+			foreach ($all_data['acList'] as $line) {
1028 1028
 			$data = array();
1029 1029
 			$data['hex'] = $line['Icao']; // hex
1030 1030
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1047,10 +1047,10 @@  discard block
 block discarded – undo
1047 1047
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1048 1048
 			if (isset($data['latitude'])) $SI->add($data);
1049 1049
 			unset($data);
1050
-		    }
1050
+			}
1051 1051
 		} elseif (is_array($all_data)) {
1052
-		    $reset = 0;
1053
-		    foreach ($all_data as $line) {
1052
+			$reset = 0;
1053
+			foreach ($all_data as $line) {
1054 1054
 			$data = array();
1055 1055
 			$data['hex'] = $line['hex']; // hex
1056 1056
 			$data['ident'] = $line['flight']; // ident
@@ -1070,291 +1070,291 @@  discard block
 block discarded – undo
1070 1070
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1071 1071
 			$SI->add($data);
1072 1072
 			unset($data);
1073
-		    }
1073
+			}
1074 1074
 		}
1075
-	    } elseif ($globalDebug) echo 'No data'."\n";
1076
-    	    //$last_exec['aircraftlistjson'] = time();
1077
-    	    $last_exec[$id]['last'] = time();
1078
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1079
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1080
-    	    (
1081
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1082
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1083
-    	    )
1084
-    	) {
1085
-	    $buffer = $Common->getData($value['host']);
1086
-	    $all_data = json_decode($buffer,true);
1087
-	    if (isset($all_data['planes'])) {
1075
+		} elseif ($globalDebug) echo 'No data'."\n";
1076
+			//$last_exec['aircraftlistjson'] = time();
1077
+			$last_exec[$id]['last'] = time();
1078
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1079
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1080
+			(
1081
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1082
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1083
+			)
1084
+		) {
1085
+		$buffer = $Common->getData($value['host']);
1086
+		$all_data = json_decode($buffer,true);
1087
+		if (isset($all_data['planes'])) {
1088 1088
 		$reset = 0;
1089 1089
 		foreach ($all_data['planes'] as $key => $line) {
1090
-		    $data = array();
1091
-		    $data['hex'] = $key; // hex
1092
-		    $data['ident'] = $line[3]; // ident
1093
-		    $data['altitude'] = $line[6]; // altitude
1094
-		    $data['speed'] = $line[8]; // speed
1095
-		    $data['heading'] = $line[7]; // heading
1096
-		    $data['latitude'] = $line[4]; // lat
1097
-		    $data['longitude'] = $line[5]; // long
1098
-		    //$data['verticalrate'] = $line[]; // verticale rate
1099
-		    $data['squawk'] = $line[10]; // squawk
1100
-		    $data['emergency'] = ''; // emergency
1101
-		    $data['registration'] = $line[2];
1102
-		    $data['aircraft_icao'] = $line[0];
1103
-		    $deparr = explode('-',$line[1]);
1104
-		    if (count($deparr) === 2) {
1090
+			$data = array();
1091
+			$data['hex'] = $key; // hex
1092
+			$data['ident'] = $line[3]; // ident
1093
+			$data['altitude'] = $line[6]; // altitude
1094
+			$data['speed'] = $line[8]; // speed
1095
+			$data['heading'] = $line[7]; // heading
1096
+			$data['latitude'] = $line[4]; // lat
1097
+			$data['longitude'] = $line[5]; // long
1098
+			//$data['verticalrate'] = $line[]; // verticale rate
1099
+			$data['squawk'] = $line[10]; // squawk
1100
+			$data['emergency'] = ''; // emergency
1101
+			$data['registration'] = $line[2];
1102
+			$data['aircraft_icao'] = $line[0];
1103
+			$deparr = explode('-',$line[1]);
1104
+			if (count($deparr) === 2) {
1105 1105
 			$data['departure_airport_icao'] = $deparr[0];
1106 1106
 			$data['arrival_airport_icao'] = $deparr[1];
1107
-		    }
1108
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1109
-	    	    $data['format_source'] = 'planeupdatefaa';
1110
-    		    $data['id_source'] = $id_source;
1111
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1112
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1113
-		    $SI->add($data);
1114
-		    unset($data);
1107
+			}
1108
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1109
+				$data['format_source'] = 'planeupdatefaa';
1110
+				$data['id_source'] = $id_source;
1111
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1112
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1113
+			$SI->add($data);
1114
+			unset($data);
1115
+		}
1115 1116
 		}
1116
-	    }
1117
-	    //$last_exec['planeupdatefaa'] = time();
1118
-	    $last_exec[$id]['last'] = time();
1117
+		//$last_exec['planeupdatefaa'] = time();
1118
+		$last_exec[$id]['last'] = time();
1119 1119
 	} elseif ($value['format'] === 'opensky' && 
1120
-	    (
1120
+		(
1121 1121
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1122 1122
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1123
-	    )
1123
+		)
1124 1124
 	) {
1125
-	    $buffer = $Common->getData($value['host']);
1126
-	    $all_data = json_decode($buffer,true);
1127
-	    if (isset($all_data['states'])) {
1125
+		$buffer = $Common->getData($value['host']);
1126
+		$all_data = json_decode($buffer,true);
1127
+		if (isset($all_data['states'])) {
1128 1128
 		$reset = 0;
1129 1129
 		foreach ($all_data['states'] as $key => $line) {
1130
-		    $data = array();
1131
-		    $data['hex'] = $line[0]; // hex
1132
-		    $data['ident'] = trim($line[1]); // ident
1133
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1134
-		    $data['speed'] = round($line[9]*1.94384); // speed
1135
-		    $data['heading'] = round($line[10]); // heading
1136
-		    $data['latitude'] = $line[6]; // lat
1137
-		    $data['longitude'] = $line[5]; // long
1138
-		    $data['verticalrate'] = $line[11]; // verticale rate
1139
-		    //$data['squawk'] = $line[10]; // squawk
1140
-		    //$data['emergency'] = ''; // emergency
1141
-		    //$data['registration'] = $line[2];
1142
-		    //$data['aircraft_icao'] = $line[0];
1143
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1144
-		    $data['format_source'] = 'opensky';
1145
-		    $data['id_source'] = $id_source;
1146
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1147
-		    $SI->add($data);
1148
-		    unset($data);
1130
+			$data = array();
1131
+			$data['hex'] = $line[0]; // hex
1132
+			$data['ident'] = trim($line[1]); // ident
1133
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1134
+			$data['speed'] = round($line[9]*1.94384); // speed
1135
+			$data['heading'] = round($line[10]); // heading
1136
+			$data['latitude'] = $line[6]; // lat
1137
+			$data['longitude'] = $line[5]; // long
1138
+			$data['verticalrate'] = $line[11]; // verticale rate
1139
+			//$data['squawk'] = $line[10]; // squawk
1140
+			//$data['emergency'] = ''; // emergency
1141
+			//$data['registration'] = $line[2];
1142
+			//$data['aircraft_icao'] = $line[0];
1143
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1144
+			$data['format_source'] = 'opensky';
1145
+			$data['id_source'] = $id_source;
1146
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1147
+			$SI->add($data);
1148
+			unset($data);
1149 1149
 		}
1150
-	    }
1151
-	    //$last_exec['planeupdatefaa'] = time();
1152
-	    $last_exec[$id]['last'] = time();
1150
+		}
1151
+		//$last_exec['planeupdatefaa'] = time();
1152
+		$last_exec[$id]['last'] = time();
1153 1153
 	} elseif ($value['format'] === 'aircraftjson' && 
1154
-	    (
1154
+		(
1155 1155
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1156 1156
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1157
-	    )
1157
+		)
1158 1158
 	) {
1159
-	    $buffer = $Common->getData($value['host']);
1160
-	    $all_data = json_decode($buffer,true);
1161
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1159
+		$buffer = $Common->getData($value['host']);
1160
+		$all_data = json_decode($buffer,true);
1161
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1162 1162
 		$reset = 0;
1163 1163
 		foreach ($all_data['aircraft'] as $key => $line) {
1164
-		    $data = array();
1165
-		    // add support for ground vehicule with ~ in front of hex
1166
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1167
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1168
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1169
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1170
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1171
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1172
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1173
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1174
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1175
-		    //$data['emergency'] = ''; // emergency
1176
-		    //$data['registration'] = $line[2];
1177
-		    //$data['aircraft_icao'] = $line[0];
1178
-		    $data['datetime'] = date('Y-m-d H:i:s');
1179
-		    $data['format_source'] = 'aircraftjson';
1180
-		    $data['id_source'] = $id_source;
1181
-		    if (isset($value['name']) && $value['name'] != '') {
1182
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1183
-			    else $data['source_name'] = $value['name'];
1184
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1185
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1186
-		    $SI->add($data);
1187
-		    unset($data);
1164
+			$data = array();
1165
+			// add support for ground vehicule with ~ in front of hex
1166
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1167
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1168
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1169
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1170
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1171
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1172
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1173
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1174
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1175
+			//$data['emergency'] = ''; // emergency
1176
+			//$data['registration'] = $line[2];
1177
+			//$data['aircraft_icao'] = $line[0];
1178
+			$data['datetime'] = date('Y-m-d H:i:s');
1179
+			$data['format_source'] = 'aircraftjson';
1180
+			$data['id_source'] = $id_source;
1181
+			if (isset($value['name']) && $value['name'] != '') {
1182
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1183
+				else $data['source_name'] = $value['name'];
1184
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1185
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1186
+			$SI->add($data);
1187
+			unset($data);
1188
+		}
1188 1189
 		}
1189
-	    }
1190
-	    //$last_exec['planeupdatefaa'] = time();
1191
-	    $last_exec[$id]['last'] = time();
1190
+		//$last_exec['planeupdatefaa'] = time();
1191
+		$last_exec[$id]['last'] = time();
1192 1192
 	} elseif ($value['format'] === 'planefinderclient' && 
1193
-	    (
1193
+		(
1194 1194
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1195 1195
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1196
-	    )
1196
+		)
1197 1197
 	) {
1198
-	    $buffer = $Common->getData($value['host']);
1199
-	    $all_data = json_decode($buffer,true);
1200
-	    if (isset($all_data['aircraft'])) {
1198
+		$buffer = $Common->getData($value['host']);
1199
+		$all_data = json_decode($buffer,true);
1200
+		if (isset($all_data['aircraft'])) {
1201 1201
 		$reset = 0;
1202 1202
 		foreach ($all_data['aircraft'] as $key => $line) {
1203
-		    $data = array();
1204
-		    $data['hex'] = $key; // hex
1205
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1206
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1207
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1208
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1209
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1210
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1211
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1212
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1213
-		    //$data['emergency'] = ''; // emergency
1214
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1215
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1216
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1217
-		    $data['format_source'] = 'planefinderclient';
1218
-		    $data['id_source'] = $id_source;
1219
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1220
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1221
-		    $SI->add($data);
1222
-		    unset($data);
1203
+			$data = array();
1204
+			$data['hex'] = $key; // hex
1205
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1206
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1207
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1208
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1209
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1210
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1211
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1212
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1213
+			//$data['emergency'] = ''; // emergency
1214
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1215
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1216
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1217
+			$data['format_source'] = 'planefinderclient';
1218
+			$data['id_source'] = $id_source;
1219
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1220
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1221
+			$SI->add($data);
1222
+			unset($data);
1223 1223
 		}
1224
-	    }
1225
-	    $last_exec[$id]['last'] = time();
1224
+		}
1225
+		$last_exec[$id]['last'] = time();
1226 1226
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1227 1227
 	} elseif ($value['format'] === 'fr24json' && 
1228
-	    (
1228
+		(
1229 1229
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1230 1230
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1231
-	    )
1231
+		)
1232 1232
 	) {
1233
-	    //$buffer = $Common->getData($hosts[$id]);
1234
-	    $buffer = $Common->getData($value['host']);
1235
-	    $all_data = json_decode($buffer,true);
1236
-	    if (!empty($all_data)) $reset = 0;
1237
-	    foreach ($all_data as $key => $line) {
1233
+		//$buffer = $Common->getData($hosts[$id]);
1234
+		$buffer = $Common->getData($value['host']);
1235
+		$all_data = json_decode($buffer,true);
1236
+		if (!empty($all_data)) $reset = 0;
1237
+		foreach ($all_data as $key => $line) {
1238 1238
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1239
-		    $data = array();
1240
-		    $data['hex'] = $line[0];
1241
-		    $data['ident'] = $line[16]; //$line[13]
1242
-	    	    $data['altitude'] = $line[4]; // altitude
1243
-	    	    $data['speed'] = $line[5]; // speed
1244
-	    	    $data['heading'] = $line[3]; // heading
1245
-	    	    $data['latitude'] = $line[1]; // lat
1246
-	    	    $data['longitude'] = $line[2]; // long
1247
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1248
-	    	    $data['squawk'] = $line[6]; // squawk
1249
-	    	    $data['aircraft_icao'] = $line[8];
1250
-	    	    $data['registration'] = $line[9];
1251
-		    $data['departure_airport_iata'] = $line[11];
1252
-		    $data['arrival_airport_iata'] = $line[12];
1253
-	    	    $data['emergency'] = ''; // emergency
1254
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1255
-	    	    $data['format_source'] = 'fr24json';
1256
-    		    $data['id_source'] = $id_source;
1257
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1258
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1259
-		    $SI->add($data);
1260
-		    unset($data);
1239
+			$data = array();
1240
+			$data['hex'] = $line[0];
1241
+			$data['ident'] = $line[16]; //$line[13]
1242
+				$data['altitude'] = $line[4]; // altitude
1243
+				$data['speed'] = $line[5]; // speed
1244
+				$data['heading'] = $line[3]; // heading
1245
+				$data['latitude'] = $line[1]; // lat
1246
+				$data['longitude'] = $line[2]; // long
1247
+				$data['verticalrate'] = $line[15]; // verticale rate
1248
+				$data['squawk'] = $line[6]; // squawk
1249
+				$data['aircraft_icao'] = $line[8];
1250
+				$data['registration'] = $line[9];
1251
+			$data['departure_airport_iata'] = $line[11];
1252
+			$data['arrival_airport_iata'] = $line[12];
1253
+				$data['emergency'] = ''; // emergency
1254
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1255
+				$data['format_source'] = 'fr24json';
1256
+				$data['id_source'] = $id_source;
1257
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1258
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1259
+			$SI->add($data);
1260
+			unset($data);
1261 1261
 		}
1262
-	    }
1263
-	    //$last_exec['fr24json'] = time();
1264
-	    $last_exec[$id]['last'] = time();
1262
+		}
1263
+		//$last_exec['fr24json'] = time();
1264
+		$last_exec[$id]['last'] = time();
1265 1265
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1266 1266
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1267
-	    (
1267
+		(
1268 1268
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1269 1269
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1270
-	    )
1270
+		)
1271 1271
 	) {
1272
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1273
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1274
-	    //echo $buffer;
1275
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1276
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1277
-	    $all_data = json_decode($buffer,true);
1278
-	    if (json_last_error() != JSON_ERROR_NONE) {
1272
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1273
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1274
+		//echo $buffer;
1275
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1276
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1277
+		$all_data = json_decode($buffer,true);
1278
+		if (json_last_error() != JSON_ERROR_NONE) {
1279 1279
 		die(json_last_error_msg());
1280
-	    }
1281
-	    if (isset($all_data['mrkrs'])) {
1280
+		}
1281
+		if (isset($all_data['mrkrs'])) {
1282 1282
 		$reset = 0;
1283 1283
 		foreach ($all_data['mrkrs'] as $key => $line) {
1284
-		    if (isset($line['inf'])) {
1284
+			if (isset($line['inf'])) {
1285 1285
 			$data = array();
1286 1286
 			$data['hex'] = $line['inf']['ia'];
1287 1287
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1288
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1289
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1290
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1291
-	    		$data['latitude'] = $line['pt'][0]; // lat
1292
-	    		$data['longitude'] = $line['pt'][1]; // long
1293
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1294
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1295
-	    		//$data['aircraft_icao'] = $line[8];
1296
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1288
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1289
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1290
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1291
+				$data['latitude'] = $line['pt'][0]; // lat
1292
+				$data['longitude'] = $line['pt'][1]; // long
1293
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1294
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1295
+				//$data['aircraft_icao'] = $line[8];
1296
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1297 1297
 			//$data['departure_airport_iata'] = $line[11];
1298 1298
 			//$data['arrival_airport_iata'] = $line[12];
1299
-	    		//$data['emergency'] = ''; // emergency
1299
+				//$data['emergency'] = ''; // emergency
1300 1300
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1301
-	    		$data['format_source'] = 'radarvirtueljson';
1302
-    			$data['id_source'] = $id_source;
1301
+				$data['format_source'] = 'radarvirtueljson';
1302
+				$data['id_source'] = $id_source;
1303 1303
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1304 1304
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1305 1305
 			$SI->add($data);
1306 1306
 			unset($data);
1307
-		    }
1307
+			}
1308 1308
 		}
1309
-	    }
1310
-	    //$last_exec['radarvirtueljson'] = time();
1311
-	    $last_exec[$id]['last'] = time();
1309
+		}
1310
+		//$last_exec['radarvirtueljson'] = time();
1311
+		$last_exec[$id]['last'] = time();
1312 1312
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1313 1313
 	} elseif ($value['format'] === 'pirepsjson' && 
1314
-	    (
1314
+		(
1315 1315
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1316 1316
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1317
-	    )
1317
+		)
1318 1318
 	) {
1319
-	    //$buffer = $Common->getData($hosts[$id]);
1320
-	    $buffer = $Common->getData($value['host'].'?'.time());
1321
-	    $all_data = json_decode(utf8_encode($buffer),true);
1319
+		//$buffer = $Common->getData($hosts[$id]);
1320
+		$buffer = $Common->getData($value['host'].'?'.time());
1321
+		$all_data = json_decode(utf8_encode($buffer),true);
1322 1322
 	    
1323
-	    if (isset($all_data['pireps'])) {
1323
+		if (isset($all_data['pireps'])) {
1324 1324
 		$reset = 0;
1325
-	        foreach ($all_data['pireps'] as $line) {
1326
-		    $data = array();
1327
-		    $data['id'] = $line['id'];
1328
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1329
-		    $data['ident'] = $line['callsign']; // ident
1330
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1331
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1332
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1333
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1334
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1335
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1336
-		    $data['latitude'] = $line['lat']; // lat
1337
-		    $data['longitude'] = $line['lon']; // long
1338
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1339
-		    //$data['squawk'] = $line['squawk']; // squawk
1340
-		    //$data['emergency'] = ''; // emergency
1341
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1342
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1343
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1344
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1345
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1346
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1347
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1348
-		    else $data['info'] = '';
1349
-		    $data['format_source'] = 'pireps';
1350
-    		    $data['id_source'] = $id_source;
1351
-		    $data['datetime'] = date('Y-m-d H:i:s');
1352
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1353
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1354
-		    if ($line['icon'] === 'plane') {
1325
+			foreach ($all_data['pireps'] as $line) {
1326
+			$data = array();
1327
+			$data['id'] = $line['id'];
1328
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1329
+			$data['ident'] = $line['callsign']; // ident
1330
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1331
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1332
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1333
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1334
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1335
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1336
+			$data['latitude'] = $line['lat']; // lat
1337
+			$data['longitude'] = $line['lon']; // long
1338
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1339
+			//$data['squawk'] = $line['squawk']; // squawk
1340
+			//$data['emergency'] = ''; // emergency
1341
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1342
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1343
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1344
+			//$data['arrival_airport_time'] = $line['arrtime'];
1345
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1346
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1347
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1348
+			else $data['info'] = '';
1349
+			$data['format_source'] = 'pireps';
1350
+				$data['id_source'] = $id_source;
1351
+			$data['datetime'] = date('Y-m-d H:i:s');
1352
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1353
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1354
+			if ($line['icon'] === 'plane') {
1355 1355
 			$SI->add($data);
1356
-		    //    print_r($data);
1357
-    		    } elseif ($line['icon'] === 'ct') {
1356
+			//    print_r($data);
1357
+				} elseif ($line['icon'] === 'ct') {
1358 1358
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1359 1359
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1360 1360
 			$typec = substr($data['ident'],-3);
@@ -1369,209 +1369,209 @@  discard block
 block discarded – undo
1369 1369
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1370 1370
 			else $data['type'] = 'Observer';
1371 1371
 			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']);
1372
-		    }
1373
-		    unset($data);
1372
+			}
1373
+			unset($data);
1374 1374
 		}
1375
-	    }
1376
-	    //$last_exec['pirepsjson'] = time();
1377
-	    $last_exec[$id]['last'] = time();
1375
+		}
1376
+		//$last_exec['pirepsjson'] = time();
1377
+		$last_exec[$id]['last'] = time();
1378 1378
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1379 1379
 	} elseif ($value['format'] === 'phpvmacars' && 
1380
-	    (
1380
+		(
1381 1381
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1382 1382
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1383
-	    )
1383
+		)
1384 1384
 	) {
1385
-	    //$buffer = $Common->getData($hosts[$id]);
1386
-	    if ($globalDebug) echo 'Get Data...'."\n";
1387
-	    $buffer = $Common->getData($value['host']);
1388
-	    $all_data = json_decode($buffer,true);
1389
-	    if ($buffer != '' && is_array($all_data)) {
1385
+		//$buffer = $Common->getData($hosts[$id]);
1386
+		if ($globalDebug) echo 'Get Data...'."\n";
1387
+		$buffer = $Common->getData($value['host']);
1388
+		$all_data = json_decode($buffer,true);
1389
+		if ($buffer != '' && is_array($all_data)) {
1390 1390
 		$reset = 0;
1391 1391
 		foreach ($all_data as $line) {
1392
-	    	    $data = array();
1393
-	    	    //$data['id'] = $line['id']; // id not usable
1394
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1395
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1396
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1397
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1398
-	    	    $data['ident'] = $line['flightnum']; // ident
1399
-	    	    $data['altitude'] = $line['alt']; // altitude
1400
-	    	    $data['speed'] = $line['gs']; // speed
1401
-	    	    $data['heading'] = $line['heading']; // heading
1402
-	    	    $data['latitude'] = $line['lat']; // lat
1403
-	    	    $data['longitude'] = $line['lng']; // long
1404
-	    	    $data['verticalrate'] = ''; // verticale rate
1405
-	    	    $data['squawk'] = ''; // squawk
1406
-	    	    $data['emergency'] = ''; // emergency
1407
-	    	    //$data['datetime'] = $line['lastupdate'];
1408
-	    	    //$data['last_update'] = $line['lastupdate'];
1409
-	    	    if (isset($value['timezone'])) {
1410
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1411
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1412
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1413
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1414
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1415
-	    	    $data['departure_airport_time'] = $line['deptime'];
1416
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1417
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1418
-    		    if (isset($line['registration'])) {
1419
-    			$data['registration'] = $line['registration'];
1420
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1421
-    		    } else $data['registration'] = $line['aircraft'];
1422
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1423
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1424
-		    if (isset($line['aircraftname'])) {
1392
+				$data = array();
1393
+				//$data['id'] = $line['id']; // id not usable
1394
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1395
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1396
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1397
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1398
+				$data['ident'] = $line['flightnum']; // ident
1399
+				$data['altitude'] = $line['alt']; // altitude
1400
+				$data['speed'] = $line['gs']; // speed
1401
+				$data['heading'] = $line['heading']; // heading
1402
+				$data['latitude'] = $line['lat']; // lat
1403
+				$data['longitude'] = $line['lng']; // long
1404
+				$data['verticalrate'] = ''; // verticale rate
1405
+				$data['squawk'] = ''; // squawk
1406
+				$data['emergency'] = ''; // emergency
1407
+				//$data['datetime'] = $line['lastupdate'];
1408
+				//$data['last_update'] = $line['lastupdate'];
1409
+				if (isset($value['timezone'])) {
1410
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1411
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1412
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1413
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1414
+				$data['departure_airport_icao'] = $line['depicao'];
1415
+				$data['departure_airport_time'] = $line['deptime'];
1416
+				$data['arrival_airport_icao'] = $line['arricao'];
1417
+				$data['arrival_airport_time'] = $line['arrtime'];
1418
+				if (isset($line['registration'])) {
1419
+				$data['registration'] = $line['registration'];
1420
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1421
+				} else $data['registration'] = $line['aircraft'];
1422
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1423
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1424
+			if (isset($line['aircraftname'])) {
1425 1425
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1426 1426
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1427
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1428
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1429
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1430
-	    		else {
1431
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1432
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1433
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1434
-	    		}
1435
-	    	    }
1436
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1437
-    		    $data['id_source'] = $id_source;
1438
-	    	    $data['format_source'] = 'phpvmacars';
1439
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1440
-		    $SI->add($data);
1441
-		    unset($data);
1427
+				$aircraft_data = explode('-',$line['aircraftname']);
1428
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1429
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1430
+				else {
1431
+					$aircraft_data = explode(' ',$line['aircraftname']);
1432
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1433
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1434
+				}
1435
+				}
1436
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1437
+				$data['id_source'] = $id_source;
1438
+				$data['format_source'] = 'phpvmacars';
1439
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1440
+			$SI->add($data);
1441
+			unset($data);
1442 1442
 		}
1443 1443
 		if ($globalDebug) echo 'No more data...'."\n";
1444 1444
 		unset($buffer);
1445 1445
 		unset($all_data);
1446
-	    }
1447
-	    //$last_exec['phpvmacars'] = time();
1448
-	    $last_exec[$id]['last'] = time();
1446
+		}
1447
+		//$last_exec['phpvmacars'] = time();
1448
+		$last_exec[$id]['last'] = time();
1449 1449
 	} elseif ($value['format'] === 'vaos' && 
1450
-	    (
1450
+		(
1451 1451
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1452 1452
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1453
-	    )
1453
+		)
1454 1454
 	) {
1455
-	    //$buffer = $Common->getData($hosts[$id]);
1456
-	    if ($globalDebug) echo 'Get Data...'."\n";
1457
-	    $buffer = $Common->getData($value['host']);
1458
-	    $all_data = json_decode($buffer,true);
1459
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1455
+		//$buffer = $Common->getData($hosts[$id]);
1456
+		if ($globalDebug) echo 'Get Data...'."\n";
1457
+		$buffer = $Common->getData($value['host']);
1458
+		$all_data = json_decode($buffer,true);
1459
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1460 1460
 		$reset = 0;
1461 1461
 		foreach ($all_data['ACARSData'] as $line) {
1462
-		    //print_r($line);
1463
-	    	    $data = array();
1464
-	    	    //$data['id'] = $line['id']; // id not usable
1465
-	    	    $data['id'] = $line['id'];
1466
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1467
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1468
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1469
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1470
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1471
-	    	    $data['altitude'] = $line['altitude']; // altitude
1472
-	    	    $data['speed'] = $line['groundspeed']; // speed
1473
-	    	    $data['heading'] = $line['heading']; // heading
1474
-	    	    $data['latitude'] = $line['lat']; // lat
1475
-	    	    $data['longitude'] = $line['lon']; // long
1476
-	    	    //$data['verticalrate'] = ''; // verticale rate
1477
-	    	    //$data['squawk'] = ''; // squawk
1478
-	    	    //$data['emergency'] = ''; // emergency
1479
-	    	    if (isset($value['timezone'])) {
1480
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1481
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1482
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1483
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1462
+			//print_r($line);
1463
+				$data = array();
1464
+				//$data['id'] = $line['id']; // id not usable
1465
+				$data['id'] = $line['id'];
1466
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1467
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1468
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1469
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1470
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1471
+				$data['altitude'] = $line['altitude']; // altitude
1472
+				$data['speed'] = $line['groundspeed']; // speed
1473
+				$data['heading'] = $line['heading']; // heading
1474
+				$data['latitude'] = $line['lat']; // lat
1475
+				$data['longitude'] = $line['lon']; // long
1476
+				//$data['verticalrate'] = ''; // verticale rate
1477
+				//$data['squawk'] = ''; // squawk
1478
+				//$data['emergency'] = ''; // emergency
1479
+				if (isset($value['timezone'])) {
1480
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1481
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1482
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1483
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1484 1484
 	    	    
1485
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1486
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1487
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1488
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1489
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1485
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1486
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1487
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1488
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1489
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1490 1490
 
1491
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1492
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1493
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1491
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1492
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1493
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1494 1494
 
1495
-    		    $data['id_source'] = $id_source;
1496
-	    	    $data['format_source'] = 'vaos';
1497
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1498
-		    $SI->add($data);
1499
-		    unset($data);
1495
+				$data['id_source'] = $id_source;
1496
+				$data['format_source'] = 'vaos';
1497
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1498
+			$SI->add($data);
1499
+			unset($data);
1500 1500
 		}
1501 1501
 		if ($globalDebug) echo 'No more data...'."\n";
1502 1502
 		unset($buffer);
1503 1503
 		unset($all_data);
1504
-	    }
1505
-	    //$last_exec['phpvmacars'] = time();
1506
-	    $last_exec[$id]['last'] = time();
1504
+		}
1505
+		//$last_exec['phpvmacars'] = time();
1506
+		$last_exec[$id]['last'] = time();
1507 1507
 	} elseif ($value['format'] === 'vam' && 
1508
-	    (
1508
+		(
1509 1509
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1510 1510
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1511
-	    )
1511
+		)
1512 1512
 	) {
1513
-	    //$buffer = $Common->getData($hosts[$id]);
1514
-	    if ($globalDebug) echo 'Get Data...'."\n";
1515
-	    $buffer = $Common->getData($value['host']);
1516
-	    $all_data = json_decode($buffer,true);
1517
-	    if ($buffer != '' && is_array($all_data)) {
1513
+		//$buffer = $Common->getData($hosts[$id]);
1514
+		if ($globalDebug) echo 'Get Data...'."\n";
1515
+		$buffer = $Common->getData($value['host']);
1516
+		$all_data = json_decode($buffer,true);
1517
+		if ($buffer != '' && is_array($all_data)) {
1518 1518
 		$reset = 0;
1519 1519
 		foreach ($all_data as $line) {
1520
-	    	    $data = array();
1521
-	    	    //$data['id'] = $line['id']; // id not usable
1522
-	    	    $data['id'] = trim($line['flight_id']);
1523
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1524
-	    	    $data['pilot_name'] = $line['pilot_name'];
1525
-	    	    $data['pilot_id'] = $line['pilot_id'];
1526
-	    	    $data['ident'] = trim($line['callsign']); // ident
1527
-	    	    $data['altitude'] = $line['altitude']; // altitude
1528
-	    	    $data['speed'] = $line['gs']; // speed
1529
-	    	    $data['heading'] = $line['heading']; // heading
1530
-	    	    $data['latitude'] = $line['latitude']; // lat
1531
-	    	    $data['longitude'] = $line['longitude']; // long
1532
-	    	    $data['verticalrate'] = ''; // verticale rate
1533
-	    	    $data['squawk'] = ''; // squawk
1534
-	    	    $data['emergency'] = ''; // emergency
1535
-	    	    //$data['datetime'] = $line['lastupdate'];
1536
-	    	    $data['last_update'] = $line['last_update'];
1537
-		    $data['datetime'] = date('Y-m-d H:i:s');
1538
-	    	    $data['departure_airport_icao'] = $line['departure'];
1539
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1540
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1541
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1542
-    		    //$data['registration'] = $line['aircraft'];
1543
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1544
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1545
-    		    $data['id_source'] = $id_source;
1546
-	    	    $data['format_source'] = 'vam';
1547
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1548
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1549
-		    $SI->add($data);
1550
-		    unset($data);
1520
+				$data = array();
1521
+				//$data['id'] = $line['id']; // id not usable
1522
+				$data['id'] = trim($line['flight_id']);
1523
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1524
+				$data['pilot_name'] = $line['pilot_name'];
1525
+				$data['pilot_id'] = $line['pilot_id'];
1526
+				$data['ident'] = trim($line['callsign']); // ident
1527
+				$data['altitude'] = $line['altitude']; // altitude
1528
+				$data['speed'] = $line['gs']; // speed
1529
+				$data['heading'] = $line['heading']; // heading
1530
+				$data['latitude'] = $line['latitude']; // lat
1531
+				$data['longitude'] = $line['longitude']; // long
1532
+				$data['verticalrate'] = ''; // verticale rate
1533
+				$data['squawk'] = ''; // squawk
1534
+				$data['emergency'] = ''; // emergency
1535
+				//$data['datetime'] = $line['lastupdate'];
1536
+				$data['last_update'] = $line['last_update'];
1537
+			$data['datetime'] = date('Y-m-d H:i:s');
1538
+				$data['departure_airport_icao'] = $line['departure'];
1539
+				//$data['departure_airport_time'] = $line['departure_time'];
1540
+				$data['arrival_airport_icao'] = $line['arrival'];
1541
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1542
+				//$data['registration'] = $line['aircraft'];
1543
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1544
+				$data['aircraft_icao'] = $line['plane_type'];
1545
+				$data['id_source'] = $id_source;
1546
+				$data['format_source'] = 'vam';
1547
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1548
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1549
+			$SI->add($data);
1550
+			unset($data);
1551 1551
 		}
1552 1552
 		if ($globalDebug) echo 'No more data...'."\n";
1553 1553
 		unset($buffer);
1554 1554
 		unset($all_data);
1555
-	    }
1556
-	    //$last_exec['phpvmacars'] = time();
1557
-	    $last_exec[$id]['last'] = time();
1555
+		}
1556
+		//$last_exec['phpvmacars'] = time();
1557
+		$last_exec[$id]['last'] = time();
1558 1558
 	} elseif ($value['format'] === 'blitzortung' && 
1559
-	    (
1559
+		(
1560 1560
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1561 1561
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1562
-	    )
1562
+		)
1563 1563
 	) {
1564
-	    //$buffer = $Common->getData($hosts[$id]);
1565
-	    if ($globalDebug) echo 'Get Data...'."\n";
1566
-	    $buffer = $Common->getData($value['host']);
1567
-	    $all_data = json_decode($buffer,true);
1568
-	    if ($buffer != '') {
1564
+		//$buffer = $Common->getData($hosts[$id]);
1565
+		if ($globalDebug) echo 'Get Data...'."\n";
1566
+		$buffer = $Common->getData($value['host']);
1567
+		$all_data = json_decode($buffer,true);
1568
+		if ($buffer != '') {
1569 1569
 		$Source->deleteLocationBySource('blitzortung');
1570 1570
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1571 1571
 		$buffer = explode('\n',$buffer);
1572 1572
 		foreach ($buffer as $buffer_line) {
1573
-		    $line = json_decode($buffer_line,true);
1574
-		    if (isset($line['time'])) {
1573
+			$line = json_decode($buffer_line,true);
1574
+			if (isset($line['time'])) {
1575 1575
 			$data = array();
1576 1576
 			$data['altitude'] = $line['alt']; // altitude
1577 1577
 			$data['latitude'] = $line['lat']; // lat
@@ -1583,92 +1583,92 @@  discard block
 block discarded – undo
1583 1583
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1584 1584
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1585 1585
 			unset($data);
1586
-		    }
1586
+			}
1587 1587
 		}
1588 1588
 		if ($globalDebug) echo 'No more data...'."\n";
1589 1589
 		unset($buffer);
1590
-	    }
1591
-	    $last_exec[$id]['last'] = time();
1590
+		}
1591
+		$last_exec[$id]['last'] = time();
1592 1592
 	} elseif ($value['format'] === 'acarsjson') {
1593
-        $arr = $httpfeeds;
1594
-        $w = $e = null;
1595
-        if (isset($arr[$id])) {
1596
-            $nn = stream_select($arr,$w,$e,$timeout);
1597
-            if ($nn > 0) {
1598
-                foreach ($httpfeeds as $feed) {
1599
-                    $buffer = stream_get_line($feed,2000,"\n");
1600
-                    if ($buffer === FALSE) {
1601
-                        connect_all($globalSources);
1602
-                    }
1603
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1604
-                    $buffer = explode('\n',$buffer);
1605
-                    foreach ($buffer as $line) {
1606
-                        if ($line != '') {
1607
-                            $line = json_decode($line, true);
1608
-                            if (!empty($line)) {
1609
-                                $ACARS->add($line['text'], array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => $line['text']));
1610
-                                $ACARS->deleteLiveAcarsData();
1611
-                            }
1612
-                        }
1613
-                    }
1614
-                }
1615
-            } else {
1616
-                $format = $value['format'];
1617
-                if (isset($tt[$format])) $tt[$format]++;
1618
-                else $tt[$format] = 0;
1619
-                if ($tt[$format] > 30) {
1620
-                    if ($globalDebug) echo 'Reconnect...'."\n";
1621
-                    sleep(2);
1622
-                    //$sourceeen[] = $value;
1623
-                    //connect_all($sourceeen);
1624
-                    //$sourceeen = array();
1625
-                    connect_all($globalSources);
1626
-                }
1627
-            }
1628
-        }
1593
+		$arr = $httpfeeds;
1594
+		$w = $e = null;
1595
+		if (isset($arr[$id])) {
1596
+			$nn = stream_select($arr,$w,$e,$timeout);
1597
+			if ($nn > 0) {
1598
+				foreach ($httpfeeds as $feed) {
1599
+					$buffer = stream_get_line($feed,2000,"\n");
1600
+					if ($buffer === FALSE) {
1601
+						connect_all($globalSources);
1602
+					}
1603
+					$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1604
+					$buffer = explode('\n',$buffer);
1605
+					foreach ($buffer as $line) {
1606
+						if ($line != '') {
1607
+							$line = json_decode($line, true);
1608
+							if (!empty($line)) {
1609
+								$ACARS->add($line['text'], array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => $line['text']));
1610
+								$ACARS->deleteLiveAcarsData();
1611
+							}
1612
+						}
1613
+					}
1614
+				}
1615
+			} else {
1616
+				$format = $value['format'];
1617
+				if (isset($tt[$format])) $tt[$format]++;
1618
+				else $tt[$format] = 0;
1619
+				if ($tt[$format] > 30) {
1620
+					if ($globalDebug) echo 'Reconnect...'."\n";
1621
+					sleep(2);
1622
+					//$sourceeen[] = $value;
1623
+					//connect_all($sourceeen);
1624
+					//$sourceeen = array();
1625
+					connect_all($globalSources);
1626
+				}
1627
+			}
1628
+		}
1629 1629
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1630 1630
 	} 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') {
1631
-	    //$last_exec[$id]['last'] = time();
1632
-	    //$read = array( $sockets[$id] );
1633
-	    $read = $sockets;
1634
-	    $write = NULL;
1635
-	    $e = NULL;
1636
-	    $n = socket_select($read, $write, $e, $timeout);
1637
-	    if ($e != NULL) var_dump($e);
1638
-	    if ($n > 0) {
1631
+		//$last_exec[$id]['last'] = time();
1632
+		//$read = array( $sockets[$id] );
1633
+		$read = $sockets;
1634
+		$write = NULL;
1635
+		$e = NULL;
1636
+		$n = socket_select($read, $write, $e, $timeout);
1637
+		if ($e != NULL) var_dump($e);
1638
+		if ($n > 0) {
1639 1639
 		$reset = 0;
1640 1640
 		foreach ($read as $nb => $r) {
1641
-		    //$value = $formats[$nb];
1642
-		    $format = $globalSources[$nb]['format'];
1643
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1641
+			//$value = $formats[$nb];
1642
+			$format = $globalSources[$nb]['format'];
1643
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1644 1644
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1645
-		    } elseif ($format === 'vrstcp') {
1645
+			} elseif ($format === 'vrstcp') {
1646 1646
 			$buffer = @socket_read($r, 6000);
1647
-		    } else {
1647
+			} else {
1648 1648
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1649
-		    }
1650
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1651
-		    //echo $buffer."\n";
1652
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1653
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1654
-		    $error = false;
1655
-		    //$SI::del();
1656
-		    if ($buffer !== FALSE) {
1649
+			}
1650
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1651
+			//echo $buffer."\n";
1652
+			// lets play nice and handle signals such as ctrl-c/kill properly
1653
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1654
+			$error = false;
1655
+			//$SI::del();
1656
+			if ($buffer !== FALSE) {
1657 1657
 			if ($format === 'vrstcp') {
1658
-			    $buffer = explode('},{',$buffer);
1658
+				$buffer = explode('},{',$buffer);
1659 1659
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1660
-		    }
1661
-		    // SBS format is CSV format
1662
-		    if ($buffer !== FALSE && $buffer !== '') {
1660
+			}
1661
+			// SBS format is CSV format
1662
+			if ($buffer !== FALSE && $buffer !== '') {
1663 1663
 			$tt[$format] = 0;
1664 1664
 			if ($format === 'acarssbs3') {
1665
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1666
-			    $ACARS->add(trim($buffer));
1667
-			    $ACARS->deleteLiveAcarsData();
1665
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1666
+				$ACARS->add(trim($buffer));
1667
+				$ACARS->deleteLiveAcarsData();
1668 1668
 			} elseif ($format === 'raw') {
1669
-			    // AVR format
1670
-			    $data = $SBS->parse($buffer);
1671
-			    if (is_array($data)) {
1669
+				// AVR format
1670
+				$data = $SBS->parse($buffer);
1671
+				if (is_array($data)) {
1672 1672
 				//if (!empty($data)) print_r($data);
1673 1673
 				$data['datetime'] = date('Y-m-d H:i:s');
1674 1674
 				$data['format_source'] = 'raw';
@@ -1678,39 +1678,39 @@  discard block
 block discarded – undo
1678 1678
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1679 1679
 				$SI->add($data);
1680 1680
 				unset($data);
1681
-			    }
1681
+				}
1682 1682
 			} elseif ($format === 'ais') {
1683
-			    $ais_data = $AIS->parse_line(trim($buffer));
1684
-			    $data = array();
1685
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1686
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1687
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1688
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1689
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1690
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1691
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1692
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1693
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1694
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1695
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1696
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1697
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1698
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1699
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1700
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1683
+				$ais_data = $AIS->parse_line(trim($buffer));
1684
+				$data = array();
1685
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1686
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1687
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1688
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1689
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1690
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1691
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1692
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1693
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1694
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1695
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1696
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1697
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1698
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1699
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1700
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1701 1701
 
1702
-			    if (isset($ais_data['timestamp'])) {
1702
+				if (isset($ais_data['timestamp'])) {
1703 1703
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1704
-			    } else {
1704
+				} else {
1705 1705
 				$data['datetime'] = date('Y-m-d H:i:s');
1706
-			    }
1707
-			    $data['format_source'] = 'aisnmea';
1708
-    			    $data['id_source'] = $id_source;
1709
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1710
-			    unset($data);
1711
-                        } elseif ($format === 'flightgearsp') {
1712
-                    	    //echo $buffer."\n";
1713
-                    	    if (strlen($buffer) > 5) {
1706
+				}
1707
+				$data['format_source'] = 'aisnmea';
1708
+					$data['id_source'] = $id_source;
1709
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1710
+				unset($data);
1711
+						} elseif ($format === 'flightgearsp') {
1712
+							//echo $buffer."\n";
1713
+							if (strlen($buffer) > 5) {
1714 1714
 				$line = explode(',',$buffer);
1715 1715
 				$data = array();
1716 1716
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1727,38 +1727,38 @@  discard block
 block discarded – undo
1727 1727
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1728 1728
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1729 1729
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1730
-			    }
1731
-                        } elseif ($format === 'acars') {
1732
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1733
-			    $ACARS->add(trim($buffer));
1734
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1735
-			    $ACARS->deleteLiveAcarsData();
1730
+				}
1731
+						} elseif ($format === 'acars') {
1732
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1733
+				$ACARS->add(trim($buffer));
1734
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1735
+				$ACARS->deleteLiveAcarsData();
1736 1736
 			} elseif ($format === 'flightgearmp') {
1737
-			    if (substr($buffer,0,1) != '#') {
1737
+				if (substr($buffer,0,1) != '#') {
1738 1738
 				$data = array();
1739 1739
 				//echo $buffer."\n";
1740 1740
 				$line = explode(' ',$buffer);
1741 1741
 				if (count($line) === 11) {
1742
-				    $userserver = explode('@',$line[0]);
1743
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1744
-				    $data['ident'] = $userserver[0];
1745
-				    $data['registration'] = $userserver[0];
1746
-				    $data['latitude'] = $line[4];
1747
-				    $data['longitude'] = $line[5];
1748
-				    $data['altitude'] = $line[6];
1749
-				    $data['datetime'] = date('Y-m-d H:i:s');
1750
-				    $aircraft_type = $line[10];
1751
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1752
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1753
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1754
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1742
+					$userserver = explode('@',$line[0]);
1743
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1744
+					$data['ident'] = $userserver[0];
1745
+					$data['registration'] = $userserver[0];
1746
+					$data['latitude'] = $line[4];
1747
+					$data['longitude'] = $line[5];
1748
+					$data['altitude'] = $line[6];
1749
+					$data['datetime'] = date('Y-m-d H:i:s');
1750
+					$aircraft_type = $line[10];
1751
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1752
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1753
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1754
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1755
+				}
1755 1756
 				}
1756
-			    }
1757 1757
 			} elseif ($format === 'beast') {
1758
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1759
-			    die;
1758
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1759
+				die;
1760 1760
 			} elseif ($format === 'vrstcp') {
1761
-			    foreach($buffer as $all_data) {
1761
+				foreach($buffer as $all_data) {
1762 1762
 				$line = json_decode('{'.$all_data.'}',true);
1763 1763
 				$data = array();
1764 1764
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1778,158 +1778,158 @@  discard block
 block discarded – undo
1778 1778
 				*/
1779 1779
 				$data['datetime'] = date('Y-m-d H:i:s');
1780 1780
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1781
-		    		$data['format_source'] = 'vrstcp';
1781
+					$data['format_source'] = 'vrstcp';
1782 1782
 				$data['id_source'] = $id_source;
1783 1783
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1784 1784
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1785 1785
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1786 1786
 				unset($data);
1787
-			    }
1787
+				}
1788 1788
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1789
-			    $line = explode("\t", $buffer);
1790
-			    for($k = 0; $k < count($line); $k=$k+2) {
1789
+				$line = explode("\t", $buffer);
1790
+				for($k = 0; $k < count($line); $k=$k+2) {
1791 1791
 				$key = $line[$k];
1792
-			        $lined[$key] = $line[$k+1];
1793
-			    }
1794
-    			    if (count($lined) > 3) {
1795
-    				$data['hex'] = $lined['hexid'];
1796
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1797
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1798
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1799
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1800
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1801
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1802
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1803
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1804
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1805
-    				$data['id_source'] = $id_source;
1806
-    				$data['format_source'] = 'tsv';
1807
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1808
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1792
+					$lined[$key] = $line[$k+1];
1793
+				}
1794
+					if (count($lined) > 3) {
1795
+					$data['hex'] = $lined['hexid'];
1796
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1797
+					$data['datetime'] = date('Y-m-d H:i:s');;
1798
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1799
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1800
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1801
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1802
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1803
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1804
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1805
+					$data['id_source'] = $id_source;
1806
+					$data['format_source'] = 'tsv';
1807
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1808
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1809 1809
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1810
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1811
-    				unset($lined);
1812
-    				unset($data);
1813
-    			    } else $error = true;
1810
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1811
+					unset($lined);
1812
+					unset($data);
1813
+					} else $error = true;
1814 1814
 			} elseif ($format === 'aprs' && $use_aprs) {
1815
-			    if ($aprs_connect === 0) {
1815
+				if ($aprs_connect === 0) {
1816 1816
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1817 1817
 				$aprs_connect = 1;
1818
-			    }
1818
+				}
1819 1819
 			    
1820
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1820
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1821 1821
 				$aprs_last_tx = time();
1822 1822
 				$data_aprs = "# Keep alive";
1823 1823
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1824
-			    }
1824
+				}
1825 1825
 			    
1826
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1827
-			    //echo 'APRS data : '.$buffer."\n";
1828
-			    $buffer = str_replace('APRS <- ','',$buffer);
1829
-			    $buffer = str_replace('APRS -> ','',$buffer);
1830
-			    //echo $buffer."\n";
1831
-			    date_default_timezone_set('UTC');
1832
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1826
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1827
+				//echo 'APRS data : '.$buffer."\n";
1828
+				$buffer = str_replace('APRS <- ','',$buffer);
1829
+				$buffer = str_replace('APRS -> ','',$buffer);
1830
+				//echo $buffer."\n";
1831
+				date_default_timezone_set('UTC');
1832
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1833 1833
 				$line = $APRS->parse($buffer);
1834 1834
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1835 1835
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1836
-				    $aprs_last_tx = time();
1837
-				    $data = array();
1838
-				    //print_r($line);
1839
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1840
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1841
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1842
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1843
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1844
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1845
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1846
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1847
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1848
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1849
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1850
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1851
-				    $data['latitude'] = $line['latitude'];
1852
-				    $data['longitude'] = $line['longitude'];
1853
-				    //$data['verticalrate'] = $line[16];
1854
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1855
-				    //else $data['speed'] = 0;
1856
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1857
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1858
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1859
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1836
+					$aprs_last_tx = time();
1837
+					$data = array();
1838
+					//print_r($line);
1839
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1840
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1841
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1842
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1843
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1844
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1845
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1846
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1847
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1848
+					else $data['datetime'] = date('Y-m-d H:i:s');
1849
+					//$data['datetime'] = date('Y-m-d H:i:s');
1850
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1851
+					$data['latitude'] = $line['latitude'];
1852
+					$data['longitude'] = $line['longitude'];
1853
+					//$data['verticalrate'] = $line[16];
1854
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1855
+					//else $data['speed'] = 0;
1856
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1857
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1858
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1859
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1860 1860
 				    
1861
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1862
-				    //else echo 'No heading...'."\n";
1863
-				    //else $data['heading'] = 0;
1864
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1865
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1866
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1867
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1868
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1869
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1870
-    				    $data['id_source'] = $id_source;
1871
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1872
-				    else $data['format_source'] = 'aprs';
1873
-				    $data['source_name'] = $line['source'];
1874
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1875
-				    else $data['source_type'] = 'flarm';
1876
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1877
-				    $currentdate = date('Y-m-d H:i:s');
1878
-				    $aprsdate = strtotime($data['datetime']);
1879
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1880
-				    // Accept data if time <= system time + 20s
1881
-				    //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'])))) {
1882
-				    if (
1861
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1862
+					//else echo 'No heading...'."\n";
1863
+					//else $data['heading'] = 0;
1864
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1865
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1866
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1867
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1868
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1869
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1870
+						$data['id_source'] = $id_source;
1871
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1872
+					else $data['format_source'] = 'aprs';
1873
+					$data['source_name'] = $line['source'];
1874
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1875
+					else $data['source_type'] = 'flarm';
1876
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1877
+					$currentdate = date('Y-m-d H:i:s');
1878
+					$aprsdate = strtotime($data['datetime']);
1879
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1880
+					// Accept data if time <= system time + 20s
1881
+					//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'])))) {
1882
+					if (
1883 1883
 					($data['source_type'] === 'modes') || 
1884 1884
 					isset($line['stealth']) && 
1885 1885
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1886 1886
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1887 1887
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1888 1888
 					$send = $SI->add($data);
1889
-				    } elseif ($data['source_type'] === 'ais') {
1889
+					} elseif ($data['source_type'] === 'ais') {
1890 1890
 					$data['type'] = '';
1891 1891
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1892
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1892
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1893 1893
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1894
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1895
-					    //$line['symbol'] === 'Balloon' ||
1896
-					    $line['symbol'] === 'Glider' || 
1897
-					    $line['symbol'] === 'No. Plane' || 
1898
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1899
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1900
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1901
-					    $send = $SI->add($data);
1902
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1903
-					    $line['symbol'] === 'Yacht (Sail)' || 
1904
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1905
-					    $send = $MI->add($data);
1906
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1907
-					    $line['symbol'] === 'Car' || 
1908
-					    $line['symbol'] === 'Ambulance' || 
1909
-					    $line['symbol'] === 'Van' || 
1910
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1911
-					    $line['symbol'] === 'Motorcycle' || 
1912
-					    $line['symbol'] === 'Tractor' || 
1913
-					    $line['symbol'] === 'Police' || 
1914
-					    $line['symbol'] === 'Bike' || 
1915
-					    $line['symbol'] === 'Jogger' || 
1916
-					    $line['symbol'] === 'Horse' || 
1917
-					    $line['symbol'] === 'Bus' || 
1918
-					    $line['symbol'] === 'Jeep' || 
1919
-					    $line['symbol'] === 'Recreational Vehicle' || 
1920
-					    $line['symbol'] === 'Yacht (Sail)' || 
1921
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1922
-					    $line['symbol'] === 'Firetruck' || 
1923
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1924
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1925
-					    $line['symbol'] === 'SUV' ||
1926
-					    $line['symbol'] === 'Snowmobile' ||
1927
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1928
-				    //} 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') {
1894
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1895
+						//$line['symbol'] === 'Balloon' ||
1896
+						$line['symbol'] === 'Glider' || 
1897
+						$line['symbol'] === 'No. Plane' || 
1898
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1899
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1900
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1901
+						$send = $SI->add($data);
1902
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1903
+						$line['symbol'] === 'Yacht (Sail)' || 
1904
+						$line['symbol'] === 'Ship (Power Boat)')) {
1905
+						$send = $MI->add($data);
1906
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1907
+						$line['symbol'] === 'Car' || 
1908
+						$line['symbol'] === 'Ambulance' || 
1909
+						$line['symbol'] === 'Van' || 
1910
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1911
+						$line['symbol'] === 'Motorcycle' || 
1912
+						$line['symbol'] === 'Tractor' || 
1913
+						$line['symbol'] === 'Police' || 
1914
+						$line['symbol'] === 'Bike' || 
1915
+						$line['symbol'] === 'Jogger' || 
1916
+						$line['symbol'] === 'Horse' || 
1917
+						$line['symbol'] === 'Bus' || 
1918
+						$line['symbol'] === 'Jeep' || 
1919
+						$line['symbol'] === 'Recreational Vehicle' || 
1920
+						$line['symbol'] === 'Yacht (Sail)' || 
1921
+						$line['symbol'] === 'Ship (Power Boat)' || 
1922
+						$line['symbol'] === 'Firetruck' || 
1923
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1924
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1925
+						$line['symbol'] === 'SUV' ||
1926
+						$line['symbol'] === 'Snowmobile' ||
1927
+						$line['symbol'] === 'Mobile Satellite Station')) {
1928
+					//} 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') {
1929 1929
 				//    } 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') {
1930 1930
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1931 1931
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1932
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1932
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1933 1933
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1934 1934
 					$Source->deleteOldLocationByType('gs');
1935 1935
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1937,7 +1937,7 @@  discard block
 block discarded – undo
1937 1937
 					} else {
1938 1938
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1939 1939
 					}
1940
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1940
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1941 1941
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1942 1942
 					if ($globalDebug) echo '# Weather Station added'."\n";
1943 1943
 					$Source->deleteOldLocationByType('wx');
@@ -1947,7 +1947,7 @@  discard block
 block discarded – undo
1947 1947
 					} else {
1948 1948
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1949 1949
 					}
1950
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1950
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1951 1951
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1952 1952
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1953 1953
 					$Source->deleteOldLocationByType('lightning');
@@ -1956,11 +1956,11 @@  discard block
 block discarded – undo
1956 1956
 					} else {
1957 1957
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1958 1958
 					}
1959
-				    } elseif ($globalDebug) {
1960
-				    	echo '/!\ Not added: '.$buffer."\n";
1961
-				    	print_r($line);
1962
-				    }
1963
-				    unset($data);
1959
+					} elseif ($globalDebug) {
1960
+						echo '/!\ Not added: '.$buffer."\n";
1961
+						print_r($line);
1962
+					}
1963
+					unset($data);
1964 1964
 				}
1965 1965
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1966 1966
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1979,13 +1979,13 @@  discard block
 block discarded – undo
1979 1979
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1980 1980
 					$globalSources[$nb]['last_weather_clean'] = time();
1981 1981
 				}
1982
-			    }
1982
+				}
1983 1983
 			} else {
1984
-			    $line = explode(',', $buffer);
1985
-			    //print_r($line);
1986
-    			    if (count($line) > 20) {
1987
-    			    	$data['hex'] = $line[4];
1988
-    				/*
1984
+				$line = explode(',', $buffer);
1985
+				//print_r($line);
1986
+					if (count($line) > 20) {
1987
+						$data['hex'] = $line[4];
1988
+					/*
1989 1989
     				$data['datetime'] = $line[6].' '.$line[7];
1990 1990
     					date_default_timezone_set($globalTimezone);
1991 1991
     					$datetime = new DateTime($data['datetime']);
@@ -1993,31 +1993,31 @@  discard block
 block discarded – undo
1993 1993
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1994 1994
     					date_default_timezone_set('UTC');
1995 1995
     				*/
1996
-    				// Force datetime to current UTC datetime
1997
-    				date_default_timezone_set('UTC');
1998
-    				$data['datetime'] = date('Y-m-d H:i:s');
1999
-    				$data['ident'] = trim($line[10]);
2000
-    				$data['latitude'] = $line[14];
2001
-    				$data['longitude'] = $line[15];
2002
-    				$data['verticalrate'] = $line[16];
2003
-    				$data['emergency'] = $line[20];
2004
-    				$data['speed'] = $line[12];
2005
-    				$data['squawk'] = $line[17];
2006
-    				$data['altitude'] = $line[11];
2007
-    				$data['heading'] = $line[13];
2008
-    				$data['ground'] = $line[21];
2009
-    				$data['emergency'] = $line[19];
2010
-    				$data['format_source'] = 'sbs';
1996
+					// Force datetime to current UTC datetime
1997
+					date_default_timezone_set('UTC');
1998
+					$data['datetime'] = date('Y-m-d H:i:s');
1999
+					$data['ident'] = trim($line[10]);
2000
+					$data['latitude'] = $line[14];
2001
+					$data['longitude'] = $line[15];
2002
+					$data['verticalrate'] = $line[16];
2003
+					$data['emergency'] = $line[20];
2004
+					$data['speed'] = $line[12];
2005
+					$data['squawk'] = $line[17];
2006
+					$data['altitude'] = $line[11];
2007
+					$data['heading'] = $line[13];
2008
+					$data['ground'] = $line[21];
2009
+					$data['emergency'] = $line[19];
2010
+					$data['format_source'] = 'sbs';
2011 2011
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2012 2012
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2013
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2013
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2014 2014
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2015
-    				$data['id_source'] = $id_source;
2016
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2017
-    				else $error = true;
2018
-    				unset($data);
2019
-    			    } else $error = true;
2020
-			    if ($error) {
2015
+					$data['id_source'] = $id_source;
2016
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2017
+					else $error = true;
2018
+					unset($data);
2019
+					} else $error = true;
2020
+				if ($error) {
2021 2021
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2022 2022
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
2023 2023
 				} else {
@@ -2033,13 +2033,13 @@  discard block
 block discarded – undo
2033 2033
 					connect_all($sourceer);
2034 2034
 					$sourceer = array();
2035 2035
 				}
2036
-			    }
2036
+				}
2037 2037
 			}
2038 2038
 			// Sleep for xxx microseconds
2039 2039
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2040
-		    } else {
2040
+			} else {
2041 2041
 			if ($format === 'flightgearmp') {
2042
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2042
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
2043 2043
 				//@socket_close($r);
2044 2044
 				sleep($globalMinFetch);
2045 2045
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2048,9 +2048,9 @@  discard block
 block discarded – undo
2048 2048
 				break;
2049 2049
 				
2050 2050
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2051
-			    if (isset($tt[$format])) $tt[$format]++;
2052
-			    else $tt[$format] = 0;
2053
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
2051
+				if (isset($tt[$format])) $tt[$format]++;
2052
+				else $tt[$format] = 0;
2053
+				if ($tt[$format] > 30 || $buffer === FALSE) {
2054 2054
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2055 2055
 				//@socket_close($r);
2056 2056
 				sleep(2);
@@ -2061,24 +2061,24 @@  discard block
 block discarded – undo
2061 2061
 				//connect_all($globalSources);
2062 2062
 				$tt[$format]=0;
2063 2063
 				break;
2064
-			    } 
2065
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2064
+				} 
2065
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2066
+			}
2066 2067
 			}
2067
-		    }
2068 2068
 		}
2069
-	    } else {
2069
+		} else {
2070 2070
 		$error = socket_strerror(socket_last_error());
2071 2071
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2072 2072
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2073 2073
 			if (isset($globalDebug)) echo "Restarting...\n";
2074 2074
 			// Restart the script if possible
2075 2075
 			if (is_array($sockets)) {
2076
-			    if ($globalDebug) echo "Shutdown all sockets...";
2076
+				if ($globalDebug) echo "Shutdown all sockets...";
2077 2077
 			    
2078
-			    foreach ($sockets as $sock) {
2078
+				foreach ($sockets as $sock) {
2079 2079
 				@socket_shutdown($sock,2);
2080 2080
 				@socket_close($sock);
2081
-			    }
2081
+				}
2082 2082
 			    
2083 2083
 			}
2084 2084
 			if ($globalDebug) echo "Waiting...";
@@ -2093,15 +2093,15 @@  discard block
 block discarded – undo
2093 2093
 			if ($globalDebug) echo "Restart all connections...";
2094 2094
 			connect_all($globalSources);
2095 2095
 		}
2096
-	    }
2096
+		}
2097 2097
 	}
2098 2098
 	if ($globalDaemon === false) {
2099
-	    if ($globalDebug) echo 'Check all...'."\n";
2100
-	    if (isset($SI)) $SI->checkAll();
2101
-	    if (isset($TI)) $TI->checkAll();
2102
-	    if (isset($MI)) $MI->checkAll();
2099
+		if ($globalDebug) echo 'Check all...'."\n";
2100
+		if (isset($SI)) $SI->checkAll();
2101
+		if (isset($TI)) $TI->checkAll();
2102
+		if (isset($MI)) $MI->checkAll();
2103
+	}
2103 2104
 	}
2104
-    }
2105 2105
 }
2106 2106
 
2107 2107
 ?>
Please login to merge, or discard this patch.
Spacing   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 	    die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
62
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
63 63
     }
64 64
 }
65 65
 
66
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
66
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70 70
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
71
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
72 72
     else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74 74
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
76 76
     else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115 115
     if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
116
+    $SI = new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
120 120
     $SI->connect();
121 121
 */
122
-} else $SI=new SpotterImport($Connection->db);
122
+} else $SI = new SpotterImport($Connection->db);
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     $MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136
-$SBS=new SBS();
136
+$SBS = new SBS();
137 137
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
-	$ACARS=new ACARS($Connection->db,true);
139
-	$Source=new Source($Connection->db);
138
+	$ACARS = new ACARS($Connection->db, true);
139
+	$Source = new Source($Connection->db);
140 140
 }
141
-$Common=new Common();
141
+$Common = new Common();
142 142
 date_default_timezone_set('UTC');
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
146
+    pcntl_signal(SIGINT, function() {
147 147
         global $sockets;
148 148
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149 149
         die("Bye!\n");
@@ -159,40 +159,40 @@  discard block
 block discarded – undo
159 159
 
160 160
 function connect_all($hosts) {
161 161
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
162
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
163 163
     $reset++;
164 164
     if ($globalDebug) echo 'Connect to all...'."\n";
165 165
     foreach ($hosts as $id => $value) {
166 166
 	$host = $value['host'];
167 167
 	$globalSources[$id]['last_exec'] = 0;
168 168
 	// Here we check type of source(s)
169
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
170
-            if (preg_match('/deltadb.txt$/i',$host)) {
169
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
170
+            if (preg_match('/deltadb.txt$/i', $host)) {
171 171
         	//$formats[$id] = 'deltadbtxt';
172 172
         	$globalSources[$id]['format'] = 'deltadbtxt';
173 173
         	//$last_exec['deltadbtxt'] = 0;
174 174
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
175
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
175
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
176 176
         	//$formats[$id] = 'vatsimtxt';
177 177
         	$globalSources[$id]['format'] = 'vatsimtxt';
178 178
         	//$last_exec['vatsimtxt'] = 0;
179 179
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
180
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
180
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
181 181
         	//$formats[$id] = 'aircraftlistjson';
182 182
         	$globalSources[$id]['format'] = 'aircraftlistjson';
183 183
         	//$last_exec['aircraftlistjson'] = 0;
184 184
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
185
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
185
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
186 186
         	//$formats[$id] = 'aircraftjson';
187 187
         	$globalSources[$id]['format'] = 'aircraftjson';
188 188
         	//$last_exec['aircraftlistjson'] = 0;
189 189
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
190
-    	    } else if (preg_match('/aircraft$/i',$host)) {
190
+    	    } else if (preg_match('/aircraft$/i', $host)) {
191 191
         	//$formats[$id] = 'planefinderclient';
192 192
         	$globalSources[$id]['format'] = 'planefinderclient';
193 193
         	//$last_exec['aircraftlistjson'] = 0;
194 194
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
195
-    	    } else if (preg_match('/opensky/i',$host)) {
195
+    	    } else if (preg_match('/opensky/i', $host)) {
196 196
         	//$formats[$id] = 'aircraftlistjson';
197 197
         	$globalSources[$id]['format'] = 'opensky';
198 198
         	//$last_exec['aircraftlistjson'] = 0;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         	    exit(0);
210 210
         	}
211 211
     	    */
212
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
212
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
213 213
         	//$formats[$id] = 'planeupdatefaa';
214 214
         	$globalSources[$id]['format'] = 'planeupdatefaa';
215 215
         	//$last_exec['planeupdatefaa'] = 0;
@@ -218,37 +218,37 @@  discard block
 block discarded – undo
218 218
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
219 219
         	    exit(0);
220 220
         	}
221
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
221
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
222 222
         	//$formats[$id] = 'phpvmacars';
223 223
         	$globalSources[$id]['format'] = 'phpvmacars';
224 224
         	//$last_exec['phpvmacars'] = 0;
225 225
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
226
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
226
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
227 227
         	//$formats[$id] = 'phpvmacars';
228 228
         	$globalSources[$id]['format'] = 'vaos';
229 229
         	//$last_exec['phpvmacars'] = 0;
230 230
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
231
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
231
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
232 232
         	//$formats[$id] = 'phpvmacars';
233 233
         	$globalSources[$id]['format'] = 'vam';
234 234
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
235
-            } else if (preg_match('/whazzup/i',$host)) {
235
+            } else if (preg_match('/whazzup/i', $host)) {
236 236
         	//$formats[$id] = 'whazzup';
237 237
         	$globalSources[$id]['format'] = 'whazzup';
238 238
         	//$last_exec['whazzup'] = 0;
239 239
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
240
-            } else if (preg_match('/blitzortung/i',$host)) {
240
+            } else if (preg_match('/blitzortung/i', $host)) {
241 241
         	$globalSources[$id]['format'] = 'blitzortung';
242 242
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
243
-            } else if (preg_match('/airwhere/i',$host)) {
243
+            } else if (preg_match('/airwhere/i', $host)) {
244 244
         	$globalSources[$id]['format'] = 'airwhere';
245 245
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
246
-            } else if (preg_match('/recentpireps/i',$host)) {
246
+            } else if (preg_match('/recentpireps/i', $host)) {
247 247
         	//$formats[$id] = 'pirepsjson';
248 248
         	$globalSources[$id]['format'] = 'pirepsjson';
249 249
         	//$last_exec['pirepsjson'] = 0;
250 250
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
251
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
251
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
252 252
         	//$formats[$id] = 'fr24json';
253 253
         	$globalSources[$id]['format'] = 'fr24json';
254 254
         	//$last_exec['fr24json'] = 0;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 258
         	    exit(0);
259 259
         	}
260
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
260
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
261 261
         	//$formats[$id] = 'fr24json';
262 262
         	$globalSources[$id]['format'] = 'myshiptracking';
263 263
         	//$last_exec['fr24json'] = 0;
@@ -267,22 +267,22 @@  discard block
 block discarded – undo
267 267
         	    exit(0);
268 268
         	}
269 269
             //} else if (preg_match('/10001/',$host)) {
270
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
270
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271 271
         	//$formats[$id] = 'tsv';
272 272
         	$globalSources[$id]['format'] = 'tsv';
273 273
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
274 274
             }
275
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
275
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276 276
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
277
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
277
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
278 278
     		    if ($idf !== false) {
279 279
     			$httpfeeds[$id] = $idf;
280 280
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
281 281
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
282 282
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
283 283
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
284
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
285
-	    $hostport = explode(':',$host);
284
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
285
+	    $hostport = explode(':', $host);
286 286
 	    if (isset($hostport[1])) {
287 287
 		$port = $hostport[1];
288 288
 		$hostn = $hostport[0];
@@ -292,19 +292,19 @@  discard block
 block discarded – undo
292 292
 	    }
293 293
 	    $Common = new Common();
294 294
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
295
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
295
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
296 296
     	    } else {
297
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
297
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
298 298
 	    }
299 299
 	    if ($s) {
300 300
     	        $sockets[$id] = $s;
301 301
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
302
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
302
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
303 303
 			//$formats[$id] = 'aprs';
304 304
 			$globalSources[$id]['format'] = 'aprs';
305 305
 			//$aprs_connect = 0;
306 306
 			//$use_aprs = true;
307
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
307
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
308 308
 			$globalSources[$id]['format'] = 'vrstcp';
309 309
     		    } elseif ($port == '10001') {
310 310
         		//$formats[$id] = 'tsv';
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
346 346
 else $timeout = 20;
347 347
 $errno = '';
348
-$errstr='';
348
+$errstr = '';
349 349
 
350 350
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
351 351
 /* Initiate connections to all the hosts simultaneously */
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 //connect_all($globalSources);
354 354
 
355 355
 if (isset($globalProxy) && $globalProxy) {
356
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
356
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
357 357
 } else {
358 358
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
359 359
 }
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 
384 384
 if ($use_aprs) {
385 385
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
386
-	$APRS=new APRS();
386
+	$APRS = new APRS();
387 387
 	$aprs_connect = 0;
388 388
 	$aprs_keep = 120;
389 389
 	$aprs_last_tx = time();
390 390
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
391
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
391
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
392 392
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
393
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
393
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
394 394
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
395
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
395
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
396 396
 	if ($aprs_full) $aprs_filter = '';
397 397
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
398 398
 	else $aprs_pass = '-1';
@@ -406,12 +406,12 @@  discard block
 block discarded – undo
406 406
 sleep(1);
407 407
 if ($globalDebug) echo "SCAN MODE \n\n";
408 408
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
409
-$endtime = time()+$globalCronEnd;
409
+$endtime = time() + $globalCronEnd;
410 410
 $i = 1;
411 411
 $tt = array();
412 412
 // Delete all ATC
413 413
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
414
-	$ATC=new ATC($Connection->db);
414
+	$ATC = new ATC($Connection->db);
415 415
 }
416 416
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
417 417
 	$ATC->deleteAll();
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 while ($i > 0) {
422 422
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
423 423
 
424
-    if (!$globalDaemon) $i = $endtime-time();
424
+    if (!$globalDaemon) $i = $endtime - time();
425 425
     // Delete old ATC
426 426
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
427 427
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	}
436 436
 	if ($max < $globalMinFetch) {
437 437
 	    if ($globalDebug) echo 'Sleeping...'."\n";
438
-	    sleep($globalMinFetch-$max+2);
438
+	    sleep($globalMinFetch - $max + 2);
439 439
 	}
440 440
     }
441 441
 
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	    //$buffer = $Common->getData($hosts[$id]);
455 455
 	    $buffer = $Common->getData($value['host']);
456 456
 	    if ($buffer != '') $reset = 0;
457
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
458
-	    $buffer = explode('\n',$buffer);
457
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
458
+	    $buffer = explode('\n', $buffer);
459 459
 	    foreach ($buffer as $line) {
460 460
     		if ($line != '' && count($line) > 7) {
461 461
     		    $line = explode(',', $line);
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
 	    )
489 489
 	) {
490 490
 	    date_default_timezone_set('CET');
491
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
491
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
492 492
 	    date_default_timezone_set('UTC');
493 493
 	    if ($buffer != '') $reset = 0;
494
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
495
-	    $buffer = explode('\n',$buffer);
494
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
495
+	    $buffer = explode('\n', $buffer);
496 496
 	    foreach ($buffer as $line) {
497 497
 		if ($line != '') {
498 498
 		    //echo "'".$line."'\n";
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 		    $ais_data = $AIS->parse_line(trim($line));
501 501
 		    $data = array();
502 502
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
503
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
503
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
504 504
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
505 505
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
506 506
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
513 513
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
514 514
 		    if (isset($ais_data['timestamp'])) {
515
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
515
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
516 516
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
517 517
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
518 518
 			    $add = true;
@@ -535,21 +535,21 @@  discard block
 block discarded – undo
535 535
 	    $w = $e = null;
536 536
 	    
537 537
 	    if (isset($arr[$id])) {
538
-		$nn = stream_select($arr,$w,$e,$timeout);
538
+		$nn = stream_select($arr, $w, $e, $timeout);
539 539
 		if ($nn > 0) {
540 540
 		    foreach ($httpfeeds as $feed) {
541
-			$buffer = stream_get_line($feed,2000,"\n");
541
+			$buffer = stream_get_line($feed, 2000, "\n");
542 542
 			if ($buffer === FALSE) {
543 543
 			    connect_all($globalSources);
544 544
 			}
545
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
546
-			$buffer = explode('\n',$buffer);
545
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
546
+			$buffer = explode('\n', $buffer);
547 547
 			foreach ($buffer as $line) {
548 548
 			    if ($line != '') {
549 549
 				$ais_data = $AIS->parse_line(trim($line));
550 550
 				$data = array();
551 551
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
552
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
552
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
553 553
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
554 554
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
555 555
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -561,9 +561,9 @@  discard block
 block discarded – undo
561 561
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
562 562
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
563 563
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
564
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
564
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
565 565
 				if (isset($ais_data['timestamp'])) {
566
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
566
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
567 567
 				} else {
568 568
 				    $data['datetime'] = date('Y-m-d H:i:s');
569 569
 				}
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
596 596
 	    )
597 597
 	) {
598
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
598
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
599 599
 	    if ($buffer != '') {
600 600
 		//echo $buffer;
601
-		$all_data = json_decode($buffer,true);
601
+		$all_data = json_decode($buffer, true);
602 602
 		//print_r($all_data);
603 603
 		if (isset($all_data[0]['DATA'])) {
604 604
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 			    $data['ident'] = $line['NAME'];
608 608
 			    $data['mmsi'] = $line['MMSI'];
609 609
 			    if (strlen($data['mmsi']) > 9) {
610
-				$data['mmsi'] = substr($data['mmsi'],-9);
610
+				$data['mmsi'] = substr($data['mmsi'], -9);
611 611
 			    }
612 612
 			    $data['speed'] = $line['SOG'];
613 613
 			    $data['heading'] = $line['COG'];
@@ -617,8 +617,8 @@  discard block
 block discarded – undo
617 617
 			    //$data['type_id'] = $line['TYPE'];
618 618
 			    $data['imo'] = $line['IMO'];
619 619
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
620
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
621
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
620
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
621
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
622 622
 			    $data['format_source'] = 'myshiptracking';
623 623
 			    $data['id_source'] = $id_source;
624 624
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -635,16 +635,16 @@  discard block
 block discarded – undo
635 635
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
636 636
 	    )
637 637
 	) {
638
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
638
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
639 639
 	    if ($buffer != '') {
640
-		$all_data = json_decode($buffer,true);
640
+		$all_data = json_decode($buffer, true);
641 641
 		if (isset($all_data[0]['mmsi'])) {
642 642
 		    foreach ($all_data as $line) {
643 643
 			if ($line != '') {
644 644
 			    $data = array();
645 645
 			    $data['ident'] = $line['shipname'];
646 646
 			    $data['callsign'] = $line['callsign'];
647
-			    $data['mmsi'] = substr($line['mmsi'],-9);
647
+			    $data['mmsi'] = substr($line['mmsi'], -9);
648 648
 			    $data['speed'] = $line['sog'];
649 649
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
650 650
 			    $data['latitude'] = $line['latitude'];
@@ -671,14 +671,14 @@  discard block
 block discarded – undo
671 671
 	) {
672 672
 	    $buffer = $Common->getData($value['host']);
673 673
 	    if ($buffer != '') {
674
-		$all_data = json_decode($buffer,true);
674
+		$all_data = json_decode($buffer, true);
675 675
 		if (isset($all_data['features'][0]['id'])) {
676 676
 		    foreach ($all_data['features'] as $line) {
677 677
 			print_r($line);
678 678
 			$data = array();
679 679
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
680 680
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
681
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
681
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
682 682
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
683 683
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
684 684
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -705,31 +705,31 @@  discard block
 block discarded – undo
705 705
 	    )
706 706
 	) {
707 707
 	    if ($globalDebug) echo 'download...';
708
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
708
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
709 709
 	    if ($globalDebug) echo 'done !'."\n";
710 710
 	    // FIXME: Need more work
711 711
 	    if ($buffer != '') $reset = 0;
712
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
713
-	    $buffer = explode('\n',$buffer);
712
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
713
+	    $buffer = explode('\n', $buffer);
714 714
 	    foreach ($buffer as $line) {
715 715
 		if ($line != '') {
716 716
 		    $data = array();
717 717
 		    //echo $line."\n";
718
-		    $data['mmsi'] = (int)substr($line,0,9);
719
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
720
-		    $data['status_id'] = substr($line,21,2);
721
-		    $data['type_id'] = substr($line,24,3);
722
-		    $data['latitude'] = substr($line,29,9);
723
-		    $data['longitude'] = substr($line,41,9);
724
-		    $data['speed'] = round(substr($line,51,5));
718
+		    $data['mmsi'] = (int) substr($line, 0, 9);
719
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
720
+		    $data['status_id'] = substr($line, 21, 2);
721
+		    $data['type_id'] = substr($line, 24, 3);
722
+		    $data['latitude'] = substr($line, 29, 9);
723
+		    $data['longitude'] = substr($line, 41, 9);
724
+		    $data['speed'] = round(substr($line, 51, 5));
725 725
 		    //$data['course'] = substr($line,57,5);
726
-		    $data['heading'] = round(substr($line,63,3));
726
+		    $data['heading'] = round(substr($line, 63, 3));
727 727
 		    //$data['draft'] = substr($line,67,4);
728 728
 		    //$data['length'] = substr($line,72,3);
729 729
 		    //$data['beam'] = substr($line,76,2);
730
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
730
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
731 731
 		    //$data['callsign'] = trim(substr($line,100,7);
732
-		    $data['arrival_code'] = substr($line,108,20);
732
+		    $data['arrival_code'] = substr($line, 108, 20);
733 733
 		    //$data['etaDate'] = substr($line,129,5);
734 734
 		    //$data['etaTime'] = substr($line,135,5);
735 735
 		    $data['format_source'] = 'shipplotter';
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	    )
750 750
 	) {
751 751
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
752
-		$authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
752
+		$authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true);
753 753
 		//echo $authsailaway;
754 754
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
755 755
 		if (isset($setcookie[1][0])) {
@@ -758,18 +758,18 @@  discard block
 block discarded – undo
758 758
 	    }
759 759
 
760 760
 	    if ($globalDebug) echo '! Download... ';
761
-	    for ($i =0; $i <= 1; $i++) {
761
+	    for ($i = 0; $i <= 1; $i++) {
762 762
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
763 763
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
764 764
 	    if ($globalDebug) echo 'done'."\n";
765 765
 	    if ($buffer != '') {
766
-		$all_data = json_decode($buffer,true);
766
+		$all_data = json_decode($buffer, true);
767 767
 		if (isset($all_data['missions'])) {
768 768
 			foreach ($all_data['missions'] as $mission) {
769 769
 				$mission_user = $mission['usrname'];
770
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
771
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
772
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
770
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
771
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
772
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
773 773
 					else $racebuffer = '';
774 774
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
775 775
 				} else {
@@ -777,19 +777,19 @@  discard block
 block discarded – undo
777 777
 					$racebuffer = '';
778 778
 				}
779 779
 				if ($racebuffer != '') {
780
-					$race_data = json_decode($racebuffer,true);
780
+					$race_data = json_decode($racebuffer, true);
781 781
 					//print_r($race_data);
782 782
 					unset($racebuffer);
783 783
 					if (isset($race_data['mission'])) {
784 784
 					    $datar = array();
785 785
 					    $datar['id'] = $mission['misnr'];
786 786
 					    $datar['desc'] = $race_data['mission']['misdescr'];
787
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
788
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
787
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
788
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
789 789
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
790 790
 					    $markers = array();
791 791
 					    foreach ($race_data['mission']['course'] as $course) {
792
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
792
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
793 793
 					    }
794 794
 					    $datar['markers'] = json_encode($markers);
795 795
 					    //print_r($datar);
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 					}
798 798
 				}
799 799
 				if ($bufferm != '') {
800
-					$mission_data = json_decode($bufferm,true);
800
+					$mission_data = json_decode($bufferm, true);
801 801
 					unset($bufferm);
802 802
 					if (isset($mission_data['leaderboard'][0]['results'])) {
803 803
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
811 811
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
812 812
 								$data['datetime'] = date('Y-m-d H:i:s');
813
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
813
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
814 814
 								$data['last_update'] = date('Y-m-d H:i:s');
815 815
 								$data['status'] = $sail['status'];
816 816
 								$data['type'] = $sail['btptype'];
@@ -821,16 +821,16 @@  discard block
 block discarded – undo
821 821
 									$data['longitude'] = $pos['longitude'];
822 822
 								}
823 823
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
824
-									$resultdescr = explode(',',$sail['resultdescr']);
824
+									$resultdescr = explode(',', $sail['resultdescr']);
825 825
 									if (count($resultdescr) > 2) {
826
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
827
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
826
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
827
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
828 828
 										if (isset($resultdescr[3])) {
829
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
829
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
830 830
 										}
831 831
 									}
832 832
 								}
833
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
833
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
834 834
 								$data['captain_id'] = $sail['usrnr'];
835 835
 								$data['captain_name'] = $sail['usrname'];
836 836
 								$data['race_id'] = $sail['misnr'];
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	) {
879 879
 	    //$buffer = $Common->getData($hosts[$id]);
880 880
 	    $buffer = $Common->getData($value['host']);
881
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
882
-	    $buffer = explode('\n',$buffer);
881
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
882
+	    $buffer = explode('\n', $buffer);
883 883
 	    $reset = 0;
884 884
 	    foreach ($buffer as $line) {
885 885
     		if ($line != '') {
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
891 891
 			$data['pilot_id'] = $line[1];
892 892
 			$data['pilot_name'] = $line[2];
893
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
893
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
894 894
 			$data['ident'] = $line[0]; // ident
895 895
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
896 896
 			$data['speed'] = $line[8]; // speed
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
907 907
 			//if (isset($line[37])) $data['last_update'] = $line[37];
908 908
 		        $data['departure_airport_icao'] = $line[11];
909
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
909
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
910 910
 		        $data['arrival_airport_icao'] = $line[13];
911 911
 			$data['frequency'] = $line[4];
912 912
 			$data['type'] = $line[18];
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
     			$data['id_source'] = $id_source;
916 916
 	    		//$data['arrival_airport_time'] = ;
917 917
 	    		if ($line[9] != '') {
918
-	    		    $aircraft_data = explode('/',$line[9]);
918
+	    		    $aircraft_data = explode('/', $line[9]);
919 919
 	    		    if (isset($aircraft_data[1])) {
920 920
 	    			$data['aircraft_icao'] = $aircraft_data[1];
921 921
 	    		    }
@@ -930,9 +930,9 @@  discard block
 block discarded – undo
930 930
     			if ($line[3] === 'PILOT') $SI->add($data);
931 931
 			elseif ($line[3] === 'ATC') {
932 932
 				//print_r($data);
933
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
934
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
935
-				$typec = substr($data['ident'],-3);
933
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
934
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
935
+				$typec = substr($data['ident'], -3);
936 936
 				if ($typec === 'APP') $data['type'] = 'Approach';
937 937
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
938 938
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
945 945
 				if (!isset($data['source_name'])) $data['source_name'] = '';
946 946
 				if (isset($ATC)) {
947
-					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']);
948
-					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']);
947
+					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']);
948
+					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']);
949 949
 				}
950 950
 			}
951 951
     			unset($data);
@@ -961,24 +961,24 @@  discard block
 block discarded – undo
961 961
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
962 962
     	    )
963 963
     	) {
964
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
964
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
965 965
 	    if ($buffer != '') {
966 966
 		$all_data = simplexml_load_string($buffer);
967
-		foreach($all_data->children() as $childdata) {
967
+		foreach ($all_data->children() as $childdata) {
968 968
 			$data = array();
969 969
 			$line = $childdata;
970 970
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
971
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
972
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
973
-			$data['latitude'] = (float)$line['pktLatitude'];
974
-			$data['longitude'] = (float)$line['pktLongitude'];
975
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
976
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
977
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
971
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
972
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
973
+			$data['latitude'] = (float) $line['pktLatitude'];
974
+			$data['longitude'] = (float) $line['pktLongitude'];
975
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
976
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
977
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
978 978
 			$data['altitude_relative'] = 'AMSL';
979
-			$data['pilot_id'] = (int)$line['pktPilotID'];
979
+			$data['pilot_id'] = (int) $line['pktPilotID'];
980 980
 			$data['aircraft_icao'] = 'PARAGLIDER';
981
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
981
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
982 982
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
983 983
 			$data['format_source'] = $value['format'];
984 984
 			$SI->add($data);
@@ -986,22 +986,22 @@  discard block
 block discarded – undo
986 986
 		}
987 987
 	    }
988 988
 	    $Source->deleteOldLocationByType('gs');
989
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
989
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
990 990
 	    if ($buffer != '') {
991 991
 		$all_data = simplexml_load_string($buffer);
992
-		foreach($all_data->children() as $childdata) {
992
+		foreach ($all_data->children() as $childdata) {
993 993
 			$data = array();
994 994
 			$line = $childdata;
995
-			$data['id'] = (int)$line['gsID'];
996
-			$data['latitude'] = (float)$line['gsLatitude'];
997
-			$data['longitude'] = (float)$line['gsLongitude'];
998
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
995
+			$data['id'] = (int) $line['gsID'];
996
+			$data['latitude'] = (float) $line['gsLatitude'];
997
+			$data['longitude'] = (float) $line['gsLongitude'];
998
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
999 999
 			$data['altitude_relative'] = 'AMSL';
1000
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1000
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1001 1001
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1002
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1002
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1003 1003
 			} else {
1004
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1004
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1005 1005
 			}
1006 1006
 			unset($data);
1007 1007
 		}
@@ -1019,9 +1019,9 @@  discard block
 block discarded – undo
1019 1019
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1020 1020
 	    )
1021 1021
 	) {
1022
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1022
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1023 1023
 	    if ($buffer != '') {
1024
-	        $all_data = json_decode($buffer,true);
1024
+	        $all_data = json_decode($buffer, true);
1025 1025
 		if (isset($all_data['acList'])) {
1026 1026
 		    $reset = 0;
1027 1027
 		    foreach ($all_data['acList'] as $line) {
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1038 1038
 			$data['emergency'] = ''; // emergency
1039 1039
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1040
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1040
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1041 1041
 			else $data['datetime'] = date('Y-m-d H:i:s');
1042 1042
 			//$data['datetime'] = date('Y-m-d H:i:s');
1043 1043
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1063 1063
 			$data['squawk'] = $line['squawk']; // squawk
1064 1064
 			$data['emergency'] = ''; // emergency
1065
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1065
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1066 1066
 			else $data['datetime'] = date('Y-m-d H:i:s');
1067 1067
 			$data['format_source'] = 'aircraftlistjson';
1068 1068
 			$data['id_source'] = $id_source;
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
     	    )
1084 1084
     	) {
1085 1085
 	    $buffer = $Common->getData($value['host']);
1086
-	    $all_data = json_decode($buffer,true);
1086
+	    $all_data = json_decode($buffer, true);
1087 1087
 	    if (isset($all_data['planes'])) {
1088 1088
 		$reset = 0;
1089 1089
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1100,12 +1100,12 @@  discard block
 block discarded – undo
1100 1100
 		    $data['emergency'] = ''; // emergency
1101 1101
 		    $data['registration'] = $line[2];
1102 1102
 		    $data['aircraft_icao'] = $line[0];
1103
-		    $deparr = explode('-',$line[1]);
1103
+		    $deparr = explode('-', $line[1]);
1104 1104
 		    if (count($deparr) === 2) {
1105 1105
 			$data['departure_airport_icao'] = $deparr[0];
1106 1106
 			$data['arrival_airport_icao'] = $deparr[1];
1107 1107
 		    }
1108
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1108
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1109 1109
 	    	    $data['format_source'] = 'planeupdatefaa';
1110 1110
     		    $data['id_source'] = $id_source;
1111 1111
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 	    )
1124 1124
 	) {
1125 1125
 	    $buffer = $Common->getData($value['host']);
1126
-	    $all_data = json_decode($buffer,true);
1126
+	    $all_data = json_decode($buffer, true);
1127 1127
 	    if (isset($all_data['states'])) {
1128 1128
 		$reset = 0;
1129 1129
 		foreach ($all_data['states'] as $key => $line) {
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 		    //$data['emergency'] = ''; // emergency
1141 1141
 		    //$data['registration'] = $line[2];
1142 1142
 		    //$data['aircraft_icao'] = $line[0];
1143
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1143
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1144 1144
 		    $data['format_source'] = 'opensky';
1145 1145
 		    $data['id_source'] = $id_source;
1146 1146
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1157,8 +1157,8 @@  discard block
 block discarded – undo
1157 1157
 	    )
1158 1158
 	) {
1159 1159
 	    $buffer = $Common->getData($value['host']);
1160
-	    $all_data = json_decode($buffer,true);
1161
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1160
+	    $all_data = json_decode($buffer, true);
1161
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1162 1162
 		$reset = 0;
1163 1163
 		foreach ($all_data['aircraft'] as $key => $line) {
1164 1164
 		    $data = array();
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 	    )
1197 1197
 	) {
1198 1198
 	    $buffer = $Common->getData($value['host']);
1199
-	    $all_data = json_decode($buffer,true);
1199
+	    $all_data = json_decode($buffer, true);
1200 1200
 	    if (isset($all_data['aircraft'])) {
1201 1201
 		$reset = 0;
1202 1202
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
 		    //$data['emergency'] = ''; // emergency
1214 1214
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1215 1215
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1216
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1216
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1217 1217
 		    $data['format_source'] = 'planefinderclient';
1218 1218
 		    $data['id_source'] = $id_source;
1219 1219
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 	) {
1233 1233
 	    //$buffer = $Common->getData($hosts[$id]);
1234 1234
 	    $buffer = $Common->getData($value['host']);
1235
-	    $all_data = json_decode($buffer,true);
1235
+	    $all_data = json_decode($buffer, true);
1236 1236
 	    if (!empty($all_data)) $reset = 0;
1237 1237
 	    foreach ($all_data as $key => $line) {
1238 1238
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1270,11 +1270,11 @@  discard block
 block discarded – undo
1270 1270
 	    )
1271 1271
 	) {
1272 1272
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1273
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1273
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1274 1274
 	    //echo $buffer;
1275
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1276
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1277
-	    $all_data = json_decode($buffer,true);
1275
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1276
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1277
+	    $all_data = json_decode($buffer, true);
1278 1278
 	    if (json_last_error() != JSON_ERROR_NONE) {
1279 1279
 		die(json_last_error_msg());
1280 1280
 	    }
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 			//$data['departure_airport_iata'] = $line[11];
1298 1298
 			//$data['arrival_airport_iata'] = $line[12];
1299 1299
 	    		//$data['emergency'] = ''; // emergency
1300
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1300
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1301 1301
 	    		$data['format_source'] = 'radarvirtueljson';
1302 1302
     			$data['id_source'] = $id_source;
1303 1303
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1318,14 +1318,14 @@  discard block
 block discarded – undo
1318 1318
 	) {
1319 1319
 	    //$buffer = $Common->getData($hosts[$id]);
1320 1320
 	    $buffer = $Common->getData($value['host'].'?'.time());
1321
-	    $all_data = json_decode(utf8_encode($buffer),true);
1321
+	    $all_data = json_decode(utf8_encode($buffer), true);
1322 1322
 	    
1323 1323
 	    if (isset($all_data['pireps'])) {
1324 1324
 		$reset = 0;
1325 1325
 	        foreach ($all_data['pireps'] as $line) {
1326 1326
 		    $data = array();
1327 1327
 		    $data['id'] = $line['id'];
1328
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1328
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1329 1329
 		    $data['ident'] = $line['callsign']; // ident
1330 1330
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1331 1331
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1355,9 +1355,9 @@  discard block
 block discarded – undo
1355 1355
 			$SI->add($data);
1356 1356
 		    //    print_r($data);
1357 1357
     		    } elseif ($line['icon'] === 'ct') {
1358
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1359
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1360
-			$typec = substr($data['ident'],-3);
1358
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1359
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1360
+			$typec = substr($data['ident'], -3);
1361 1361
 			$data['type'] = '';
1362 1362
 			if ($typec === 'APP') $data['type'] = 'Approach';
1363 1363
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1368,7 +1368,7 @@  discard block
 block discarded – undo
1368 1368
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1369 1369
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1370 1370
 			else $data['type'] = 'Observer';
1371
-			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']);
1371
+			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']);
1372 1372
 		    }
1373 1373
 		    unset($data);
1374 1374
 		}
@@ -1385,14 +1385,14 @@  discard block
 block discarded – undo
1385 1385
 	    //$buffer = $Common->getData($hosts[$id]);
1386 1386
 	    if ($globalDebug) echo 'Get Data...'."\n";
1387 1387
 	    $buffer = $Common->getData($value['host']);
1388
-	    $all_data = json_decode($buffer,true);
1388
+	    $all_data = json_decode($buffer, true);
1389 1389
 	    if ($buffer != '' && is_array($all_data)) {
1390 1390
 		$reset = 0;
1391 1391
 		foreach ($all_data as $line) {
1392 1392
 	    	    $data = array();
1393 1393
 	    	    //$data['id'] = $line['id']; // id not usable
1394 1394
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1395
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1395
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1396 1396
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1397 1397
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1398 1398
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 	    	    //$data['datetime'] = $line['lastupdate'];
1408 1408
 	    	    //$data['last_update'] = $line['lastupdate'];
1409 1409
 	    	    if (isset($value['timezone'])) {
1410
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1410
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1411 1411
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1412 1412
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1413 1413
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1423,14 +1423,14 @@  discard block
 block discarded – undo
1423 1423
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1424 1424
 		    if (isset($line['aircraftname'])) {
1425 1425
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1426
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1427
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1426
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1427
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1428 1428
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1429 1429
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1430 1430
 	    		else {
1431
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1432
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1433
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1431
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1432
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1433
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1434 1434
 	    		}
1435 1435
 	    	    }
1436 1436
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	    //$buffer = $Common->getData($hosts[$id]);
1456 1456
 	    if ($globalDebug) echo 'Get Data...'."\n";
1457 1457
 	    $buffer = $Common->getData($value['host']);
1458
-	    $all_data = json_decode($buffer,true);
1458
+	    $all_data = json_decode($buffer, true);
1459 1459
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1460 1460
 		$reset = 0;
1461 1461
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1467 1467
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1468 1468
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1469
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1469
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1470 1470
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1471 1471
 	    	    $data['altitude'] = $line['altitude']; // altitude
1472 1472
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
 	    	    //$data['squawk'] = ''; // squawk
1478 1478
 	    	    //$data['emergency'] = ''; // emergency
1479 1479
 	    	    if (isset($value['timezone'])) {
1480
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1480
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1481 1481
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1482 1482
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1483 1483
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1513,14 +1513,14 @@  discard block
 block discarded – undo
1513 1513
 	    //$buffer = $Common->getData($hosts[$id]);
1514 1514
 	    if ($globalDebug) echo 'Get Data...'."\n";
1515 1515
 	    $buffer = $Common->getData($value['host']);
1516
-	    $all_data = json_decode($buffer,true);
1516
+	    $all_data = json_decode($buffer, true);
1517 1517
 	    if ($buffer != '' && is_array($all_data)) {
1518 1518
 		$reset = 0;
1519 1519
 		foreach ($all_data as $line) {
1520 1520
 	    	    $data = array();
1521 1521
 	    	    //$data['id'] = $line['id']; // id not usable
1522 1522
 	    	    $data['id'] = trim($line['flight_id']);
1523
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1523
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1524 1524
 	    	    $data['pilot_name'] = $line['pilot_name'];
1525 1525
 	    	    $data['pilot_id'] = $line['pilot_id'];
1526 1526
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1564,24 +1564,24 @@  discard block
 block discarded – undo
1564 1564
 	    //$buffer = $Common->getData($hosts[$id]);
1565 1565
 	    if ($globalDebug) echo 'Get Data...'."\n";
1566 1566
 	    $buffer = $Common->getData($value['host']);
1567
-	    $all_data = json_decode($buffer,true);
1567
+	    $all_data = json_decode($buffer, true);
1568 1568
 	    if ($buffer != '') {
1569 1569
 		$Source->deleteLocationBySource('blitzortung');
1570
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1571
-		$buffer = explode('\n',$buffer);
1570
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1571
+		$buffer = explode('\n', $buffer);
1572 1572
 		foreach ($buffer as $buffer_line) {
1573
-		    $line = json_decode($buffer_line,true);
1573
+		    $line = json_decode($buffer_line, true);
1574 1574
 		    if (isset($line['time'])) {
1575 1575
 			$data = array();
1576 1576
 			$data['altitude'] = $line['alt']; // altitude
1577 1577
 			$data['latitude'] = $line['lat']; // lat
1578 1578
 			$data['longitude'] = $line['lon']; // long
1579
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1579
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1580 1580
 			$data['id_source'] = $id_source;
1581 1581
 			$data['format_source'] = 'blitzortung';
1582 1582
 			$SI->add($data);
1583 1583
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1584
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1584
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1585 1585
 			unset($data);
1586 1586
 		    }
1587 1587
 		}
@@ -1593,15 +1593,15 @@  discard block
 block discarded – undo
1593 1593
         $arr = $httpfeeds;
1594 1594
         $w = $e = null;
1595 1595
         if (isset($arr[$id])) {
1596
-            $nn = stream_select($arr,$w,$e,$timeout);
1596
+            $nn = stream_select($arr, $w, $e, $timeout);
1597 1597
             if ($nn > 0) {
1598 1598
                 foreach ($httpfeeds as $feed) {
1599
-                    $buffer = stream_get_line($feed,2000,"\n");
1599
+                    $buffer = stream_get_line($feed, 2000, "\n");
1600 1600
                     if ($buffer === FALSE) {
1601 1601
                         connect_all($globalSources);
1602 1602
                     }
1603
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1604
-                    $buffer = explode('\n',$buffer);
1603
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1604
+                    $buffer = explode('\n', $buffer);
1605 1605
                     foreach ($buffer as $line) {
1606 1606
                         if ($line != '') {
1607 1607
                             $line = json_decode($line, true);
@@ -1641,11 +1641,11 @@  discard block
 block discarded – undo
1641 1641
 		    //$value = $formats[$nb];
1642 1642
 		    $format = $globalSources[$nb]['format'];
1643 1643
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1644
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1644
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1645 1645
 		    } elseif ($format === 'vrstcp') {
1646 1646
 			$buffer = @socket_read($r, 6000);
1647 1647
 		    } else {
1648
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1648
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1649 1649
 		    }
1650 1650
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1651 1651
 		    //echo $buffer."\n";
@@ -1655,8 +1655,8 @@  discard block
 block discarded – undo
1655 1655
 		    //$SI::del();
1656 1656
 		    if ($buffer !== FALSE) {
1657 1657
 			if ($format === 'vrstcp') {
1658
-			    $buffer = explode('},{',$buffer);
1659
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1658
+			    $buffer = explode('},{', $buffer);
1659
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1660 1660
 		    }
1661 1661
 		    // SBS format is CSV format
1662 1662
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1683,7 +1683,7 @@  discard block
 block discarded – undo
1683 1683
 			    $ais_data = $AIS->parse_line(trim($buffer));
1684 1684
 			    $data = array();
1685 1685
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1686
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1686
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1687 1687
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1688 1688
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1689 1689
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1694,13 +1694,13 @@  discard block
 block discarded – undo
1694 1694
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1695 1695
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1696 1696
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1697
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1697
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1698 1698
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1699 1699
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1700 1700
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1701 1701
 
1702 1702
 			    if (isset($ais_data['timestamp'])) {
1703
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1703
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1704 1704
 			    } else {
1705 1705
 				$data['datetime'] = date('Y-m-d H:i:s');
1706 1706
 			    }
@@ -1711,10 +1711,10 @@  discard block
 block discarded – undo
1711 1711
                         } elseif ($format === 'flightgearsp') {
1712 1712
                     	    //echo $buffer."\n";
1713 1713
                     	    if (strlen($buffer) > 5) {
1714
-				$line = explode(',',$buffer);
1714
+				$line = explode(',', $buffer);
1715 1715
 				$data = array();
1716 1716
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1717
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1717
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1718 1718
 				$data['ident'] = $line[6];
1719 1719
 				$data['aircraft_name'] = $line[7];
1720 1720
 				$data['longitude'] = $line[1];
@@ -1731,16 +1731,16 @@  discard block
 block discarded – undo
1731 1731
                         } elseif ($format === 'acars') {
1732 1732
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1733 1733
 			    $ACARS->add(trim($buffer));
1734
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1734
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1735 1735
 			    $ACARS->deleteLiveAcarsData();
1736 1736
 			} elseif ($format === 'flightgearmp') {
1737
-			    if (substr($buffer,0,1) != '#') {
1737
+			    if (substr($buffer, 0, 1) != '#') {
1738 1738
 				$data = array();
1739 1739
 				//echo $buffer."\n";
1740
-				$line = explode(' ',$buffer);
1740
+				$line = explode(' ', $buffer);
1741 1741
 				if (count($line) === 11) {
1742
-				    $userserver = explode('@',$line[0]);
1743
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1742
+				    $userserver = explode('@', $line[0]);
1743
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1744 1744
 				    $data['ident'] = $userserver[0];
1745 1745
 				    $data['registration'] = $userserver[0];
1746 1746
 				    $data['latitude'] = $line[4];
@@ -1748,8 +1748,8 @@  discard block
 block discarded – undo
1748 1748
 				    $data['altitude'] = $line[6];
1749 1749
 				    $data['datetime'] = date('Y-m-d H:i:s');
1750 1750
 				    $aircraft_type = $line[10];
1751
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1752
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1751
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1752
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1753 1753
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1754 1754
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1755 1755
 				}
@@ -1758,8 +1758,8 @@  discard block
 block discarded – undo
1758 1758
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1759 1759
 			    die;
1760 1760
 			} elseif ($format === 'vrstcp') {
1761
-			    foreach($buffer as $all_data) {
1762
-				$line = json_decode('{'.$all_data.'}',true);
1761
+			    foreach ($buffer as $all_data) {
1762
+				$line = json_decode('{'.$all_data.'}', true);
1763 1763
 				$data = array();
1764 1764
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1765 1765
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1785,16 +1785,16 @@  discard block
 block discarded – undo
1785 1785
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1786 1786
 				unset($data);
1787 1787
 			    }
1788
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1788
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1789 1789
 			    $line = explode("\t", $buffer);
1790
-			    for($k = 0; $k < count($line); $k=$k+2) {
1790
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1791 1791
 				$key = $line[$k];
1792
-			        $lined[$key] = $line[$k+1];
1792
+			        $lined[$key] = $line[$k + 1];
1793 1793
 			    }
1794 1794
     			    if (count($lined) > 3) {
1795 1795
     				$data['hex'] = $lined['hexid'];
1796 1796
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1797
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1797
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1798 1798
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1799 1799
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1800 1800
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1813,23 +1813,23 @@  discard block
 block discarded – undo
1813 1813
     			    } else $error = true;
1814 1814
 			} elseif ($format === 'aprs' && $use_aprs) {
1815 1815
 			    if ($aprs_connect === 0) {
1816
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1816
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1817 1817
 				$aprs_connect = 1;
1818 1818
 			    }
1819 1819
 			    
1820
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1820
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1821 1821
 				$aprs_last_tx = time();
1822 1822
 				$data_aprs = "# Keep alive";
1823
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1823
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1824 1824
 			    }
1825 1825
 			    
1826 1826
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1827 1827
 			    //echo 'APRS data : '.$buffer."\n";
1828
-			    $buffer = str_replace('APRS <- ','',$buffer);
1829
-			    $buffer = str_replace('APRS -> ','',$buffer);
1828
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1829
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1830 1830
 			    //echo $buffer."\n";
1831 1831
 			    date_default_timezone_set('UTC');
1832
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1832
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1833 1833
 				$line = $APRS->parse($buffer);
1834 1834
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1835 1835
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1845 1845
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1846 1846
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1847
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1847
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1848 1848
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1849 1849
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1850 1850
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1932,29 +1932,29 @@  discard block
 block discarded – undo
1932 1932
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1933 1933
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1934 1934
 					$Source->deleteOldLocationByType('gs');
1935
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1936
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1935
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1936
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1937 1937
 					} else {
1938
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1938
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1939 1939
 					}
1940 1940
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1941 1941
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1942 1942
 					if ($globalDebug) echo '# Weather Station added'."\n";
1943 1943
 					$Source->deleteOldLocationByType('wx');
1944 1944
 					$weather_data = json_encode($line);
1945
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1946
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1945
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1946
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1947 1947
 					} else {
1948
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1948
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1949 1949
 					}
1950 1950
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1951 1951
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1952 1952
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1953 1953
 					$Source->deleteOldLocationByType('lightning');
1954
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1955
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1954
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1955
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1956 1956
 					} else {
1957
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1957
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1958 1958
 					}
1959 1959
 				    } elseif ($globalDebug) {
1960 1960
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
 				    unset($data);
1964 1964
 				}
1965 1965
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1966
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1966
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1967 1967
 				}
1968 1968
 				/*
1969 1969
 				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')) {
@@ -1972,7 +1972,7 @@  discard block
 block discarded – undo
1972 1972
 				*/
1973 1973
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1974 1974
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1975
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1975
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1976 1976
 					$Source->deleteOldLocationByType('lightning');
1977 1977
 					$Source->deleteOldLocationByType('wx');
1978 1978
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2059,7 +2059,7 @@  discard block
 block discarded – undo
2059 2059
 				connect_all($sourceee);
2060 2060
 				$sourceee = array();
2061 2061
 				//connect_all($globalSources);
2062
-				$tt[$format]=0;
2062
+				$tt[$format] = 0;
2063 2063
 				break;
2064 2064
 			    } 
2065 2065
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2069,14 +2069,14 @@  discard block
 block discarded – undo
2069 2069
 	    } else {
2070 2070
 		$error = socket_strerror(socket_last_error());
2071 2071
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2072
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2072
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2073 2073
 			if (isset($globalDebug)) echo "Restarting...\n";
2074 2074
 			// Restart the script if possible
2075 2075
 			if (is_array($sockets)) {
2076 2076
 			    if ($globalDebug) echo "Shutdown all sockets...";
2077 2077
 			    
2078 2078
 			    foreach ($sockets as $sock) {
2079
-				@socket_shutdown($sock,2);
2079
+				@socket_shutdown($sock, 2);
2080 2080
 				@socket_close($sock);
2081 2081
 			    }
2082 2082
 			    
Please login to merge, or discard this patch.
Braces   +1217 added lines, -409 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
26 28
 
27 29
 if ($globalInstalled === FALSE) {
28 30
     echo "This script MUST be run after install script. Use your web browser to run install/index.php";
@@ -68,66 +70,107 @@  discard block
 block discarded – undo
68 70
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 71
 if (isset($options['s'])) {
70 72
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
73
-} elseif (isset($options['source'])) {
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['s']);
77
+    }
78
+    } elseif (isset($options['source'])) {
74 79
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
77
-}
80
+    if (isset($options['format'])) {
81
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
82
+    } else {
83
+    	$globalSources[] = array('host' => $options['source']);
84
+    }
85
+    }
78 86
 if (isset($options['aprsserverhost'])) {
79 87
 	$globalServerAPRS = TRUE;
80 88
 	$globalServerAPRShost = $options['aprsserverhost'];
81 89
 }
82
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
83
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
84
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
85
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
90
+if (isset($options['aprsserverport'])) {
91
+	$globalServerAPRSport = $options['aprsserverport'];
92
+}
93
+if (isset($options['aprsserverssid'])) {
94
+	$globalServerAPRSssid = $options['aprsserverssid'];
95
+}
96
+if (isset($options['aprsserverpass'])) {
97
+	$globalServerAPRSpass = $options['aprsserverpass'];
98
+}
99
+if (isset($options['noaprsserver'])) {
100
+	$globalServerAPRS = FALSE;
101
+}
86 102
 if (isset($options['enable-aircraft'])) {
87
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
103
+	if ($globalDebug) {
104
+		echo 'Enable Aircraft mode'."\n";
105
+	}
88 106
 	$globalAircraft = TRUE; 
89 107
 }
90 108
 if (isset($options['disable-aircraft'])) {
91
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
109
+	if ($globalDebug) {
110
+		echo 'Disable Aircraft mode'."\n";
111
+	}
92 112
 	$globalAircraft = FALSE;
93 113
 }
94 114
 if (isset($options['enable-tracker'])) {
95
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
115
+	if ($globalDebug) {
116
+		echo 'Enable Tracker mode'."\n";
117
+	}
96 118
 	$globalTracker = TRUE; 
97 119
 }
98 120
 if (isset($options['disable-tracker'])) {
99
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
121
+	if ($globalDebug) {
122
+		echo 'Disable Tracker mode'."\n";
123
+	}
100 124
 	$globalTracker = FALSE;
101 125
 }
102 126
 if (isset($options['enable-marine'])) {
103
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
127
+	if ($globalDebug) {
128
+		echo 'Enable Marine mode'."\n";
129
+	}
104 130
 	$globalMarine = TRUE;
105 131
 }
106 132
 if (isset($options['disable-marine'])) {
107
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
133
+	if ($globalDebug) {
134
+		echo 'Disable Marine mode'."\n";
135
+	}
108 136
 	$globalMarine = FALSE;
109 137
 }
110
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
111
-if (isset($options['server'])) $globalServer = TRUE;
112
-if (isset($options['idsource'])) $id_source = $options['idsource'];
113
-else $id_source = 1;
138
+if (isset($options['nodaemon'])) {
139
+	$globalDaemon = FALSE;
140
+}
141
+if (isset($options['server'])) {
142
+	$globalServer = TRUE;
143
+}
144
+if (isset($options['idsource'])) {
145
+	$id_source = $options['idsource'];
146
+} else {
147
+	$id_source = 1;
148
+}
114 149
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
150
+    if ($globalDebug) {
151
+    	echo "Using Server Mode\n";
152
+    }
116 153
     $SI=new SpotterServer();
117 154
 /*
118 155
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 156
     $SI = new adsb2aprs();
120 157
     $SI->connect();
121 158
 */
122
-} else $SI=new SpotterImport($Connection->db);
159
+} else {
160
+	$SI=new SpotterImport($Connection->db);
161
+}
123 162
 
124
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
163
+if (isset($globalTracker) && $globalTracker) {
164
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
165
+}
125 166
 if (isset($globalMarine) && $globalMarine) {
126 167
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
127 168
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 169
 }
129 170
 
130
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
171
+if (isset($globalTracker) && $globalTracker) {
172
+	$TI = new TrackerImport($Connection->db);
173
+}
131 174
 if (isset($globalMarine) && $globalMarine) {
132 175
     $AIS = new AIS();
133 176
     $MI = new MarineImport($Connection->db);
@@ -152,7 +195,9 @@  discard block
 block discarded – undo
152 195
 }
153 196
 
154 197
 // let's try and connect
155
-if ($globalDebug) echo "Connecting...\n";
198
+if ($globalDebug) {
199
+	echo "Connecting...\n";
200
+}
156 201
 $use_aprs = false;
157 202
 $aprs_full = false;
158 203
 $reset = 0;
@@ -161,7 +206,9 @@  discard block
 block discarded – undo
161 206
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162 207
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163 208
     $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
209
+    if ($globalDebug) {
210
+    	echo 'Connect to all...'."\n";
211
+    }
165 212
     foreach ($hosts as $id => $value) {
166 213
 	$host = $value['host'];
167 214
 	$globalSources[$id]['last_exec'] = 0;
@@ -171,32 +218,44 @@  discard block
 block discarded – undo
171 218
         	//$formats[$id] = 'deltadbtxt';
172 219
         	$globalSources[$id]['format'] = 'deltadbtxt';
173 220
         	//$last_exec['deltadbtxt'] = 0;
174
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to deltadb source (".$host.")...\n";
223
+        	}
175 224
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176 225
         	//$formats[$id] = 'vatsimtxt';
177 226
         	$globalSources[$id]['format'] = 'vatsimtxt';
178 227
         	//$last_exec['vatsimtxt'] = 0;
179
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to vatsim source (".$host.")...\n";
230
+        	}
180 231
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181 232
         	//$formats[$id] = 'aircraftlistjson';
182 233
         	$globalSources[$id]['format'] = 'aircraftlistjson';
183 234
         	//$last_exec['aircraftlistjson'] = 0;
184
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
237
+        	}
185 238
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
186 239
         	//$formats[$id] = 'aircraftjson';
187 240
         	$globalSources[$id]['format'] = 'aircraftjson';
188 241
         	//$last_exec['aircraftlistjson'] = 0;
189
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to aircraft.json source (".$host.")...\n";
244
+        	}
190 245
     	    } else if (preg_match('/aircraft$/i',$host)) {
191 246
         	//$formats[$id] = 'planefinderclient';
192 247
         	$globalSources[$id]['format'] = 'planefinderclient';
193 248
         	//$last_exec['aircraftlistjson'] = 0;
194
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to planefinderclient source (".$host.")...\n";
251
+        	}
195 252
     	    } else if (preg_match('/opensky/i',$host)) {
196 253
         	//$formats[$id] = 'aircraftlistjson';
197 254
         	$globalSources[$id]['format'] = 'opensky';
198 255
         	//$last_exec['aircraftlistjson'] = 0;
199
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
256
+        	if ($globalDebug) {
257
+        		echo "Connect to opensky source (".$host.")...\n";
258
+        	}
200 259
     	    /*
201 260
     	    // Disabled for now, site change source format
202 261
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -213,7 +272,9 @@  discard block
 block discarded – undo
213 272
         	//$formats[$id] = 'planeupdatefaa';
214 273
         	$globalSources[$id]['format'] = 'planeupdatefaa';
215 274
         	//$last_exec['planeupdatefaa'] = 0;
216
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
275
+        	if ($globalDebug) {
276
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
277
+        	}
217 278
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
218 279
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
219 280
         	    exit(0);
@@ -222,37 +283,53 @@  discard block
 block discarded – undo
222 283
         	//$formats[$id] = 'phpvmacars';
223 284
         	$globalSources[$id]['format'] = 'phpvmacars';
224 285
         	//$last_exec['phpvmacars'] = 0;
225
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
286
+        	if ($globalDebug) {
287
+        		echo "Connect to phpvmacars source (".$host.")...\n";
288
+        	}
226 289
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227 290
         	//$formats[$id] = 'phpvmacars';
228 291
         	$globalSources[$id]['format'] = 'vaos';
229 292
         	//$last_exec['phpvmacars'] = 0;
230
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
293
+        	if ($globalDebug) {
294
+        		echo "Connect to vaos source (".$host.")...\n";
295
+        	}
231 296
             } else if (preg_match('/VAM-json.php$/i',$host)) {
232 297
         	//$formats[$id] = 'phpvmacars';
233 298
         	$globalSources[$id]['format'] = 'vam';
234
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
299
+        	if ($globalDebug) {
300
+        		echo "Connect to Vam source (".$host.")...\n";
301
+        	}
235 302
             } else if (preg_match('/whazzup/i',$host)) {
236 303
         	//$formats[$id] = 'whazzup';
237 304
         	$globalSources[$id]['format'] = 'whazzup';
238 305
         	//$last_exec['whazzup'] = 0;
239
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
306
+        	if ($globalDebug) {
307
+        		echo "Connect to whazzup source (".$host.")...\n";
308
+        	}
240 309
             } else if (preg_match('/blitzortung/i',$host)) {
241 310
         	$globalSources[$id]['format'] = 'blitzortung';
242
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
311
+        	if ($globalDebug) {
312
+        		echo "Connect to blitzortung source (".$host.")...\n";
313
+        	}
243 314
             } else if (preg_match('/airwhere/i',$host)) {
244 315
         	$globalSources[$id]['format'] = 'airwhere';
245
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to airwhere source (".$host.")...\n";
318
+        	}
246 319
             } else if (preg_match('/recentpireps/i',$host)) {
247 320
         	//$formats[$id] = 'pirepsjson';
248 321
         	$globalSources[$id]['format'] = 'pirepsjson';
249 322
         	//$last_exec['pirepsjson'] = 0;
250
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
323
+        	if ($globalDebug) {
324
+        		echo "Connect to pirepsjson source (".$host.")...\n";
325
+        	}
251 326
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252 327
         	//$formats[$id] = 'fr24json';
253 328
         	$globalSources[$id]['format'] = 'fr24json';
254 329
         	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
330
+        	if ($globalDebug) {
331
+        		echo "Connect to fr24 source (".$host.")...\n";
332
+        	}
256 333
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257 334
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 335
         	    exit(0);
@@ -261,7 +338,9 @@  discard block
 block discarded – undo
261 338
         	//$formats[$id] = 'fr24json';
262 339
         	$globalSources[$id]['format'] = 'myshiptracking';
263 340
         	//$last_exec['fr24json'] = 0;
264
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
341
+        	if ($globalDebug) {
342
+        		echo "Connect to myshiptracking source (".$host.")...\n";
343
+        	}
265 344
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
266 345
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
267 346
         	    exit(0);
@@ -270,17 +349,26 @@  discard block
 block discarded – undo
270 349
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271 350
         	//$formats[$id] = 'tsv';
272 351
         	$globalSources[$id]['format'] = 'tsv';
273
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
352
+        	if ($globalDebug) {
353
+        		echo "Connect to tsv source (".$host.")...\n";
354
+        	}
274 355
             }
275 356
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276 357
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
277 358
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278 359
     		    if ($idf !== false) {
279 360
     			$httpfeeds[$id] = $idf;
280
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
281
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
282
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
283
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
361
+        		if ($globalDebug) {
362
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
363
+        		}
364
+    		    } elseif ($globalDebug) {
365
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
366
+    		    }
367
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
368
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
369
+    		} elseif ($globalDebug) {
370
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
371
+    		}
284 372
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
285 373
 	    $hostport = explode(':',$host);
286 374
 	    if (isset($hostport[1])) {
@@ -320,19 +408,27 @@  discard block
 block discarded – undo
320 408
         		//$formats[$id] = 'beast';
321 409
         		$globalSources[$id]['format'] = 'beast';
322 410
 		    //} else $formats[$id] = 'sbs';
323
-		    } else $globalSources[$id]['format'] = 'sbs';
411
+		    } else {
412
+		    	$globalSources[$id]['format'] = 'sbs';
413
+		    }
324 414
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
325 415
 		}
326
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
416
+		if ($globalDebug) {
417
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
418
+		}
327 419
             } else {
328
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
420
+		if ($globalDebug) {
421
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
422
+		}
329 423
 		sleep(10);
330 424
 		connect_all($hosts);
331 425
     	    }
332 426
         }
333 427
     }
334 428
 }
335
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
429
+if (!isset($globalMinFetch)) {
430
+	$globalMinFetch = 15;
431
+}
336 432
 
337 433
 // Initialize all
338 434
 $status = array();
@@ -341,13 +437,19 @@  discard block
 block discarded – undo
341 437
 $formats = array();
342 438
 $last_exec = array();
343 439
 $time = time();
344
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
345
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
346
-else $timeout = 20;
440
+if (isset($globalSourcesTimeout)) {
441
+	$timeout = $globalSourcesTimeOut;
442
+} else if (isset($globalSBS1TimeOut)) {
443
+	$timeout = $globalSBS1TimeOut;
444
+} else {
445
+	$timeout = 20;
446
+}
347 447
 $errno = '';
348 448
 $errstr='';
349 449
 
350
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
450
+if (!isset($globalDaemon)) {
451
+	$globalDaemon = TRUE;
452
+}
351 453
 /* Initiate connections to all the hosts simultaneously */
352 454
 //connect_all($hosts);
353 455
 //connect_all($globalSources);
@@ -376,7 +478,9 @@  discard block
 block discarded – undo
376 478
     if (isset($source['format']) && $source['format'] == 'aprs') {
377 479
 	$aprs_connect = 0;
378 480
 	$use_aprs = true;
379
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
481
+	if (isset($source['port']) && $source['port'] == '10152') {
482
+		$aprs_full = true;
483
+	}
380 484
 	break;
381 485
     }
382 486
 }
@@ -387,25 +491,46 @@  discard block
 block discarded – undo
387 491
 	$aprs_connect = 0;
388 492
 	$aprs_keep = 120;
389 493
 	$aprs_last_tx = time();
390
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
391
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
392
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
393
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
394
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
395
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
396
-	if ($aprs_full) $aprs_filter = '';
397
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
398
-	else $aprs_pass = '-1';
494
+	if (isset($globalAPRSversion)) {
495
+		$aprs_version = $globalAPRSversion;
496
+	} else {
497
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
498
+	}
499
+	if (isset($globalAPRSssid)) {
500
+		$aprs_ssid = $globalAPRSssid;
501
+	} else {
502
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
503
+	}
504
+	if (isset($globalAPRSfilter)) {
505
+		$aprs_filter = $globalAPRSfilter;
506
+	} else {
507
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
508
+	}
509
+	if ($aprs_full) {
510
+		$aprs_filter = '';
511
+	}
512
+	if (isset($globalAPRSpass)) {
513
+		$aprs_pass = $globalAPRSpass;
514
+	} else {
515
+		$aprs_pass = '-1';
516
+	}
399 517
 
400
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
401
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
402
-}
518
+	if ($aprs_filter != '') {
519
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
520
+	} else {
521
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
522
+	}
523
+	}
403 524
 
404 525
 // connected - lets do some work
405 526
 //if ($globalDebug) echo "Connected!\n";
406 527
 sleep(1);
407
-if ($globalDebug) echo "SCAN MODE \n\n";
408
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
528
+if ($globalDebug) {
529
+	echo "SCAN MODE \n\n";
530
+}
531
+if (!isset($globalCronEnd)) {
532
+	$globalCronEnd = 60;
533
+}
409 534
 $endtime = time()+$globalCronEnd;
410 535
 $i = 1;
411 536
 $tt = array();
@@ -419,22 +544,32 @@  discard block
 block discarded – undo
419 544
 
420 545
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
421 546
 while ($i > 0) {
422
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
547
+    if (function_exists('pcntl_fork')) {
548
+    	pcntl_signal_dispatch();
549
+    }
423 550
 
424
-    if (!$globalDaemon) $i = $endtime-time();
551
+    if (!$globalDaemon) {
552
+    	$i = $endtime-time();
553
+    }
425 554
     // Delete old ATC
426 555
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
427
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
556
+	if ($globalDebug) {
557
+		echo 'Delete old ATC...'."\n";
558
+	}
428 559
         $ATC->deleteOldATC();
429 560
     }
430 561
     
431 562
     if (count($last_exec) == count($globalSources)) {
432 563
 	$max = $globalMinFetch;
433 564
 	foreach ($last_exec as $last) {
434
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
565
+	    if ((time() - $last['last']) < $max) {
566
+	    	$max = time() - $last['last'];
567
+	    }
435 568
 	}
436 569
 	if ($max < $globalMinFetch) {
437
-	    if ($globalDebug) echo 'Sleeping...'."\n";
570
+	    if ($globalDebug) {
571
+	    	echo 'Sleeping...'."\n";
572
+	    }
438 573
 	    sleep($globalMinFetch-$max+2);
439 574
 	}
440 575
     }
@@ -444,7 +579,9 @@  discard block
 block discarded – undo
444 579
     foreach ($globalSources as $id => $value) {
445 580
 	date_default_timezone_set('UTC');
446 581
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
447
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
582
+	if (!isset($last_exec[$id]['last'])) {
583
+		$last_exec[$id]['last'] = 0;
584
+	}
448 585
 	if ($value['format'] === 'deltadbtxt' && 
449 586
 	    (
450 587
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -453,7 +590,9 @@  discard block
 block discarded – undo
453 590
 	) {
454 591
 	    //$buffer = $Common->getData($hosts[$id]);
455 592
 	    $buffer = $Common->getData($value['host']);
456
-	    if ($buffer != '') $reset = 0;
593
+	    if ($buffer != '') {
594
+	    	$reset = 0;
595
+	    }
457 596
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
458 597
 	    $buffer = explode('\n',$buffer);
459 598
 	    foreach ($buffer as $line) {
@@ -462,20 +601,41 @@  discard block
 block discarded – undo
462 601
 	            $data = array();
463 602
 	            $data['hex'] = $line[1]; // hex
464 603
 	            $data['ident'] = $line[2]; // ident
465
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
466
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
467
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
468
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
469
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
604
+	            if (isset($line[3])) {
605
+	            	$data['altitude'] = $line[3];
606
+	            }
607
+	            // altitude
608
+	            if (isset($line[4])) {
609
+	            	$data['speed'] = $line[4];
610
+	            }
611
+	            // speed
612
+	            if (isset($line[5])) {
613
+	            	$data['heading'] = $line[5];
614
+	            }
615
+	            // heading
616
+	            if (isset($line[6])) {
617
+	            	$data['latitude'] = $line[6];
618
+	            }
619
+	            // lat
620
+	            if (isset($line[7])) {
621
+	            	$data['longitude'] = $line[7];
622
+	            }
623
+	            // long
470 624
 	            $data['verticalrate'] = ''; // vertical rate
471 625
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
472 626
 	            $data['emergency'] = ''; // emergency
473 627
 		    $data['datetime'] = date('Y-m-d H:i:s');
474 628
 		    $data['format_source'] = 'deltadbtxt';
475 629
     		    $data['id_source'] = $id_source;
476
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
477
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
630
+		    if (isset($value['name']) && $value['name'] != '') {
631
+		    	$data['source_name'] = $value['name'];
632
+		    }
633
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
634
+		    	$data['noarchive'] = true;
635
+		    }
636
+		    if (isset($value['sourcestats'])) {
637
+		    	$data['sourcestats'] = $value['sourcestats'];
638
+		    }
479 639
     		    $SI->add($data);
480 640
 		    unset($data);
481 641
     		}
@@ -490,7 +650,9 @@  discard block
 block discarded – undo
490 650
 	    date_default_timezone_set('CET');
491 651
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
492 652
 	    date_default_timezone_set('UTC');
493
-	    if ($buffer != '') $reset = 0;
653
+	    if ($buffer != '') {
654
+	    	$reset = 0;
655
+	    }
494 656
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
495 657
 	    $buffer = explode('\n',$buffer);
496 658
 	    foreach ($buffer as $line) {
@@ -499,18 +661,42 @@  discard block
 block discarded – undo
499 661
 		    $add = false;
500 662
 		    $ais_data = $AIS->parse_line(trim($line));
501 663
 		    $data = array();
502
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
503
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
504
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
505
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
506
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
507
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
508
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
509
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
510
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
511
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
512
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
513
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
664
+		    if (isset($ais_data['ident'])) {
665
+		    	$data['ident'] = $ais_data['ident'];
666
+		    }
667
+		    if (isset($ais_data['mmsi'])) {
668
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
669
+		    }
670
+		    if (isset($ais_data['speed'])) {
671
+		    	$data['speed'] = $ais_data['speed'];
672
+		    }
673
+		    if (isset($ais_data['heading'])) {
674
+		    	$data['heading'] = $ais_data['heading'];
675
+		    }
676
+		    if (isset($ais_data['latitude'])) {
677
+		    	$data['latitude'] = $ais_data['latitude'];
678
+		    }
679
+		    if (isset($ais_data['longitude'])) {
680
+		    	$data['longitude'] = $ais_data['longitude'];
681
+		    }
682
+		    if (isset($ais_data['status'])) {
683
+		    	$data['status'] = $ais_data['status'];
684
+		    }
685
+		    if (isset($ais_data['statusid'])) {
686
+		    	$data['status_id'] = $ais_data['statusid'];
687
+		    }
688
+		    if (isset($ais_data['type'])) {
689
+		    	$data['type'] = $ais_data['type'];
690
+		    }
691
+		    if (isset($ais_data['typeid'])) {
692
+		    	$data['type_id'] = $ais_data['typeid'];
693
+		    }
694
+		    if (isset($ais_data['imo'])) {
695
+		    	$data['imo'] = $ais_data['imo'];
696
+		    }
697
+		    if (isset($ais_data['callsign'])) {
698
+		    	$data['callsign'] = $ais_data['callsign'];
699
+		    }
514 700
 		    if (isset($ais_data['timestamp'])) {
515 701
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
516 702
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -524,8 +710,12 @@  discard block
 block discarded – undo
524 710
 		    $data['format_source'] = 'aisnmeatxt';
525 711
     		    $data['id_source'] = $id_source;
526 712
 		    //print_r($data);
527
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
528
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
713
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
714
+		    	$data['noarchive'] = true;
715
+		    }
716
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
717
+		    	$MI->add($data);
718
+		    }
529 719
 		    unset($data);
530 720
 		}
531 721
     	    }
@@ -548,20 +738,48 @@  discard block
 block discarded – undo
548 738
 			    if ($line != '') {
549 739
 				$ais_data = $AIS->parse_line(trim($line));
550 740
 				$data = array();
551
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
552
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
553
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
554
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
555
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
556
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
557
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
558
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
559
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
560
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
561
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
562
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
563
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
564
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
741
+				if (isset($ais_data['ident'])) {
742
+					$data['ident'] = $ais_data['ident'];
743
+				}
744
+				if (isset($ais_data['mmsi'])) {
745
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
746
+				}
747
+				if (isset($ais_data['speed'])) {
748
+					$data['speed'] = $ais_data['speed'];
749
+				}
750
+				if (isset($ais_data['heading'])) {
751
+					$data['heading'] = $ais_data['heading'];
752
+				}
753
+				if (isset($ais_data['latitude'])) {
754
+					$data['latitude'] = $ais_data['latitude'];
755
+				}
756
+				if (isset($ais_data['longitude'])) {
757
+					$data['longitude'] = $ais_data['longitude'];
758
+				}
759
+				if (isset($ais_data['status'])) {
760
+					$data['status'] = $ais_data['status'];
761
+				}
762
+				if (isset($ais_data['statusid'])) {
763
+					$data['status_id'] = $ais_data['statusid'];
764
+				}
765
+				if (isset($ais_data['type'])) {
766
+					$data['type'] = $ais_data['type'];
767
+				}
768
+				if (isset($ais_data['typeid'])) {
769
+					$data['type_id'] = $ais_data['typeid'];
770
+				}
771
+				if (isset($ais_data['imo'])) {
772
+					$data['imo'] = $ais_data['imo'];
773
+				}
774
+				if (isset($ais_data['callsign'])) {
775
+					$data['callsign'] = $ais_data['callsign'];
776
+				}
777
+				if (isset($ais_data['destination'])) {
778
+					$data['arrival_code'] = $ais_data['destination'];
779
+				}
780
+				if (isset($ais_data['eta_ts'])) {
781
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
782
+				}
565 783
 				if (isset($ais_data['timestamp'])) {
566 784
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
567 785
 				} else {
@@ -569,18 +787,27 @@  discard block
 block discarded – undo
569 787
 				}
570 788
 				$data['format_source'] = 'aisnmeahttp';
571 789
 				$data['id_source'] = $id_source;
572
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
573
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
790
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
791
+					$data['noarchive'] = true;
792
+				}
793
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
794
+					$MI->add($data);
795
+				}
574 796
 				unset($data);
575 797
 			    }
576 798
 			}
577 799
 		    }
578 800
 		} else {
579 801
 		    $format = $value['format'];
580
-		    if (isset($tt[$format])) $tt[$format]++;
581
-		    else $tt[$format] = 0;
802
+		    if (isset($tt[$format])) {
803
+		    	$tt[$format]++;
804
+		    } else {
805
+		    	$tt[$format] = 0;
806
+		    }
582 807
 		    if ($tt[$format] > 30) {
583
-			if ($globalDebug) echo 'Reconnect...'."\n";
808
+			if ($globalDebug) {
809
+				echo 'Reconnect...'."\n";
810
+			}
584 811
 			sleep(2);
585 812
 			//$sourceeen[] = $value;
586 813
 			//connect_all($sourceeen);
@@ -616,12 +843,18 @@  discard block
 block discarded – undo
616 843
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
617 844
 			    //$data['type_id'] = $line['TYPE'];
618 845
 			    $data['imo'] = $line['IMO'];
619
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
620
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
846
+			    if ($line['DEST'] != '') {
847
+			    	$data['arrival_code'] = $line['DEST'];
848
+			    }
849
+			    if ($line['ARV'] != '') {
850
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
851
+			    }
621 852
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
622 853
 			    $data['format_source'] = 'myshiptracking';
623 854
 			    $data['id_source'] = $id_source;
624
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
855
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
856
+			    	$data['noarchive'] = true;
857
+			    }
625 858
 			    $MI->add($data);
626 859
 			    unset($data);
627 860
 			}
@@ -646,7 +879,9 @@  discard block
 block discarded – undo
646 879
 			    $data['callsign'] = $line['callsign'];
647 880
 			    $data['mmsi'] = substr($line['mmsi'],-9);
648 881
 			    $data['speed'] = $line['sog'];
649
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
882
+			    if ($line['heading'] != '511') {
883
+			    	$data['heading'] = $line['heading'];
884
+			    }
650 885
 			    $data['latitude'] = $line['latitude'];
651 886
 			    $data['longitude'] = $line['longitude'];
652 887
 			    $data['type_id'] = $line['shiptype'];
@@ -654,7 +889,9 @@  discard block
 block discarded – undo
654 889
 			    $data['datetime'] = $line['time'];
655 890
 			    $data['format_source'] = 'boatbeaconapp';
656 891
 			    $data['id_source'] = $id_source;
657
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
892
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
893
+			    	$data['noarchive'] = true;
894
+			    }
658 895
 			    $MI->add($data);
659 896
 			    unset($data);
660 897
 			}
@@ -676,22 +913,44 @@  discard block
 block discarded – undo
676 913
 		    foreach ($all_data['features'] as $line) {
677 914
 			print_r($line);
678 915
 			$data = array();
679
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
680
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
681
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
682
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
683
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
684
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
916
+			if (isset($line['properties']['name'])) {
917
+				$data['ident'] = $line['properties']['name'];
918
+			}
919
+			if (isset($line['properties']['callsign'])) {
920
+				$data['callsign'] = $line['properties']['callsign'];
921
+			}
922
+			if (isset($line['properties']['mmsi'])) {
923
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
924
+			}
925
+			if (isset($line['properties']['imo'])) {
926
+				$data['imo'] = $line['properties']['imo'];
927
+			}
928
+			if (isset($line['properties']['speed'])) {
929
+				$data['speed'] = $line['properties']['speed'];
930
+			}
931
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
932
+				$data['heading'] = $line['properties']['heading'];
933
+			}
685 934
 			$data['latitude'] = $line['geometry']['coordinates'][1];
686 935
 			$data['longitude'] = $line['geometry']['coordinates'][0];
687
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
688
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
689
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
936
+			if (isset($line['properties']['vesselType'])) {
937
+				$data['type'] = $line['properties']['vesselType'];
938
+			}
939
+			if (isset($line['properties']['destination'])) {
940
+				$data['arrival_code'] = $line['properties']['destination'];
941
+			}
942
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
943
+				$data['arrival_date'] = $line['properties']['eta'];
944
+			}
690 945
 			$data['format_source'] = 'boatnerd';
691 946
 			$data['id_source'] = $id_source;
692 947
 			$data['datetime'] = date('Y-m-d H:i:s');
693
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
694
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
948
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
949
+				$data['noarchive'] = true;
950
+			}
951
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
952
+				$MI->add($data);
953
+			}
695 954
 			unset($data);
696 955
 		    }
697 956
 		}
@@ -704,11 +963,17 @@  discard block
 block discarded – undo
704 963
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
705 964
 	    )
706 965
 	) {
707
-	    if ($globalDebug) echo 'download...';
966
+	    if ($globalDebug) {
967
+	    	echo 'download...';
968
+	    }
708 969
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
709
-	    if ($globalDebug) echo 'done !'."\n";
970
+	    if ($globalDebug) {
971
+	    	echo 'done !'."\n";
972
+	    }
710 973
 	    // FIXME: Need more work
711
-	    if ($buffer != '') $reset = 0;
974
+	    if ($buffer != '') {
975
+	    	$reset = 0;
976
+	    }
712 977
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
713 978
 	    $buffer = explode('\n',$buffer);
714 979
 	    foreach ($buffer as $line) {
@@ -734,7 +999,9 @@  discard block
 block discarded – undo
734 999
 		    //$data['etaTime'] = substr($line,135,5);
735 1000
 		    $data['format_source'] = 'shipplotter';
736 1001
     		    $data['id_source'] = $id_source;
737
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1002
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1003
+		    	$data['noarchive'] = true;
1004
+		    }
738 1005
 		    //print_r($data);
739 1006
 		    //echo 'Add...'."\n";
740 1007
 		    $MI->add($data);
@@ -757,11 +1024,17 @@  discard block
 block discarded – undo
757 1024
 		}
758 1025
 	    }
759 1026
 
760
-	    if ($globalDebug) echo '! Download... ';
1027
+	    if ($globalDebug) {
1028
+	    	echo '! Download... ';
1029
+	    }
761 1030
 	    for ($i =0; $i <= 1; $i++) {
762
-		if ($globalDebug) echo 'Racetype: '.$i.' ';
1031
+		if ($globalDebug) {
1032
+			echo 'Racetype: '.$i.' ';
1033
+		}
763 1034
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
764
-	    if ($globalDebug) echo 'done'."\n";
1035
+	    if ($globalDebug) {
1036
+	    	echo 'done'."\n";
1037
+	    }
765 1038
 	    if ($buffer != '') {
766 1039
 		$all_data = json_decode($buffer,true);
767 1040
 		if (isset($all_data['missions'])) {
@@ -769,8 +1042,11 @@  discard block
 block discarded – undo
769 1042
 				$mission_user = $mission['usrname'];
770 1043
 				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
771 1044
 				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
772
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
773
-					else $racebuffer = '';
1045
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
1046
+						$racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
1047
+					} else {
1048
+						$racebuffer = '';
1049
+					}
774 1050
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
775 1051
 				} else {
776 1052
 					$bufferm = '';
@@ -834,7 +1110,9 @@  discard block
 block discarded – undo
834 1110
 								$data['captain_id'] = $sail['usrnr'];
835 1111
 								$data['captain_name'] = $sail['usrname'];
836 1112
 								$data['race_id'] = $sail['misnr'];
837
-								if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank'];
1113
+								if ($sail['rank'] != 'DNF') {
1114
+									$data['race_rank'] = $sail['rank'];
1115
+								}
838 1116
 								$data['race_time'] = $sail['racetime'];
839 1117
 								if ($mission_user != '') {
840 1118
 									$data['race_name'] = $mission_name.' ('.$mission_user.')';
@@ -844,7 +1122,9 @@  discard block
 block discarded – undo
844 1122
 								//$data['callsign'] = trim(substr($line,100,7);
845 1123
 								$data['format_source'] = 'sailaway';
846 1124
 								$data['id_source'] = $id_source;
847
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1125
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1126
+									$data['noarchive'] = true;
1127
+								}
848 1128
 								//print_r($data);
849 1129
 								//if ($data['race_id'] == '48') print_r($data);
850 1130
 								//echo 'Add...'."\n";
@@ -886,16 +1166,28 @@  discard block
 block discarded – undo
886 1166
     		    $line = explode(':', $line);
887 1167
     		    if (count($line) > 30 && $line[0] != 'callsign') {
888 1168
 			$data = array();
889
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
890
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1169
+			if (isset($line[37]) && $line[37] != '') {
1170
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1171
+			} else {
1172
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1173
+			}
891 1174
 			$data['pilot_id'] = $line[1];
892 1175
 			$data['pilot_name'] = $line[2];
893 1176
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
894 1177
 			$data['ident'] = $line[0]; // ident
895
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1178
+			if ($line[7] != '' && $line[7] != 0) {
1179
+				$data['altitude'] = $line[7];
1180
+			}
1181
+			// altitude
896 1182
 			$data['speed'] = $line[8]; // speed
897
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
898
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1183
+			if (isset($line[45])) {
1184
+				$data['heading'] = $line[45];
1185
+			}
1186
+			// heading
1187
+			elseif (isset($line[38])) {
1188
+				$data['heading'] = $line[38];
1189
+			}
1190
+			// heading
899 1191
 			$data['latitude'] = $line[5]; // lat
900 1192
 	        	$data['longitude'] = $line[6]; // long
901 1193
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -911,7 +1203,9 @@  discard block
 block discarded – undo
911 1203
 			$data['frequency'] = $line[4];
912 1204
 			$data['type'] = $line[18];
913 1205
 			$data['range'] = $line[19];
914
-			if (isset($line[35])) $data['info'] = $line[35];
1206
+			if (isset($line[35])) {
1207
+				$data['info'] = $line[35];
1208
+			}
915 1209
     			$data['id_source'] = $id_source;
916 1210
 	    		//$data['arrival_airport_time'] = ;
917 1211
 	    		if ($line[9] != '') {
@@ -925,27 +1219,47 @@  discard block
 block discarded – undo
925 1219
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
926 1220
 	    		*/
927 1221
 	    		$data['format_source'] = $value['format'];
928
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
929
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
930
-    			if ($line[3] === 'PILOT') $SI->add($data);
931
-			elseif ($line[3] === 'ATC') {
1222
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1223
+				$data['noarchive'] = true;
1224
+			}
1225
+			if (isset($value['name']) && $value['name'] != '') {
1226
+				$data['source_name'] = $value['name'];
1227
+			}
1228
+    			if ($line[3] === 'PILOT') {
1229
+    				$SI->add($data);
1230
+    			} elseif ($line[3] === 'ATC') {
932 1231
 				//print_r($data);
933 1232
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
934 1233
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
935 1234
 				$typec = substr($data['ident'],-3);
936
-				if ($typec === 'APP') $data['type'] = 'Approach';
937
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
938
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
939
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
940
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
941
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
942
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
943
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
944
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
945
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1235
+				if ($typec === 'APP') {
1236
+					$data['type'] = 'Approach';
1237
+				} elseif ($typec === 'TWR') {
1238
+					$data['type'] = 'Tower';
1239
+				} elseif ($typec === 'OBS') {
1240
+					$data['type'] = 'Observer';
1241
+				} elseif ($typec === 'GND') {
1242
+					$data['type'] = 'Ground';
1243
+				} elseif ($typec === 'DEL') {
1244
+					$data['type'] = 'Delivery';
1245
+				} elseif ($typec === 'DEP') {
1246
+					$data['type'] = 'Departure';
1247
+				} elseif ($typec === 'FSS') {
1248
+					$data['type'] = 'Flight Service Station';
1249
+				} elseif ($typec === 'CTR') {
1250
+					$data['type'] = 'Control Radar or Centre';
1251
+				} elseif ($data['type'] === '') {
1252
+					$data['type'] = 'Observer';
1253
+				}
1254
+				if (!isset($data['source_name'])) {
1255
+					$data['source_name'] = '';
1256
+				}
946 1257
 				if (isset($ATC)) {
947
-					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']);
948
-					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']);
1258
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1259
+						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']);
1260
+					} else {
1261
+						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']);
1262
+					}
949 1263
 				}
950 1264
 			}
951 1265
     			unset($data);
@@ -972,14 +1286,20 @@  discard block
 block discarded – undo
972 1286
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
973 1287
 			$data['latitude'] = (float)$line['pktLatitude'];
974 1288
 			$data['longitude'] = (float)$line['pktLongitude'];
975
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
976
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1289
+			if ((float)$line['pktTrack'] != 0) {
1290
+				$data['heading'] = (float)$line['pktTrack'];
1291
+			}
1292
+			if ((int)$line['pktSpeed'] != 0) {
1293
+				$data['speed'] = (int)$line['pktSpeed'];
1294
+			}
977 1295
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
978 1296
 			$data['altitude_relative'] = 'AMSL';
979 1297
 			$data['pilot_id'] = (int)$line['pktPilotID'];
980 1298
 			$data['aircraft_icao'] = 'PARAGLIDER';
981 1299
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
982
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1300
+			if (isset($pilot_data[4])) {
1301
+				$data['pilot_name'] = $pilot_data[4];
1302
+			}
983 1303
 			$data['format_source'] = $value['format'];
984 1304
 			$SI->add($data);
985 1305
 			unset($data);
@@ -1027,25 +1347,59 @@  discard block
 block discarded – undo
1027 1347
 		    foreach ($all_data['acList'] as $line) {
1028 1348
 			$data = array();
1029 1349
 			$data['hex'] = $line['Icao']; // hex
1030
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1031
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1032
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1033
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1034
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1035
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1350
+			if (isset($line['Call'])) {
1351
+				$data['ident'] = $line['Call'];
1352
+			}
1353
+			// ident
1354
+			if (isset($line['Alt'])) {
1355
+				$data['altitude'] = $line['Alt'];
1356
+			}
1357
+			// altitude
1358
+			if (isset($line['Spd'])) {
1359
+				$data['speed'] = $line['Spd'];
1360
+			}
1361
+			// speed
1362
+			if (isset($line['Trak'])) {
1363
+				$data['heading'] = $line['Trak'];
1364
+			}
1365
+			// heading
1366
+			if (isset($line['Lat'])) {
1367
+				$data['latitude'] = $line['Lat'];
1368
+			}
1369
+			// lat
1370
+			if (isset($line['Long'])) {
1371
+				$data['longitude'] = $line['Long'];
1372
+			}
1373
+			// long
1036 1374
 			//$data['verticalrate'] = $line['']; // verticale rate
1037
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1375
+			if (isset($line['Sqk'])) {
1376
+				$data['squawk'] = $line['Sqk'];
1377
+			}
1378
+			// squawk
1038 1379
 			$data['emergency'] = ''; // emergency
1039
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1040
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1041
-			else $data['datetime'] = date('Y-m-d H:i:s');
1380
+			if (isset($line['Reg'])) {
1381
+				$data['registration'] = $line['Reg'];
1382
+			}
1383
+			if (isset($line['PosTime'])) {
1384
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1385
+			} else {
1386
+				$data['datetime'] = date('Y-m-d H:i:s');
1387
+			}
1042 1388
 			//$data['datetime'] = date('Y-m-d H:i:s');
1043
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1389
+			if (isset($line['Type'])) {
1390
+				$data['aircraft_icao'] = $line['Type'];
1391
+			}
1044 1392
 			$data['format_source'] = 'aircraftlistjson';
1045 1393
 			$data['id_source'] = $id_source;
1046
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1047
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1048
-			if (isset($data['latitude'])) $SI->add($data);
1394
+			if (isset($value['name']) && $value['name'] != '') {
1395
+				$data['source_name'] = $value['name'];
1396
+			}
1397
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1398
+				$data['noarchive'] = true;
1399
+			}
1400
+			if (isset($data['latitude'])) {
1401
+				$SI->add($data);
1402
+			}
1049 1403
 			unset($data);
1050 1404
 		    }
1051 1405
 		} elseif (is_array($all_data)) {
@@ -1062,17 +1416,26 @@  discard block
 block discarded – undo
1062 1416
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1063 1417
 			$data['squawk'] = $line['squawk']; // squawk
1064 1418
 			$data['emergency'] = ''; // emergency
1065
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1066
-			else $data['datetime'] = date('Y-m-d H:i:s');
1419
+			if (isset($line['PosTime'])) {
1420
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1421
+			} else {
1422
+				$data['datetime'] = date('Y-m-d H:i:s');
1423
+			}
1067 1424
 			$data['format_source'] = 'aircraftlistjson';
1068 1425
 			$data['id_source'] = $id_source;
1069
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1070
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1426
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1427
+				$data['noarchive'] = true;
1428
+			}
1429
+			if (isset($value['name']) && $value['name'] != '') {
1430
+				$data['source_name'] = $value['name'];
1431
+			}
1071 1432
 			$SI->add($data);
1072 1433
 			unset($data);
1073 1434
 		    }
1074 1435
 		}
1075
-	    } elseif ($globalDebug) echo 'No data'."\n";
1436
+	    } elseif ($globalDebug) {
1437
+	    	echo 'No data'."\n";
1438
+	    }
1076 1439
     	    //$last_exec['aircraftlistjson'] = time();
1077 1440
     	    $last_exec[$id]['last'] = time();
1078 1441
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1108,8 +1471,12 @@  discard block
 block discarded – undo
1108 1471
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1109 1472
 	    	    $data['format_source'] = 'planeupdatefaa';
1110 1473
     		    $data['id_source'] = $id_source;
1111
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1112
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1474
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1475
+		    	$data['noarchive'] = true;
1476
+		    }
1477
+		    if (isset($value['name']) && $value['name'] != '') {
1478
+		    	$data['source_name'] = $value['name'];
1479
+		    }
1113 1480
 		    $SI->add($data);
1114 1481
 		    unset($data);
1115 1482
 		}
@@ -1143,7 +1510,9 @@  discard block
 block discarded – undo
1143 1510
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1144 1511
 		    $data['format_source'] = 'opensky';
1145 1512
 		    $data['id_source'] = $id_source;
1146
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1513
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1514
+		    	$data['noarchive'] = true;
1515
+		    }
1147 1516
 		    $SI->add($data);
1148 1517
 		    unset($data);
1149 1518
 		}
@@ -1163,15 +1532,42 @@  discard block
 block discarded – undo
1163 1532
 		foreach ($all_data['aircraft'] as $key => $line) {
1164 1533
 		    $data = array();
1165 1534
 		    // add support for ground vehicule with ~ in front of hex
1166
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1167
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1168
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1169
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1170
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1171
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1172
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1173
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1174
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1535
+		    if (isset($line['hex'])) {
1536
+		    	$data['hex'] = $line['hex'];
1537
+		    }
1538
+		    // hex
1539
+		    if (isset($line['flight'])) {
1540
+		    	$data['ident'] = trim($line['flight']);
1541
+		    }
1542
+		    // ident
1543
+		    if (isset($line['altitude'])) {
1544
+		    	$data['altitude'] = $line['altitude'];
1545
+		    }
1546
+		    // altitude
1547
+		    if (isset($line['speed'])) {
1548
+		    	$data['speed'] = $line['speed'];
1549
+		    }
1550
+		    // speed
1551
+		    if (isset($line['track'])) {
1552
+		    	$data['heading'] = $line['track'];
1553
+		    }
1554
+		    // heading
1555
+		    if (isset($line['lat'])) {
1556
+		    	$data['latitude'] = $line['lat'];
1557
+		    }
1558
+		    // lat
1559
+		    if (isset($line['lon'])) {
1560
+		    	$data['longitude'] = $line['lon'];
1561
+		    }
1562
+		    // long
1563
+		    if (isset($line['vert_rate'])) {
1564
+		    	$data['verticalrate'] = $line['vert_rate'];
1565
+		    }
1566
+		    // verticale rate
1567
+		    if (isset($line['squawk'])) {
1568
+		    	$data['squawk'] = $line['squawk'];
1569
+		    }
1570
+		    // squawk
1175 1571
 		    //$data['emergency'] = ''; // emergency
1176 1572
 		    //$data['registration'] = $line[2];
1177 1573
 		    //$data['aircraft_icao'] = $line[0];
@@ -1179,10 +1575,17 @@  discard block
 block discarded – undo
1179 1575
 		    $data['format_source'] = 'aircraftjson';
1180 1576
 		    $data['id_source'] = $id_source;
1181 1577
 		    if (isset($value['name']) && $value['name'] != '') {
1182
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1183
-			    else $data['source_name'] = $value['name'];
1184
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1185
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1578
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1579
+			    	$data['source_name'] = $value['name'].'_MLAT';
1580
+			    } else {
1581
+			    	$data['source_name'] = $value['name'];
1582
+			    }
1583
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1584
+		    	$data['source_name'] = 'MLAT';
1585
+		    }
1586
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1587
+		    	$data['noarchive'] = true;
1588
+		    }
1186 1589
 		    $SI->add($data);
1187 1590
 		    unset($data);
1188 1591
 		}
@@ -1202,22 +1605,54 @@  discard block
 block discarded – undo
1202 1605
 		foreach ($all_data['aircraft'] as $key => $line) {
1203 1606
 		    $data = array();
1204 1607
 		    $data['hex'] = $key; // hex
1205
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1206
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1207
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1208
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1209
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1210
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1211
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1212
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1608
+		    if (isset($line['callsign'])) {
1609
+		    	$data['ident'] = trim($line['callsign']);
1610
+		    }
1611
+		    // ident
1612
+		    if (isset($line['altitude'])) {
1613
+		    	$data['altitude'] = $line['altitude'];
1614
+		    }
1615
+		    // altitude
1616
+		    if (isset($line['speed'])) {
1617
+		    	$data['speed'] = $line['speed'];
1618
+		    }
1619
+		    // speed
1620
+		    if (isset($line['heading'])) {
1621
+		    	$data['heading'] = $line['heading'];
1622
+		    }
1623
+		    // heading
1624
+		    if (isset($line['lat'])) {
1625
+		    	$data['latitude'] = $line['lat'];
1626
+		    }
1627
+		    // lat
1628
+		    if (isset($line['lon'])) {
1629
+		    	$data['longitude'] = $line['lon'];
1630
+		    }
1631
+		    // long
1632
+		    if (isset($line['vert_rate'])) {
1633
+		    	$data['verticalrate'] = $line['vert_rate'];
1634
+		    }
1635
+		    // verticale rate
1636
+		    if (isset($line['squawk'])) {
1637
+		    	$data['squawk'] = $line['squawk'];
1638
+		    }
1639
+		    // squawk
1213 1640
 		    //$data['emergency'] = ''; // emergency
1214
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1215
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1641
+		    if (isset($line['reg'])) {
1642
+		    	$data['registration'] = $line['reg'];
1643
+		    }
1644
+		    if (isset($line['type'])) {
1645
+		    	$data['aircraft_icao'] = $line['type'];
1646
+		    }
1216 1647
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1217 1648
 		    $data['format_source'] = 'planefinderclient';
1218 1649
 		    $data['id_source'] = $id_source;
1219
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1220
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1650
+		    if (isset($value['name']) && $value['name'] != '') {
1651
+		    	$data['source_name'] = $value['name'];
1652
+		    }
1653
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1654
+		    	$data['noarchive'] = true;
1655
+		    }
1221 1656
 		    $SI->add($data);
1222 1657
 		    unset($data);
1223 1658
 		}
@@ -1233,7 +1668,9 @@  discard block
 block discarded – undo
1233 1668
 	    //$buffer = $Common->getData($hosts[$id]);
1234 1669
 	    $buffer = $Common->getData($value['host']);
1235 1670
 	    $all_data = json_decode($buffer,true);
1236
-	    if (!empty($all_data)) $reset = 0;
1671
+	    if (!empty($all_data)) {
1672
+	    	$reset = 0;
1673
+	    }
1237 1674
 	    foreach ($all_data as $key => $line) {
1238 1675
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1239 1676
 		    $data = array();
@@ -1254,8 +1691,12 @@  discard block
 block discarded – undo
1254 1691
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1255 1692
 	    	    $data['format_source'] = 'fr24json';
1256 1693
     		    $data['id_source'] = $id_source;
1257
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1258
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1694
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1695
+		    	$data['noarchive'] = true;
1696
+		    }
1697
+		    if (isset($value['name']) && $value['name'] != '') {
1698
+		    	$data['source_name'] = $value['name'];
1699
+		    }
1259 1700
 		    $SI->add($data);
1260 1701
 		    unset($data);
1261 1702
 		}
@@ -1284,24 +1725,42 @@  discard block
 block discarded – undo
1284 1725
 		    if (isset($line['inf'])) {
1285 1726
 			$data = array();
1286 1727
 			$data['hex'] = $line['inf']['ia'];
1287
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1728
+			if (isset($line['inf']['cs'])) {
1729
+				$data['ident'] = $line['inf']['cs'];
1730
+			}
1731
+			//$line[13]
1288 1732
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1289
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1290
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1733
+	    		if (isset($line['inf']['gs'])) {
1734
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1735
+	    		}
1736
+	    		// speed
1737
+	    		if (isset($line['inf']['tr'])) {
1738
+	    			$data['heading'] = $line['inf']['tr'];
1739
+	    		}
1740
+	    		// heading
1291 1741
 	    		$data['latitude'] = $line['pt'][0]; // lat
1292 1742
 	    		$data['longitude'] = $line['pt'][1]; // long
1293 1743
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1294
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1744
+	    		if (isset($line['inf']['sq'])) {
1745
+	    			$data['squawk'] = $line['inf']['sq'];
1746
+	    		}
1747
+	    		// squawk
1295 1748
 	    		//$data['aircraft_icao'] = $line[8];
1296
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1749
+	    		if (isset($line['inf']['rc'])) {
1750
+	    			$data['registration'] = $line['inf']['rc'];
1751
+	    		}
1297 1752
 			//$data['departure_airport_iata'] = $line[11];
1298 1753
 			//$data['arrival_airport_iata'] = $line[12];
1299 1754
 	    		//$data['emergency'] = ''; // emergency
1300 1755
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1301 1756
 	    		$data['format_source'] = 'radarvirtueljson';
1302 1757
     			$data['id_source'] = $id_source;
1303
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1304
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1758
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1759
+				$data['noarchive'] = true;
1760
+			}
1761
+			if (isset($value['name']) && $value['name'] != '') {
1762
+				$data['source_name'] = $value['name'];
1763
+			}
1305 1764
 			$SI->add($data);
1306 1765
 			unset($data);
1307 1766
 		    }
@@ -1327,30 +1786,65 @@  discard block
 block discarded – undo
1327 1786
 		    $data['id'] = $line['id'];
1328 1787
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1329 1788
 		    $data['ident'] = $line['callsign']; // ident
1330
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1331
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1332
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1333
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1334
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1335
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1789
+		    if (isset($line['pilotid'])) {
1790
+		    	$data['pilot_id'] = $line['pilotid'];
1791
+		    }
1792
+		    // pilot id
1793
+		    if (isset($line['name'])) {
1794
+		    	$data['pilot_name'] = $line['name'];
1795
+		    }
1796
+		    // pilot name
1797
+		    if (isset($line['alt'])) {
1798
+		    	$data['altitude'] = $line['alt'];
1799
+		    }
1800
+		    // altitude
1801
+		    if (isset($line['gs'])) {
1802
+		    	$data['speed'] = $line['gs'];
1803
+		    }
1804
+		    // speed
1805
+		    if (isset($line['heading'])) {
1806
+		    	$data['heading'] = $line['heading'];
1807
+		    }
1808
+		    // heading
1809
+		    if (isset($line['route'])) {
1810
+		    	$data['waypoints'] = $line['route'];
1811
+		    }
1812
+		    // route
1336 1813
 		    $data['latitude'] = $line['lat']; // lat
1337 1814
 		    $data['longitude'] = $line['lon']; // long
1338 1815
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1339 1816
 		    //$data['squawk'] = $line['squawk']; // squawk
1340 1817
 		    //$data['emergency'] = ''; // emergency
1341
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1342
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1343
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1818
+		    if (isset($line['depicao'])) {
1819
+		    	$data['departure_airport_icao'] = $line['depicao'];
1820
+		    }
1821
+		    if (isset($line['deptime'])) {
1822
+		    	$data['departure_airport_time'] = $line['deptime'];
1823
+		    }
1824
+		    if (isset($line['arricao'])) {
1825
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1826
+		    }
1344 1827
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1345
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1346
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1347
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1348
-		    else $data['info'] = '';
1828
+		    if (isset($line['aircraft'])) {
1829
+		    	$data['aircraft_icao'] = $line['aircraft'];
1830
+		    }
1831
+		    if (isset($line['transponder'])) {
1832
+		    	$data['squawk'] = $line['transponder'];
1833
+		    }
1834
+		    if (isset($line['atis'])) {
1835
+		    	$data['info'] = $line['atis'];
1836
+		    } else {
1837
+		    	$data['info'] = '';
1838
+		    }
1349 1839
 		    $data['format_source'] = 'pireps';
1350 1840
     		    $data['id_source'] = $id_source;
1351 1841
 		    $data['datetime'] = date('Y-m-d H:i:s');
1352
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1353
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1842
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1843
+		    	$data['noarchive'] = true;
1844
+		    }
1845
+		    if (isset($value['name']) && $value['name'] != '') {
1846
+		    	$data['source_name'] = $value['name'];
1847
+		    }
1354 1848
 		    if ($line['icon'] === 'plane') {
1355 1849
 			$SI->add($data);
1356 1850
 		    //    print_r($data);
@@ -1359,16 +1853,28 @@  discard block
 block discarded – undo
1359 1853
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1360 1854
 			$typec = substr($data['ident'],-3);
1361 1855
 			$data['type'] = '';
1362
-			if ($typec === 'APP') $data['type'] = 'Approach';
1363
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1364
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1365
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1366
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1367
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1368
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1369
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1370
-			else $data['type'] = 'Observer';
1371
-			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']);
1856
+			if ($typec === 'APP') {
1857
+				$data['type'] = 'Approach';
1858
+			} elseif ($typec === 'TWR') {
1859
+				$data['type'] = 'Tower';
1860
+			} elseif ($typec === 'OBS') {
1861
+				$data['type'] = 'Observer';
1862
+			} elseif ($typec === 'GND') {
1863
+				$data['type'] = 'Ground';
1864
+			} elseif ($typec === 'DEL') {
1865
+				$data['type'] = 'Delivery';
1866
+			} elseif ($typec === 'DEP') {
1867
+				$data['type'] = 'Departure';
1868
+			} elseif ($typec === 'FSS') {
1869
+				$data['type'] = 'Flight Service Station';
1870
+			} elseif ($typec === 'CTR') {
1871
+				$data['type'] = 'Control Radar or Centre';
1872
+			} else {
1873
+				$data['type'] = 'Observer';
1874
+			}
1875
+			if (isset($ATC)) {
1876
+				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']);
1877
+			}
1372 1878
 		    }
1373 1879
 		    unset($data);
1374 1880
 		}
@@ -1383,7 +1889,9 @@  discard block
 block discarded – undo
1383 1889
 	    )
1384 1890
 	) {
1385 1891
 	    //$buffer = $Common->getData($hosts[$id]);
1386
-	    if ($globalDebug) echo 'Get Data...'."\n";
1892
+	    if ($globalDebug) {
1893
+	    	echo 'Get Data...'."\n";
1894
+	    }
1387 1895
 	    $buffer = $Common->getData($value['host']);
1388 1896
 	    $all_data = json_decode($buffer,true);
1389 1897
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1391,10 +1899,16 @@  discard block
 block discarded – undo
1391 1899
 		foreach ($all_data as $line) {
1392 1900
 	    	    $data = array();
1393 1901
 	    	    //$data['id'] = $line['id']; // id not usable
1394
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1902
+	    	    if (isset($line['pilotid'])) {
1903
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1904
+	    	    }
1395 1905
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1396
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1397
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1906
+	    	    if (isset($line['pilotname'])) {
1907
+	    	    	$data['pilot_name'] = $line['pilotname'];
1908
+	    	    }
1909
+	    	    if (isset($line['pilotid'])) {
1910
+	    	    	$data['pilot_id'] = $line['pilotid'];
1911
+	    	    }
1398 1912
 	    	    $data['ident'] = $line['flightnum']; // ident
1399 1913
 	    	    $data['altitude'] = $line['alt']; // altitude
1400 1914
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1410,7 +1924,9 @@  discard block
 block discarded – undo
1410 1924
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1411 1925
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1412 1926
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1413
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1927
+	    	    } else {
1928
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1929
+	    	    }
1414 1930
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1415 1931
 	    	    $data['departure_airport_time'] = $line['deptime'];
1416 1932
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1418,29 +1934,47 @@  discard block
 block discarded – undo
1418 1934
     		    if (isset($line['registration'])) {
1419 1935
     			$data['registration'] = $line['registration'];
1420 1936
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1421
-    		    } else $data['registration'] = $line['aircraft'];
1422
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1423
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1937
+    		    } else {
1938
+    		    	$data['registration'] = $line['aircraft'];
1939
+    		    }
1940
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1941
+		    	$data['noarchive'] = true;
1942
+		    }
1943
+		    if (isset($line['route'])) {
1944
+		    	$data['waypoints'] = $line['route'];
1945
+		    }
1946
+		    // route
1424 1947
 		    if (isset($line['aircraftname'])) {
1425 1948
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1426 1949
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1427 1950
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1428
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1429
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1430
-	    		else {
1951
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1952
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1953
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1954
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1955
+	    		} else {
1431 1956
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1432
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1433
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1957
+	    		    if (isset($aircraft_data[1])) {
1958
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1959
+	    		    } else {
1960
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1961
+	    		    }
1434 1962
 	    		}
1435 1963
 	    	    }
1436
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1964
+    		    if (isset($line['route'])) {
1965
+    		    	$data['waypoints'] = $line['route'];
1966
+    		    }
1437 1967
     		    $data['id_source'] = $id_source;
1438 1968
 	    	    $data['format_source'] = 'phpvmacars';
1439
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1969
+		    if (isset($value['name']) && $value['name'] != '') {
1970
+		    	$data['source_name'] = $value['name'];
1971
+		    }
1440 1972
 		    $SI->add($data);
1441 1973
 		    unset($data);
1442 1974
 		}
1443
-		if ($globalDebug) echo 'No more data...'."\n";
1975
+		if ($globalDebug) {
1976
+			echo 'No more data...'."\n";
1977
+		}
1444 1978
 		unset($buffer);
1445 1979
 		unset($all_data);
1446 1980
 	    }
@@ -1453,7 +1987,9 @@  discard block
 block discarded – undo
1453 1987
 	    )
1454 1988
 	) {
1455 1989
 	    //$buffer = $Common->getData($hosts[$id]);
1456
-	    if ($globalDebug) echo 'Get Data...'."\n";
1990
+	    if ($globalDebug) {
1991
+	    	echo 'Get Data...'."\n";
1992
+	    }
1457 1993
 	    $buffer = $Common->getData($value['host']);
1458 1994
 	    $all_data = json_decode($buffer,true);
1459 1995
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1464,10 +2000,16 @@  discard block
 block discarded – undo
1464 2000
 	    	    //$data['id'] = $line['id']; // id not usable
1465 2001
 	    	    $data['id'] = $line['id'];
1466 2002
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1467
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1468
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
2003
+	    	    if (isset($line['user']['username'])) {
2004
+	    	    	$data['pilot_name'] = $line['user']['username'];
2005
+	    	    }
2006
+	    	    if (isset($line['user_id'])) {
2007
+	    	    	$data['pilot_id'] = $line['user_id'];
2008
+	    	    }
1469 2009
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1470
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2010
+	    	    if (is_numeric($data['ident'])) {
2011
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2012
+	    	    }
1471 2013
 	    	    $data['altitude'] = $line['altitude']; // altitude
1472 2014
 	    	    $data['speed'] = $line['groundspeed']; // speed
1473 2015
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1480,7 +2022,9 @@  discard block
 block discarded – undo
1480 2022
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1481 2023
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1482 2024
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1483
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2025
+	    	    } else {
2026
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2027
+	    	    }
1484 2028
 	    	    
1485 2029
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1486 2030
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1488,17 +2032,26 @@  discard block
 block discarded – undo
1488 2032
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1489 2033
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1490 2034
 
1491
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1492
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2035
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2036
+		    	$data['noarchive'] = true;
2037
+		    }
2038
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2039
+		    	$data['waypoints'] = $line['bid']['route'];
2040
+		    }
2041
+		    // route
1493 2042
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1494 2043
 
1495 2044
     		    $data['id_source'] = $id_source;
1496 2045
 	    	    $data['format_source'] = 'vaos';
1497
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2046
+		    if (isset($value['name']) && $value['name'] != '') {
2047
+		    	$data['source_name'] = $value['name'];
2048
+		    }
1498 2049
 		    $SI->add($data);
1499 2050
 		    unset($data);
1500 2051
 		}
1501
-		if ($globalDebug) echo 'No more data...'."\n";
2052
+		if ($globalDebug) {
2053
+			echo 'No more data...'."\n";
2054
+		}
1502 2055
 		unset($buffer);
1503 2056
 		unset($all_data);
1504 2057
 	    }
@@ -1511,7 +2064,9 @@  discard block
 block discarded – undo
1511 2064
 	    )
1512 2065
 	) {
1513 2066
 	    //$buffer = $Common->getData($hosts[$id]);
1514
-	    if ($globalDebug) echo 'Get Data...'."\n";
2067
+	    if ($globalDebug) {
2068
+	    	echo 'Get Data...'."\n";
2069
+	    }
1515 2070
 	    $buffer = $Common->getData($value['host']);
1516 2071
 	    $all_data = json_decode($buffer,true);
1517 2072
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1540,16 +2095,25 @@  discard block
 block discarded – undo
1540 2095
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1541 2096
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1542 2097
     		    //$data['registration'] = $line['aircraft'];
1543
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2098
+		    if (isset($line['route'])) {
2099
+		    	$data['waypoints'] = $line['route'];
2100
+		    }
2101
+		    // route
1544 2102
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1545 2103
     		    $data['id_source'] = $id_source;
1546 2104
 	    	    $data['format_source'] = 'vam';
1547
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1548
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2105
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2106
+		    	$data['noarchive'] = true;
2107
+		    }
2108
+		    if (isset($value['name']) && $value['name'] != '') {
2109
+		    	$data['source_name'] = $value['name'];
2110
+		    }
1549 2111
 		    $SI->add($data);
1550 2112
 		    unset($data);
1551 2113
 		}
1552
-		if ($globalDebug) echo 'No more data...'."\n";
2114
+		if ($globalDebug) {
2115
+			echo 'No more data...'."\n";
2116
+		}
1553 2117
 		unset($buffer);
1554 2118
 		unset($all_data);
1555 2119
 	    }
@@ -1562,7 +2126,9 @@  discard block
 block discarded – undo
1562 2126
 	    )
1563 2127
 	) {
1564 2128
 	    //$buffer = $Common->getData($hosts[$id]);
1565
-	    if ($globalDebug) echo 'Get Data...'."\n";
2129
+	    if ($globalDebug) {
2130
+	    	echo 'Get Data...'."\n";
2131
+	    }
1566 2132
 	    $buffer = $Common->getData($value['host']);
1567 2133
 	    $all_data = json_decode($buffer,true);
1568 2134
 	    if ($buffer != '') {
@@ -1580,12 +2146,16 @@  discard block
 block discarded – undo
1580 2146
 			$data['id_source'] = $id_source;
1581 2147
 			$data['format_source'] = 'blitzortung';
1582 2148
 			$SI->add($data);
1583
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2149
+			if ($globalDebug) {
2150
+				echo '☈ Lightning added'."\n";
2151
+			}
1584 2152
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1585 2153
 			unset($data);
1586 2154
 		    }
1587 2155
 		}
1588
-		if ($globalDebug) echo 'No more data...'."\n";
2156
+		if ($globalDebug) {
2157
+			echo 'No more data...'."\n";
2158
+		}
1589 2159
 		unset($buffer);
1590 2160
 	    }
1591 2161
 	    $last_exec[$id]['last'] = time();
@@ -1614,10 +2184,15 @@  discard block
 block discarded – undo
1614 2184
                 }
1615 2185
             } else {
1616 2186
                 $format = $value['format'];
1617
-                if (isset($tt[$format])) $tt[$format]++;
1618
-                else $tt[$format] = 0;
2187
+                if (isset($tt[$format])) {
2188
+                	$tt[$format]++;
2189
+                } else {
2190
+                	$tt[$format] = 0;
2191
+                }
1619 2192
                 if ($tt[$format] > 30) {
1620
-                    if ($globalDebug) echo 'Reconnect...'."\n";
2193
+                    if ($globalDebug) {
2194
+                    	echo 'Reconnect...'."\n";
2195
+                    }
1621 2196
                     sleep(2);
1622 2197
                     //$sourceeen[] = $value;
1623 2198
                     //connect_all($sourceeen);
@@ -1634,7 +2209,9 @@  discard block
 block discarded – undo
1634 2209
 	    $write = NULL;
1635 2210
 	    $e = NULL;
1636 2211
 	    $n = socket_select($read, $write, $e, $timeout);
1637
-	    if ($e != NULL) var_dump($e);
2212
+	    if ($e != NULL) {
2213
+	    	var_dump($e);
2214
+	    }
1638 2215
 	    if ($n > 0) {
1639 2216
 		$reset = 0;
1640 2217
 		foreach ($read as $nb => $r) {
@@ -1656,13 +2233,17 @@  discard block
 block discarded – undo
1656 2233
 		    if ($buffer !== FALSE) {
1657 2234
 			if ($format === 'vrstcp') {
1658 2235
 			    $buffer = explode('},{',$buffer);
1659
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2236
+			} else {
2237
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2238
+			}
1660 2239
 		    }
1661 2240
 		    // SBS format is CSV format
1662 2241
 		    if ($buffer !== FALSE && $buffer !== '') {
1663 2242
 			$tt[$format] = 0;
1664 2243
 			if ($format === 'acarssbs3') {
1665
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2244
+			    if ($globalDebug) {
2245
+			    	echo 'ACARS : '.$buffer."\n";
2246
+			    }
1666 2247
 			    $ACARS->add(trim($buffer));
1667 2248
 			    $ACARS->deleteLiveAcarsData();
1668 2249
 			} elseif ($format === 'raw') {
@@ -1672,9 +2253,15 @@  discard block
 block discarded – undo
1672 2253
 				//if (!empty($data)) print_r($data);
1673 2254
 				$data['datetime'] = date('Y-m-d H:i:s');
1674 2255
 				$data['format_source'] = 'raw';
1675
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1676
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1677
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2256
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2257
+					$data['source_name'] = $globalSources[$nb]['name'];
2258
+				}
2259
+				if (isset($globalSources[$nb]['sourcestats'])) {
2260
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2261
+				}
2262
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2263
+					$data['noarchive'] = true;
2264
+				}
1678 2265
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1679 2266
 				$SI->add($data);
1680 2267
 				unset($data);
@@ -1682,22 +2269,54 @@  discard block
 block discarded – undo
1682 2269
 			} elseif ($format === 'ais') {
1683 2270
 			    $ais_data = $AIS->parse_line(trim($buffer));
1684 2271
 			    $data = array();
1685
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1686
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1687
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1688
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1689
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1690
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1691
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1692
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1693
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1694
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1695
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1696
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1697
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1698
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1699
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1700
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2272
+			    if (isset($ais_data['ident'])) {
2273
+			    	$data['ident'] = $ais_data['ident'];
2274
+			    }
2275
+			    if (isset($ais_data['mmsi'])) {
2276
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2277
+			    }
2278
+			    if (isset($ais_data['speed'])) {
2279
+			    	$data['speed'] = $ais_data['speed'];
2280
+			    }
2281
+			    if (isset($ais_data['heading'])) {
2282
+			    	$data['heading'] = $ais_data['heading'];
2283
+			    }
2284
+			    if (isset($ais_data['latitude'])) {
2285
+			    	$data['latitude'] = $ais_data['latitude'];
2286
+			    }
2287
+			    if (isset($ais_data['longitude'])) {
2288
+			    	$data['longitude'] = $ais_data['longitude'];
2289
+			    }
2290
+			    if (isset($ais_data['status'])) {
2291
+			    	$data['status'] = $ais_data['status'];
2292
+			    }
2293
+			    if (isset($ais_data['statusid'])) {
2294
+			    	$data['status_id'] = $ais_data['statusid'];
2295
+			    }
2296
+			    if (isset($ais_data['type'])) {
2297
+			    	$data['type'] = $ais_data['type'];
2298
+			    }
2299
+			    if (isset($ais_data['imo'])) {
2300
+			    	$data['imo'] = $ais_data['imo'];
2301
+			    }
2302
+			    if (isset($ais_data['callsign'])) {
2303
+			    	$data['callsign'] = $ais_data['callsign'];
2304
+			    }
2305
+			    if (isset($ais_data['destination'])) {
2306
+			    	$data['arrival_code'] = $ais_data['destination'];
2307
+			    }
2308
+			    if (isset($ais_data['eta_ts'])) {
2309
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2310
+			    }
2311
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2312
+			    	$data['noarchive'] = true;
2313
+			    }
2314
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2315
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2316
+			    }
2317
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2318
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2319
+			    }
1701 2320
 
1702 2321
 			    if (isset($ais_data['timestamp'])) {
1703 2322
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1706,7 +2325,9 @@  discard block
 block discarded – undo
1706 2325
 			    }
1707 2326
 			    $data['format_source'] = 'aisnmea';
1708 2327
     			    $data['id_source'] = $id_source;
1709
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2328
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2329
+			    	$MI->add($data);
2330
+			    }
1710 2331
 			    unset($data);
1711 2332
                         } elseif ($format === 'flightgearsp') {
1712 2333
                     	    //echo $buffer."\n";
@@ -1724,12 +2345,18 @@  discard block
 block discarded – undo
1724 2345
 				$data['speed'] = round($line[5]*1.94384);
1725 2346
 				$data['datetime'] = date('Y-m-d H:i:s');
1726 2347
 				$data['format_source'] = 'flightgearsp';
1727
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1728
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2348
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2349
+					$data['noarchive'] = true;
2350
+				}
2351
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2352
+					$SI->add($data);
2353
+				}
1729 2354
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1730 2355
 			    }
1731 2356
                         } elseif ($format === 'acars') {
1732
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2357
+                    	    if ($globalDebug) {
2358
+                    	    	echo 'ACARS : '.$buffer."\n";
2359
+                    	    }
1733 2360
 			    $ACARS->add(trim($buffer));
1734 2361
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1735 2362
 			    $ACARS->deleteLiveAcarsData();
@@ -1750,8 +2377,12 @@  discard block
 block discarded – undo
1750 2377
 				    $aircraft_type = $line[10];
1751 2378
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1752 2379
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1753
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1754
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2380
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2381
+				    	$data['noarchive'] = true;
2382
+				    }
2383
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2384
+				    	$SI->add($data);
2385
+				    }
1755 2386
 				}
1756 2387
 			    }
1757 2388
 			} elseif ($format === 'beast') {
@@ -1761,28 +2392,62 @@  discard block
 block discarded – undo
1761 2392
 			    foreach($buffer as $all_data) {
1762 2393
 				$line = json_decode('{'.$all_data.'}',true);
1763 2394
 				$data = array();
1764
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1765
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1766
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1767
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1768
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1769
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1770
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2395
+				if (isset($line['Icao'])) {
2396
+					$data['hex'] = $line['Icao'];
2397
+				}
2398
+				// hex
2399
+				if (isset($line['Call'])) {
2400
+					$data['ident'] = $line['Call'];
2401
+				}
2402
+				// ident
2403
+				if (isset($line['Alt'])) {
2404
+					$data['altitude'] = $line['Alt'];
2405
+				}
2406
+				// altitude
2407
+				if (isset($line['Spd'])) {
2408
+					$data['speed'] = $line['Spd'];
2409
+				}
2410
+				// speed
2411
+				if (isset($line['Trak'])) {
2412
+					$data['heading'] = $line['Trak'];
2413
+				}
2414
+				// heading
2415
+				if (isset($line['Lat'])) {
2416
+					$data['latitude'] = $line['Lat'];
2417
+				}
2418
+				// lat
2419
+				if (isset($line['Long'])) {
2420
+					$data['longitude'] = $line['Long'];
2421
+				}
2422
+				// long
1771 2423
 				//$data['verticalrate'] = $line['']; // verticale rate
1772
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2424
+				if (isset($line['Sqk'])) {
2425
+					$data['squawk'] = $line['Sqk'];
2426
+				}
2427
+				// squawk
1773 2428
 				$data['emergency'] = ''; // emergency
1774
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2429
+				if (isset($line['Reg'])) {
2430
+					$data['registration'] = $line['Reg'];
2431
+				}
1775 2432
 				/*
1776 2433
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1777 2434
 				else $data['datetime'] = date('Y-m-d H:i:s');
1778 2435
 				*/
1779 2436
 				$data['datetime'] = date('Y-m-d H:i:s');
1780
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2437
+				if (isset($line['Type'])) {
2438
+					$data['aircraft_icao'] = $line['Type'];
2439
+				}
1781 2440
 		    		$data['format_source'] = 'vrstcp';
1782 2441
 				$data['id_source'] = $id_source;
1783
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1784
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1785
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2442
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2443
+					$data['noarchive'] = true;
2444
+				}
2445
+				if (isset($value['name']) && $value['name'] != '') {
2446
+					$data['source_name'] = $value['name'];
2447
+				}
2448
+				if (isset($data['latitude']) && isset($data['hex'])) {
2449
+					$SI->add($data);
2450
+				}
1786 2451
 				unset($data);
1787 2452
 			    }
1788 2453
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1795,22 +2460,46 @@  discard block
 block discarded – undo
1795 2460
     				$data['hex'] = $lined['hexid'];
1796 2461
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1797 2462
     				$data['datetime'] = date('Y-m-d H:i:s');;
1798
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1799
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1800
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1801
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1802
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1803
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1804
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2463
+    				if (isset($lined['ident'])) {
2464
+    					$data['ident'] = $lined['ident'];
2465
+    				}
2466
+    				if (isset($lined['lat'])) {
2467
+    					$data['latitude'] = $lined['lat'];
2468
+    				}
2469
+    				if (isset($lined['lon'])) {
2470
+    					$data['longitude'] = $lined['lon'];
2471
+    				}
2472
+    				if (isset($lined['speed'])) {
2473
+    					$data['speed'] = $lined['speed'];
2474
+    				}
2475
+    				if (isset($lined['squawk'])) {
2476
+    					$data['squawk'] = $lined['squawk'];
2477
+    				}
2478
+    				if (isset($lined['alt'])) {
2479
+    					$data['altitude'] = $lined['alt'];
2480
+    				}
2481
+    				if (isset($lined['heading'])) {
2482
+    					$data['heading'] = $lined['heading'];
2483
+    				}
1805 2484
     				$data['id_source'] = $id_source;
1806 2485
     				$data['format_source'] = 'tsv';
1807
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1808
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1809
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1810
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2486
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2487
+    					$data['source_name'] = $globalSources[$nb]['name'];
2488
+    				}
2489
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2490
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2491
+    				}
2492
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2493
+					$data['noarchive'] = true;
2494
+				}
2495
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2496
+    					$SI->add($data);
2497
+    				}
1811 2498
     				unset($lined);
1812 2499
     				unset($data);
1813
-    			    } else $error = true;
2500
+    			    } else {
2501
+    			    	$error = true;
2502
+    			    }
1814 2503
 			} elseif ($format === 'aprs' && $use_aprs) {
1815 2504
 			    if ($aprs_connect === 0) {
1816 2505
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1836,47 +2525,96 @@  discard block
 block discarded – undo
1836 2525
 				    $aprs_last_tx = time();
1837 2526
 				    $data = array();
1838 2527
 				    //print_r($line);
1839
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1840
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1841
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1842
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1843
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1844
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1845
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1846
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1847
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1848
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2528
+				    if (isset($line['address'])) {
2529
+				    	$data['hex'] = $line['address'];
2530
+				    }
2531
+				    if (isset($line['mmsi'])) {
2532
+				    	$data['mmsi'] = $line['mmsi'];
2533
+				    }
2534
+				    if (isset($line['imo'])) {
2535
+				    	$data['imo'] = $line['imo'];
2536
+				    }
2537
+				    if (isset($line['squawk'])) {
2538
+				    	$data['squawk'] = $line['squawk'];
2539
+				    }
2540
+				    if (isset($line['arrival_code'])) {
2541
+				    	$data['arrival_code'] = $line['arrival_code'];
2542
+				    }
2543
+				    if (isset($line['arrival_date'])) {
2544
+				    	$data['arrival_date'] = $line['arrival_date'];
2545
+				    }
2546
+				    if (isset($line['typeid'])) {
2547
+				    	$data['type_id'] = $line['typeid'];
2548
+				    }
2549
+				    if (isset($line['statusid'])) {
2550
+				    	$data['status_id'] = $line['statusid'];
2551
+				    }
2552
+				    if (isset($line['timestamp'])) {
2553
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2554
+				    } else {
2555
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2556
+				    }
1849 2557
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1850
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2558
+				    if (isset($line['ident'])) {
2559
+				    	$data['ident'] = $line['ident'];
2560
+				    }
1851 2561
 				    $data['latitude'] = $line['latitude'];
1852 2562
 				    $data['longitude'] = $line['longitude'];
1853 2563
 				    //$data['verticalrate'] = $line[16];
1854
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2564
+				    if (isset($line['speed'])) {
2565
+				    	$data['speed'] = $line['speed'];
2566
+				    }
1855 2567
 				    //else $data['speed'] = 0;
1856
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1857
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1858
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2568
+				    if (isset($line['altitude'])) {
2569
+				    	$data['altitude'] = $line['altitude'];
2570
+				    }
2571
+				    if (isset($line['comment'])) {
2572
+				    	$data['comment'] = $line['comment'];
2573
+				    }
2574
+				    if (isset($line['symbol'])) {
2575
+				    	$data['type'] = $line['symbol'];
2576
+				    }
1859 2577
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1860 2578
 				    
1861
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2579
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2580
+				    	$data['heading'] = $line['heading'];
2581
+				    }
1862 2582
 				    //else echo 'No heading...'."\n";
1863 2583
 				    //else $data['heading'] = 0;
1864
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2584
+				    if (isset($line['stealth'])) {
2585
+				    	$data['aircraft_type'] = $line['stealth'];
2586
+				    }
1865 2587
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1866
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1867
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1868
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1869
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2588
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2589
+				    	$data['noarchive'] = true;
2590
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2591
+				    	$data['noarchive'] = false;
2592
+				    }
2593
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2594
+				    	$data['noarchive'] = true;
2595
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2596
+				    	$data['noarchive'] = false;
2597
+				    }
1870 2598
     				    $data['id_source'] = $id_source;
1871
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1872
-				    else $data['format_source'] = 'aprs';
2599
+    				    if (isset($line['format_source'])) {
2600
+    				    	$data['format_source'] = $line['format_source'];
2601
+    				    } else {
2602
+				    	$data['format_source'] = 'aprs';
2603
+				    }
1873 2604
 				    $data['source_name'] = $line['source'];
1874
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1875
-				    else $data['source_type'] = 'flarm';
1876
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2605
+				    if (isset($line['source_type'])) {
2606
+				    	$data['source_type'] = $line['source_type'];
2607
+				    } else {
2608
+				    	$data['source_type'] = 'flarm';
2609
+				    }
2610
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2611
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2612
+    				    }
1877 2613
 				    $currentdate = date('Y-m-d H:i:s');
1878 2614
 				    $aprsdate = strtotime($data['datetime']);
1879
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2615
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2616
+				    	$data['altitude_relative'] = 'AMSL';
2617
+				    }
1880 2618
 				    // Accept data if time <= system time + 20s
1881 2619
 				    //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'])))) {
1882 2620
 				    if (
@@ -1888,7 +2626,9 @@  discard block
 block discarded – undo
1888 2626
 					$send = $SI->add($data);
1889 2627
 				    } elseif ($data['source_type'] === 'ais') {
1890 2628
 					$data['type'] = '';
1891
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2629
+					if (isset($globalMarine) && $globalMarine) {
2630
+						$send = $MI->add($data);
2631
+					}
1892 2632
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1893 2633
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1894 2634
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1896,8 +2636,12 @@  discard block
 block discarded – undo
1896 2636
 					    $line['symbol'] === 'Glider' || 
1897 2637
 					    $line['symbol'] === 'No. Plane' || 
1898 2638
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1899
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1900
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2639
+					    if ($line['symbol'] === 'Ballon') {
2640
+					    	$data['aircraft_icao'] = 'BALL';
2641
+					    }
2642
+					    if ($line['symbol'] === 'Glider') {
2643
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2644
+					    }
1901 2645
 					    $send = $SI->add($data);
1902 2646
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1903 2647
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1928,9 +2672,13 @@  discard block
 block discarded – undo
1928 2672
 				    //} 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') {
1929 2673
 				//    } 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') {
1930 2674
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1931
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2675
+					if (isset($globalTracker) && $globalTracker) {
2676
+						$send = $TI->add($data);
2677
+					}
1932 2678
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1933
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2679
+					if (!isset($data['altitude'])) {
2680
+						$data['altitude'] = 0;
2681
+					}
1934 2682
 					$Source->deleteOldLocationByType('gs');
1935 2683
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1936 2684
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1939,7 +2687,9 @@  discard block
 block discarded – undo
1939 2687
 					}
1940 2688
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1941 2689
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1942
-					if ($globalDebug) echo '# Weather Station added'."\n";
2690
+					if ($globalDebug) {
2691
+						echo '# Weather Station added'."\n";
2692
+					}
1943 2693
 					$Source->deleteOldLocationByType('wx');
1944 2694
 					$weather_data = json_encode($line);
1945 2695
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1949,7 +2699,9 @@  discard block
 block discarded – undo
1949 2699
 					}
1950 2700
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1951 2701
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1952
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2702
+					if ($globalDebug) {
2703
+						echo '☈ Lightning added'."\n";
2704
+					}
1953 2705
 					$Source->deleteOldLocationByType('lightning');
1954 2706
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1955 2707
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1961,8 +2713,7 @@  discard block
 block discarded – undo
1961 2713
 				    	print_r($line);
1962 2714
 				    }
1963 2715
 				    unset($data);
1964
-				}
1965
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2716
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1966 2717
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1967 2718
 				}
1968 2719
 				/*
@@ -1971,7 +2722,9 @@  discard block
 block discarded – undo
1971 2722
 				}
1972 2723
 				*/
1973 2724
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1974
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2725
+				elseif ($line === true && $globalDebug) {
2726
+					echo '!! Failed : '.$buffer."!!\n";
2727
+				}
1975 2728
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1976 2729
 					$Source->deleteOldLocationByType('lightning');
1977 2730
 					$Source->deleteOldLocationByType('wx');
@@ -2008,27 +2761,47 @@  discard block
 block discarded – undo
2008 2761
     				$data['ground'] = $line[21];
2009 2762
     				$data['emergency'] = $line[19];
2010 2763
     				$data['format_source'] = 'sbs';
2011
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2012
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2013
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2014
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2764
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2765
+					$data['source_name'] = $globalSources[$nb]['name'];
2766
+				} elseif ($line[0] == 'MLAT') {
2767
+					$data['source_name'] = 'MLAT';
2768
+				}
2769
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2770
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2771
+    				}
2772
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2773
+					$data['noarchive'] = true;
2774
+				}
2015 2775
     				$data['id_source'] = $id_source;
2016
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2017
-    				else $error = true;
2776
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2777
+    					$send = $SI->add($data);
2778
+    				} else {
2779
+    					$error = true;
2780
+    				}
2018 2781
     				unset($data);
2019
-    			    } else $error = true;
2782
+    			    } else {
2783
+    			    	$error = true;
2784
+    			    }
2020 2785
 			    if ($error) {
2021 2786
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2022
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2787
+					if ($globalDebug) {
2788
+						echo "Not a message. Ignoring... \n";
2789
+					}
2023 2790
 				} else {
2024
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2791
+					if ($globalDebug) {
2792
+						echo "Wrong line format. Ignoring... \n";
2793
+					}
2025 2794
 					if ($globalDebug) {
2026 2795
 						echo $buffer;
2027 2796
 						//print_r($line);
2028 2797
 					}
2029 2798
 					//socket_close($r);
2030
-					if ($globalDebug) echo "Reconnect after an error...\n";
2031
-					if ($format === 'aprs') $aprs_connect = 0;
2799
+					if ($globalDebug) {
2800
+						echo "Reconnect after an error...\n";
2801
+					}
2802
+					if ($format === 'aprs') {
2803
+						$aprs_connect = 0;
2804
+					}
2032 2805
 					$sourceer[$nb] = $globalSources[$nb];
2033 2806
 					connect_all($sourceer);
2034 2807
 					$sourceer = array();
@@ -2036,10 +2809,14 @@  discard block
 block discarded – undo
2036 2809
 			    }
2037 2810
 			}
2038 2811
 			// Sleep for xxx microseconds
2039
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2812
+			if (isset($globalSBSSleep)) {
2813
+				usleep($globalSBSSleep);
2814
+			}
2040 2815
 		    } else {
2041 2816
 			if ($format === 'flightgearmp') {
2042
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2817
+			    	if ($globalDebug) {
2818
+			    		echo "Reconnect FlightGear MP...";
2819
+			    	}
2043 2820
 				//@socket_close($r);
2044 2821
 				sleep($globalMinFetch);
2045 2822
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2048,10 +2825,15 @@  discard block
 block discarded – undo
2048 2825
 				break;
2049 2826
 				
2050 2827
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2051
-			    if (isset($tt[$format])) $tt[$format]++;
2052
-			    else $tt[$format] = 0;
2828
+			    if (isset($tt[$format])) {
2829
+			    	$tt[$format]++;
2830
+			    } else {
2831
+			    	$tt[$format] = 0;
2832
+			    }
2053 2833
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2054
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2834
+				if ($globalDebug) {
2835
+					echo "ERROR : Reconnect ".$format."...";
2836
+				}
2055 2837
 				//@socket_close($r);
2056 2838
 				sleep(2);
2057 2839
 				$aprs_connect = 0;
@@ -2069,11 +2851,17 @@  discard block
 block discarded – undo
2069 2851
 	    } else {
2070 2852
 		$error = socket_strerror(socket_last_error());
2071 2853
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2072
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2073
-			if (isset($globalDebug)) echo "Restarting...\n";
2854
+			if ($globalDebug) {
2855
+				echo "ERROR : socket_select give this error ".$error . "\n";
2856
+			}
2857
+			if (isset($globalDebug)) {
2858
+				echo "Restarting...\n";
2859
+			}
2074 2860
 			// Restart the script if possible
2075 2861
 			if (is_array($sockets)) {
2076
-			    if ($globalDebug) echo "Shutdown all sockets...";
2862
+			    if ($globalDebug) {
2863
+			    	echo "Shutdown all sockets...";
2864
+			    }
2077 2865
 			    
2078 2866
 			    foreach ($sockets as $sock) {
2079 2867
 				@socket_shutdown($sock,2);
@@ -2081,25 +2869,45 @@  discard block
 block discarded – undo
2081 2869
 			    }
2082 2870
 			    
2083 2871
 			}
2084
-			if ($globalDebug) echo "Waiting...";
2872
+			if ($globalDebug) {
2873
+				echo "Waiting...";
2874
+			}
2085 2875
 			sleep(2);
2086 2876
 			$time = time();
2087 2877
 			//connect_all($hosts);
2088 2878
 			$aprs_connect = 0;
2089
-			if ($reset%5 === 0) sleep(20);
2090
-			if ($reset%10 === 0) sleep(100);
2091
-			if ($reset%20 === 0) sleep(200);
2092
-			if ($reset > 100) exit('Too many attempts...');
2093
-			if ($globalDebug) echo "Restart all connections...";
2879
+			if ($reset%5 === 0) {
2880
+				sleep(20);
2881
+			}
2882
+			if ($reset%10 === 0) {
2883
+				sleep(100);
2884
+			}
2885
+			if ($reset%20 === 0) {
2886
+				sleep(200);
2887
+			}
2888
+			if ($reset > 100) {
2889
+				exit('Too many attempts...');
2890
+			}
2891
+			if ($globalDebug) {
2892
+				echo "Restart all connections...";
2893
+			}
2094 2894
 			connect_all($globalSources);
2095 2895
 		}
2096 2896
 	    }
2097 2897
 	}
2098 2898
 	if ($globalDaemon === false) {
2099
-	    if ($globalDebug) echo 'Check all...'."\n";
2100
-	    if (isset($SI)) $SI->checkAll();
2101
-	    if (isset($TI)) $TI->checkAll();
2102
-	    if (isset($MI)) $MI->checkAll();
2899
+	    if ($globalDebug) {
2900
+	    	echo 'Check all...'."\n";
2901
+	    }
2902
+	    if (isset($SI)) {
2903
+	    	$SI->checkAll();
2904
+	    }
2905
+	    if (isset($TI)) {
2906
+	    	$TI->checkAll();
2907
+	    }
2908
+	    if (isset($MI)) {
2909
+	    	$MI->checkAll();
2910
+	    }
2103 2911
 	}
2104 2912
     }
2105 2913
 }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +643 added lines, -171 removed lines patch added patch discarded remove patch
@@ -4,12 +4,22 @@  discard block
 block discarded – undo
4 4
 if (isset($_SESSION['error'])) {
5 5
 	header('Content-Encoding: none;');
6 6
 	echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.';
7
-	if (isset($_SESSION['error'])) unset($_SESSION['error']);
8
-	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
9
-	if (isset($_SESSION['next'])) unset($_SESSION['next']);
10
-	if (isset($_SESSION['install'])) unset($_SESSION['install']);
11
-	if (isset($_SESSION['identitied'])) unset($_SESSION['identified']);
12
-}
7
+	if (isset($_SESSION['error'])) {
8
+		unset($_SESSION['error']);
9
+	}
10
+	if (isset($_SESSION['errorlst'])) {
11
+		unset($_SESSION['errorlst']);
12
+	}
13
+	if (isset($_SESSION['next'])) {
14
+		unset($_SESSION['next']);
15
+	}
16
+	if (isset($_SESSION['install'])) {
17
+		unset($_SESSION['install']);
18
+	}
19
+	if (isset($_SESSION['identitied'])) {
20
+		unset($_SESSION['identified']);
21
+	}
22
+	}
13 23
 /*
14 24
 if (isset($_SESSION['errorlst'])) {
15 25
 	header('Content-Encoding: none;');
@@ -131,7 +141,9 @@  discard block
 block discarded – undo
131 141
 		if (count($alllng) != count($availablelng)) {
132 142
 			$notavailable = array();
133 143
 			foreach($alllng as $lng) {
134
-				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
144
+				if (!isset($availablelng[$lng])) {
145
+					$notavailable[] = $lng;
146
+				}
135 147
 			}
136 148
 			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
137 149
 		}
@@ -170,7 +182,10 @@  discard block
 block discarded – undo
170 182
 			<legend>Install script configuration</legend>
171 183
 			<p>
172 184
 				<label for="installpass">Install password</label>
173
-				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" />
185
+				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) {
186
+	print $globalInstallPassword;
187
+}
188
+?>" />
174 189
 			</p>
175 190
 			<p class="help-block">Password needed to access this install script. If empty, to access this script,  you will need to change the $globalInstalled setting in require/settings.php to FALSE</p>
176 191
 		</fieldset>
@@ -200,31 +215,49 @@  discard block
 block discarded – undo
200 215
 			</div>
201 216
 			<p>
202 217
 				<label for="dbhost">Database hostname</label>
203
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
218
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
219
+	print $globalDBhost;
220
+}
221
+?>" />
204 222
 			</p>
205 223
 			<p>
206 224
 				<label for="dbport">Database port</label>
207
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
225
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
226
+	print $globalDBport;
227
+}
228
+?>" />
208 229
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
209 230
 			</p>
210 231
 			<p>
211 232
 				<label for="dbname">Database name</label>
212
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
233
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
234
+	print $globalDBname;
235
+}
236
+?>" />
213 237
 			</p>
214 238
 			<p>
215 239
 				<label for="dbuser">Database user</label>
216
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
240
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
241
+	print $globalDBuser;
242
+}
243
+?>" />
217 244
 			</p>
218 245
 			<p>
219 246
 				<label for="dbuserpass">Database user password</label>
220
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
247
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
248
+	print $globalDBpass;
249
+}
250
+?>" />
221 251
 			</p>
222 252
 		</fieldset>
223 253
 		<fieldset id="site">
224 254
 			<legend>Site configuration</legend>
225 255
 			<p>
226 256
 				<label for="sitename">Site name</label>
227
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
257
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
258
+	print $globalName;
259
+}
260
+?>" />
228 261
 			</p>
229 262
 			<p>
230 263
 				<label for="siteurl">Site directory</label>
@@ -237,18 +270,27 @@  discard block
 block discarded – undo
237 270
 					}
238 271
 				    }
239 272
 				?>
240
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
273
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
274
+	print $globalURL;
275
+}
276
+?>" />
241 277
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
242 278
 				<p class="help-block">Can be empty</p>
243 279
 			</p>
244 280
 			<p>
245 281
 				<label for="timezone">Timezone</label>
246
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
282
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
283
+	print $globalTimezone;
284
+}
285
+?>" />
247 286
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
248 287
 			</p>
249 288
 			<p>
250 289
 				<label for="language">Language</label>
251
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
290
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
291
+	print $globalLanguage;
292
+}
293
+?>" />
252 294
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
253 295
 			</p>
254 296
 		</fieldset>
@@ -268,11 +310,17 @@  discard block
 block discarded – undo
268 310
 			<div id="mapbox_data">
269 311
 				<p>
270 312
 					<label for="mapboxid">Mapbox id</label>
271
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
313
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
314
+	print $globalMapboxId;
315
+}
316
+?>" />
272 317
 				</p>
273 318
 				<p>
274 319
 					<label for="mapboxtoken">Mapbox token</label>
275
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
320
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
321
+	print $globalMapboxToken;
322
+}
323
+?>" />
276 324
 				</p>
277 325
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
278 326
 			</div>
@@ -280,7 +328,10 @@  discard block
 block discarded – undo
280 328
 			<div id="google_data">
281 329
 				<p>
282 330
 					<label for="googlekey">Google API key</label>
283
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
331
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
332
+	print $globalGoogleAPIKey;
333
+}
334
+?>" />
284 335
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
285 336
 				</p>
286 337
 			</div>
@@ -288,7 +339,10 @@  discard block
 block discarded – undo
288 339
 			<div id="bing_data">
289 340
 				<p>
290 341
 					<label for="bingkey">Bing Map key</label>
291
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
342
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
343
+	print $globalBingMapKey;
344
+}
345
+?>" />
292 346
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
293 347
 				</p>
294 348
 			</div>
@@ -296,7 +350,10 @@  discard block
 block discarded – undo
296 350
 			<div id="mapquest_data">
297 351
 				<p>
298 352
 					<label for="mapquestkey">MapQuest key</label>
299
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
353
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
354
+	print $globalMapQuestKey;
355
+}
356
+?>" />
300 357
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
301 358
 				</p>
302 359
 			</div>
@@ -304,11 +361,17 @@  discard block
 block discarded – undo
304 361
 			<div id="here_data">
305 362
 				<p>
306 363
 					<label for="hereappid">Here App_Id</label>
307
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
364
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
365
+	print $globalHereappId;
366
+}
367
+?>" />
308 368
 				</p>
309 369
 				<p>
310 370
 					<label for="hereappcode">Here App_Code</label>
311
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
371
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
372
+	print $globalHereappCode;
373
+}
374
+?>" />
312 375
 				</p>
313 376
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
314 377
 			</div>
@@ -316,7 +379,10 @@  discard block
 block discarded – undo
316 379
 			<div id="openweathermap_data">
317 380
 				<p>
318 381
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
319
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
382
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
383
+	print $globalOpenWeatherMapKey;
384
+}
385
+?>" />
320 386
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
321 387
 				</p>
322 388
 			</div>
@@ -345,42 +411,86 @@  discard block
 block discarded – undo
345 411
 			<legend>Coverage area</legend>
346 412
 			<p>
347 413
 				<label for="latitudemax">The maximum latitude (north)</label>
348
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
414
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
415
+	print $globalLatitudeMax;
416
+}
417
+?>" />
349 418
 			</p>
350 419
 			<p>
351 420
 				<label for="latitudemin">The minimum latitude (south)</label>
352
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
421
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
422
+	print $globalLatitudeMin;
423
+}
424
+?>" />
353 425
 			</p>
354 426
 			<p>
355 427
 				<label for="longitudemax">The maximum longitude (west)</label>
356
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
428
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
429
+	print $globalLongitudeMax;
430
+}
431
+?>" />
357 432
 			</p>
358 433
 			<p>
359 434
 				<label for="longitudemin">The minimum longitude (east)</label>
360
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
435
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
436
+	print $globalLongitudeMin;
437
+}
438
+?>" />
361 439
 			</p>
362 440
 			<p>
363 441
 				<label for="latitudecenter">The latitude center</label>
364
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
442
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
443
+	print $globalCenterLatitude;
444
+}
445
+?>" />
365 446
 			</p>
366 447
 			<p>
367 448
 				<label for="longitudecenter">The longitude center</label>
368
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
449
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
450
+	print $globalCenterLongitude;
451
+}
452
+?>" />
369 453
 			</p>
370 454
 			<p>
371 455
 				<label for="livezoom">Default Zoom on live map</label>
372
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
456
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
457
+	print $globalLiveZoom;
458
+} else {
459
+	print '9';
460
+}
461
+?>" />
373 462
 			</p>
374 463
 			<p>
375 464
 				<label for="squawk_country">Country for squawk usage</label>
376 465
 				<select name="squawk_country" id="squawk_country">
377
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
378
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
379
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
380
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
381
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
382
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
383
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
466
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
467
+	print ' selected ';
468
+}
469
+?>>UK</option>
470
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
471
+	print ' selected ';
472
+}
473
+?>>NZ</option>
474
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
475
+	print ' selected ';
476
+}
477
+?>>US</option>
478
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
479
+	print ' selected ';
480
+}
481
+?>>AU</option>
482
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
483
+	print ' selected ';
484
+}
485
+?>>NL</option>
486
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
487
+	print ' selected ';
488
+}
489
+?>>FR</option>
490
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
491
+	print ' selected ';
492
+}
493
+?>>TR</option>
384 494
 				</select>
385 495
 			</p>
386 496
 		</fieldset>
@@ -389,15 +499,24 @@  discard block
 block discarded – undo
389 499
 			<p><i>Only put in DB flights that are inside a circle</i></p>
390 500
 			<p>
391 501
 				<label for="latitude">Center latitude</label>
392
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
502
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
503
+	echo $globalDistanceIgnore['latitude'];
504
+}
505
+?>" />
393 506
 			</p>
394 507
 			<p>
395 508
 				<label for="longitude">Center longitude</label>
396
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
509
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
510
+	echo $globalDistanceIgnore['longitude'];
511
+}
512
+?>" />
397 513
 			</p>
398 514
 			<p>
399 515
 				<label for="Distance">Distance (in km)</label>
400
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
516
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
517
+	echo $globalDistanceIgnore['distance'];
518
+}
519
+?>" />
401 520
 			</p>
402 521
 		</fieldset>
403 522
 		<fieldset id="sourceloc">
@@ -523,22 +642,34 @@  discard block
 block discarded – undo
523 642
 			<div id="flightaware_data">
524 643
 				<p>
525 644
 					<label for="flightawareusername">FlightAware username</label>
526
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
645
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
646
+	print $globalFlightAwareUsername;
647
+}
648
+?>" />
527 649
 				</p>
528 650
 				<p>
529 651
 					<label for="flightawarepassword">FlightAware password/API key</label>
530
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
652
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
653
+	print $globalFlightAwarePassword;
654
+}
655
+?>" />
531 656
 				</p>
532 657
 			</div>
533 658
 -->
534 659
 			<div id="sailaway_data">
535 660
 				<p>
536 661
 					<label for="sailawayemail">Sailaway email</label>
537
-					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" />
662
+					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) {
663
+	print $globalSailaway['email'];
664
+}
665
+?>" />
538 666
 				</p>
539 667
 				<p>
540 668
 					<label for="sailawaypassword">Sailaway password</label>
541
-					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" />
669
+					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) {
670
+	print $globalSailaway['password'];
671
+}
672
+?>" />
542 673
 				</p>
543 674
 			</div>
544 675
 
@@ -580,7 +711,10 @@  discard block
 block discarded – undo
580 711
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
581 712
 								?>
582 713
 								<td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td>
583
-								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
714
+								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) {
715
+	print $source['port'];
716
+}
717
+?>" /></td>
584 718
 								<?php
585 719
 								    } else {
586 720
 									$hostport = explode(':',$source['host']);
@@ -599,38 +733,122 @@  discard block
 block discarded – undo
599 733
 								?>
600 734
 								<td>
601 735
 									<select name="format[]">
602
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
603
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
604
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
605
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
606
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
607
-										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option>
608
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
609
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
610
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
611
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
612
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
613
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
614
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
615
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
616
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
617
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
618
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
619
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
620
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
621
-                                        <option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json</option>
622
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
623
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
624
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
625
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
626
-										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option>
736
+										<option value="auto" <?php if (!isset($source['format'])) {
737
+	print 'selected';
738
+}
739
+?>>Auto</option>
740
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
741
+	print 'selected';
742
+}
743
+?>>SBS</option>
744
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
745
+	print 'selected';
746
+}
747
+?>>TSV</option>
748
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
749
+	print 'selected';
750
+}
751
+?>>Raw</option>
752
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
753
+	print 'selected';
754
+}
755
+?>>Dump1090 aircraft.json</option>
756
+										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') {
757
+	print 'selected';
758
+}
759
+?>>Planefinder client</option>
760
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
761
+	print 'selected';
762
+}
763
+?>>APRS</option>
764
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
765
+	print 'selected';
766
+}
767
+?>>Radarcape deltadb.txt</option>
768
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
769
+	print 'selected';
770
+}
771
+?>>Vatsim</option>
772
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
773
+	print 'selected';
774
+}
775
+?>>Virtual Radar Server AircraftList.json</option>
776
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
777
+	print 'selected';
778
+}
779
+?>>Virtual Radar Server TCP</option>
780
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
781
+	print 'selected';
782
+}
783
+?>>phpVMS</option>
784
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
785
+	print 'selected';
786
+}
787
+?>>Virtual Airline Operations System (VAOS)</option>
788
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
789
+	print 'selected';
790
+}
791
+?>>Virtual Airlines Manager</option>
792
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
793
+	print 'selected';
794
+}
795
+?>>IVAO</option>
796
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
797
+	print 'selected';
798
+}
799
+?>>FlightGear Multiplayer</option>
800
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
801
+	print 'selected';
802
+}
803
+?>>FlightGear Singleplayer</option>
804
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
805
+	print 'selected';
806
+}
807
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
808
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
809
+	print 'selected';
810
+}
811
+?>>ACARS SBS-3 over TCP</option>
812
+                                        <option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') {
813
+	print 'selected';
814
+}
815
+?>>ACARS from acarsdec json</option>
816
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
817
+	print 'selected';
818
+}
819
+?>>NMEA AIS over TCP</option>
820
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
821
+	print 'selected';
822
+}
823
+?>>AirWhere website</option>
824
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
825
+	print 'selected';
826
+}
827
+?>>HidnSeek Callback</option>
828
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
829
+	print 'selected';
830
+}
831
+?>>Blitzortung</option>
832
+										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') {
833
+	print 'selected';
834
+}
835
+?>>Sailaway</option>
627 836
 									</select>
628 837
 								</td>
629 838
 								<td>
630
-									<input type="text" name="name[]" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
839
+									<input type="text" name="name[]" value="<?php if (isset($source['name'])) {
840
+	print $source['name'];
841
+}
842
+?>" />
631 843
 								</td>
632
-								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
633
-								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
844
+								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
845
+	print 'checked';
846
+}
847
+?> /></td>
848
+								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
849
+	print 'checked';
850
+}
851
+?> /></td>
634 852
 								<td>
635 853
 									<select name="timezones[]">
636 854
 								<?php
@@ -640,7 +858,9 @@  discard block
 block discarded – undo
640 858
 											print '<option selected>'.$timezones.'</option>';
641 859
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
642 860
 											print '<option selected>'.$timezones.'</option>';
643
-										} else print '<option>'.$timezones.'</option>';
861
+										} else {
862
+											print '<option>'.$timezones.'</option>';
863
+										}
644 864
 									}
645 865
 								?>
646 866
 									</select>
@@ -695,7 +915,9 @@  discard block
 block discarded – undo
695 915
 									foreach($timezonelist as $timezones){
696 916
 										if ($timezones == 'UTC') {
697 917
 											print '<option selected>'.$timezones.'</option>';
698
-										} else print '<option>'.$timezones.'</option>';
918
+										} else {
919
+											print '<option>'.$timezones.'</option>';
920
+										}
699 921
 									}
700 922
 								?>
701 923
 									</select>
@@ -720,11 +942,17 @@  discard block
 block discarded – undo
720 942
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
721 943
 					<p>
722 944
 						<label for="acarshost">ACARS UDP host</label>
723
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
945
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
946
+	print $globalACARSHost;
947
+}
948
+?>" />
724 949
 					</p>
725 950
 					<p>
726 951
 						<label for="acarsport">ACARS UDP port</label>
727
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
952
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
953
+	print $globalACARSPort;
954
+}
955
+?>" />
728 956
 					</p>
729 957
 					<p class="help-block"><i>daemon-acars.php</i> can only be run as daemon. It's an alternate script for ACARS data, <i>daemon-spotter.php</i> may be better.</p>
730 958
 				</fieldset>
@@ -751,17 +979,38 @@  discard block
 block discarded – undo
751 979
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
752 980
 				    <td>
753 981
 					<select name="newslang[]">
754
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
755
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
982
+					    <option value="en"<?php if ($lng == 'en') {
983
+	print ' selected';
984
+}
985
+?>>English</option>
986
+					    <option value="fr"<?php if ($lng == 'fr') {
987
+	print ' selected';
988
+}
989
+?>>French</option>
756 990
 					</select>
757 991
 				    </td>
758 992
 				    <td>
759 993
 					<select name="newstype[]">
760
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
761
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
762
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
763
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
764
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
994
+					    <option value="global"<?php if ($type == 'global') {
995
+	print ' selected';
996
+}
997
+?>>Global</option>
998
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
999
+	print ' selected';
1000
+}
1001
+?>>Aircraft</option>
1002
+					    <option value="marine"<?php if ($type == 'marine') {
1003
+	print ' selected';
1004
+}
1005
+?>>Marine</option>
1006
+					    <option value="tracker"<?php if ($type == 'tracker') {
1007
+	print ' selected';
1008
+}
1009
+?>>Tracker</option>
1010
+					    <option value="satellite"<?php if ($type == 'Satellite') {
1011
+	print ' selected';
1012
+}
1013
+?>>Satellite</option>
765 1014
 					</select>
766 1015
 				    </td>
767 1016
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -845,7 +1094,10 @@  discard block
 block discarded – undo
845 1094
 			</p>
846 1095
 			<p>
847 1096
 				<label for="corsproxy">CORS proxy</label>
848
-				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
1097
+				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) {
1098
+	print $globalCORSproxy;
1099
+} else {
1100
+	print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
849 1101
 				<p class="help-block">CORS proxy used for some WMS servers</p>
850 1102
 			</p>
851 1103
 <!--
@@ -908,13 +1160,18 @@  discard block
 block discarded – undo
908 1160
 			<div id="schedules_options">
909 1161
 				<p>
910 1162
 					<label for="britishairways">British Airways API Key</label>
911
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1163
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey;
1164
+}
1165
+?>" />
912 1166
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
913 1167
 				</p>
914 1168
 				<!--
915 1169
 				<p>
916 1170
 					<label for="transavia">Transavia Test API Consumer Key</label>
917
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1171
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1172
+	print $globalTransaviaKey;
1173
+}
1174
+?>" />
918 1175
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
919 1176
 				</p>
920 1177
 				-->
@@ -923,10 +1180,16 @@  discard block
 block discarded – undo
923 1180
 						<b>Lufthansa API Key</b>
924 1181
 						<p>
925 1182
 							<label for="lufthansakey">Key</label>
926
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1183
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1184
+	print $globalLufthansaKey['key'];
1185
+}
1186
+?>" />
927 1187
 						</p><p>
928 1188
 							<label for="lufthansasecret">Secret</label>
929
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1189
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1190
+	print $globalLufthansaKey['secret'];
1191
+}
1192
+?>" />
930 1193
 						</p>
931 1194
 					</div>
932 1195
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -936,11 +1199,17 @@  discard block
 block discarded – undo
936 1199
 						<b>FlightAware API Key</b>
937 1200
 						<p>
938 1201
 							<label for="flightawareusername">Username</label>
939
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1202
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1203
+	print $globalFlightAwareUsername;
1204
+}
1205
+?>" />
940 1206
 						</p>
941 1207
 						<p>
942 1208
 							<label for="flightawarepassword">API key</label>
943
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1209
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1210
+	print $globalFlightAwarePassword;
1211
+}
1212
+?>" />
944 1213
 						</p>
945 1214
 					</div>
946 1215
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -957,10 +1226,22 @@  discard block
 block discarded – undo
957 1226
 				<p>
958 1227
 					<label for="mapmatchingsource">Map Matching source</label>
959 1228
 					<select name="mapmatchingsource" id="mapmatchingsource">
960
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
961
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
962
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
963
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1229
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1230
+	print 'selected="selected" ';
1231
+}
1232
+?>>FlightAirMap Map Matching</option>
1233
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1234
+	print 'selected="selected" ';
1235
+}
1236
+?>>GraphHopper</option>
1237
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1238
+	print 'selected="selected" ';
1239
+}
1240
+?>>OSMR</option>
1241
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1242
+	print 'selected="selected" ';
1243
+}
1244
+?>>Mapbox</option>
964 1245
 					</select>
965 1246
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
966 1247
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -968,7 +1249,10 @@  discard block
 block discarded – undo
968 1249
 				<br />
969 1250
 				<p>
970 1251
 					<label for="graphhopper">GraphHopper API Key</label>
971
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1252
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1253
+	print $globalGraphHopperKey;
1254
+}
1255
+?>" />
972 1256
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
973 1257
 				</p>
974 1258
 			</div>
@@ -986,7 +1270,10 @@  discard block
 block discarded – undo
986 1270
 			</p>
987 1271
 			<p>
988 1272
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
989
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1273
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1274
+	print $globalNOTAMSource;
1275
+}
1276
+?>" />
990 1277
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
991 1278
 			</p>
992 1279
 			<br />
@@ -1002,14 +1289,20 @@  discard block
 block discarded – undo
1002 1289
 			<div id="metarsrc">
1003 1290
 				<p>
1004 1291
 					<label for="metarsource">URL of your METAR source</label>
1005
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1292
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1293
+	print $globalMETARurl;
1294
+}
1295
+?>" />
1006 1296
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
1007 1297
 				</p>
1008 1298
 			</div>
1009 1299
 			<br />
1010 1300
 			<p>
1011 1301
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
1012
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1302
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1303
+	print $globalBitlyAccessToken;
1304
+}
1305
+?>" />
1013 1306
 			</p>
1014 1307
 			<br />
1015 1308
 			<p>
@@ -1025,11 +1318,26 @@  discard block
 block discarded – undo
1025 1318
 			<p>
1026 1319
 				<label for="geoid_source">Geoid Source</label>
1027 1320
 				<select name="geoid_source" id="geoid_source">
1028
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
1029
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
1030
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
1031
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
1032
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1321
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1322
+	print ' selected="selected"';
1323
+}
1324
+?>>EGM96 15' (2.1MB)</option>
1325
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1326
+	print ' selected="selected"';
1327
+}
1328
+?>>EGM96 5' (19MB)</option>
1329
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1330
+	print ' selected="selected"';
1331
+}
1332
+?>>EGM2008 5' (19MB)</option>
1333
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1334
+	print ' selected="selected"';
1335
+}
1336
+?>>EGM2008 2.5' (75MB)</option>
1337
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1338
+	print ' selected="selected"';
1339
+}
1340
+?>>EGM2008 1' (470MB)</option>
1033 1341
 				</select>
1034 1342
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
1035 1343
 			</p>
@@ -1051,7 +1359,12 @@  discard block
 block discarded – undo
1051 1359
 			</p>
1052 1360
 			<p>
1053 1361
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
1054
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1362
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1363
+	print $globalArchiveMonths;
1364
+} else {
1365
+	echo '1';
1366
+}
1367
+?>" />
1055 1368
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
1056 1369
 			</p>
1057 1370
 			<p>
@@ -1061,12 +1374,22 @@  discard block
 block discarded – undo
1061 1374
 			</p>
1062 1375
 			<p>
1063 1376
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
1064
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1377
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1378
+	print $globalArchiveKeepMonths;
1379
+} else {
1380
+	echo '1';
1381
+}
1382
+?>" />
1065 1383
 				<p class="help-block">0 to disable</p>
1066 1384
 			</p>
1067 1385
 			<p>
1068 1386
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
1069
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1387
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1388
+	print $globalArchiveKeepTrackMonths;
1389
+} else {
1390
+	echo '1';
1391
+}
1392
+?>" />
1070 1393
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
1071 1394
 			</p>
1072 1395
 			<br />
@@ -1076,7 +1399,12 @@  discard block
 block discarded – undo
1076 1399
 				<p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p>
1077 1400
 				<div id="cronends"> 
1078 1401
 					<label for="cronend">Run script for xx seconds</label>
1079
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1402
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1403
+	print $globalCronEnd;
1404
+} else {
1405
+	print '0';
1406
+}
1407
+?>" />
1080 1408
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
1081 1409
 				</div>
1082 1410
 			</p>
@@ -1135,20 +1463,40 @@  discard block
 block discarded – undo
1135 1463
 			<br />
1136 1464
 			<p>
1137 1465
 				<label for="refresh">Show flights detected since xxx seconds</label>
1138
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1466
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1467
+	echo $globalLiveInterval;
1468
+} else {
1469
+	echo '200';
1470
+}
1471
+?>" />
1139 1472
 			</p>
1140 1473
 			<p>
1141 1474
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1142
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1475
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1476
+	echo $globalMapRefresh;
1477
+} else {
1478
+	echo '30';
1479
+}
1480
+?>" />
1143 1481
 			</p>
1144 1482
 			<p>
1145 1483
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1146
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1484
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1485
+	echo $globalMapIdleTimeout;
1486
+} else {
1487
+	echo '30';
1488
+}
1489
+?>" />
1147 1490
 				<p class="help-block">0 to disable</p>
1148 1491
 			</p>
1149 1492
 			<p>
1150 1493
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1151
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1494
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1495
+	echo $globalMinFetch;
1496
+} else {
1497
+	echo '20';
1498
+}
1499
+?>" />
1152 1500
 			</p>
1153 1501
 			<p>
1154 1502
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1167,12 +1515,20 @@  discard block
 block discarded – undo
1167 1515
 			<br />
1168 1516
 			<p>
1169 1517
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1170
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1518
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1519
+	echo $globalClosestMinDist;
1520
+} else {
1521
+	echo '50';
1522
+}
1523
+?>" />
1171 1524
 			</p>
1172 1525
 			<br />
1173 1526
 			<p>
1174 1527
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1175
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1528
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1529
+	echo $globalAircraftSize;
1530
+}
1531
+?>" />
1176 1532
 			</p>
1177 1533
 			<br />
1178 1534
 			<p>
@@ -1191,22 +1547,42 @@  discard block
 block discarded – undo
1191 1547
 			<br />
1192 1548
 			<p>
1193 1549
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1194
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1550
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1551
+	echo $globalAircraftIconColor;
1552
+} else {
1553
+	echo '1a3151';
1554
+}
1555
+?>" />
1195 1556
 			</p>
1196 1557
 			<br />
1197 1558
 			<p>
1198 1559
 				<label for="marineiconcolor">Color of marine icon on map</label>
1199
-				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" />
1560
+				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) {
1561
+	echo $globalMarineIconColor;
1562
+} else {
1563
+	echo '43d1d8';
1564
+}
1565
+?>" />
1200 1566
 			</p>
1201 1567
 			<br />
1202 1568
 			<p>
1203 1569
 				<label for="trackericoncolor">Color of tracker icon on map</label>
1204
-				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" />
1570
+				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) {
1571
+	echo $globalTrackerIconColor;
1572
+} else {
1573
+	echo '1a3151';
1574
+}
1575
+?>" />
1205 1576
 			</p>
1206 1577
 			<br />
1207 1578
 			<p>
1208 1579
 				<label for="satelliteiconcolor">Color of satellite icon on map</label>
1209
-				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" />
1580
+				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) {
1581
+	echo $globalSatelliteIconColor;
1582
+} else {
1583
+	echo '1a3151';
1584
+}
1585
+?>" />
1210 1586
 			</p>
1211 1587
 			<?php
1212 1588
 				if (!is_writable('../cache')) {
@@ -1230,14 +1606,27 @@  discard block
 block discarded – undo
1230 1606
 			<p>
1231 1607
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1232 1608
 				<div class="range">
1233
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1234
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1609
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1610
+	echo $globalAirportZoom;
1611
+} else {
1612
+	echo '7';
1613
+}
1614
+?>" />
1615
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1616
+	echo $globalAirportZoom;
1617
+} else {
1618
+	echo '7';
1619
+}
1620
+?></output>
1235 1621
 				</div>
1236 1622
 			</p>
1237 1623
 			<br />
1238 1624
 			<p>
1239 1625
 				<label for="customcss">Custom CSS web path</label>
1240
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1626
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1627
+	echo $globalCustomCSS;
1628
+}
1629
+?>" />
1241 1630
 			</p>
1242 1631
 		</fieldset>
1243 1632
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1267,8 +1656,12 @@  discard block
 block discarded – undo
1267 1656
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1268 1657
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1269 1658
 
1270
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1271
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1659
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1660
+		$error .= 'Mysql driver for PDO must be loaded';
1661
+	}
1662
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1663
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1664
+	}
1272 1665
 	
1273 1666
 	$_SESSION['database_root'] = $dbroot;
1274 1667
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1346,15 +1739,23 @@  discard block
 block discarded – undo
1346 1739
 	$source_city = $_POST['source_city'];
1347 1740
 	$source_country = $_POST['source_country'];
1348 1741
 	$source_ref = $_POST['source_ref'];
1349
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1350
-	else $source_id = array();
1742
+	if (isset($source_id)) {
1743
+		$source_id = $_POST['source_id'];
1744
+	} else {
1745
+		$source_id = array();
1746
+	}
1351 1747
 	
1352 1748
 	$sources = array();
1353 1749
 	foreach ($source_name as $keys => $name) {
1354
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1355
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1750
+	    if (isset($source_id[$keys])) {
1751
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1752
+	    } else {
1753
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1754
+	    }
1755
+	}
1756
+	if (count($sources) > 0) {
1757
+		$_SESSION['sources'] = $sources;
1356 1758
 	}
1357
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1358 1759
 
1359 1760
 	$newsurl = $_POST['newsurl'];
1360 1761
 	$newslng = $_POST['newslang'];
@@ -1367,7 +1768,9 @@  discard block
 block discarded – undo
1367 1768
 		$lng = $newslng[$newskey];
1368 1769
 		if (isset($newsfeeds[$type][$lng])) {
1369 1770
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1370
-		} else $newsfeeds[$type][$lng] = array($url);
1771
+		} else {
1772
+			$newsfeeds[$type][$lng] = array($url);
1773
+		}
1371 1774
 	    }
1372 1775
 	}
1373 1776
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1392,17 +1795,29 @@  discard block
 block discarded – undo
1392 1795
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1393 1796
 
1394 1797
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1395
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1396
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1798
+	if ($globalaircraft == 'aircraft') {
1799
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1800
+	} else {
1801
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1802
+	}
1397 1803
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1398
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1399
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1804
+	if ($globaltracker == 'tracker') {
1805
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1806
+	} else {
1807
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1808
+	}
1400 1809
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1401
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1402
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1810
+	if ($globalmarine == 'marine') {
1811
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1812
+	} else {
1813
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1814
+	}
1403 1815
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1404
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1405
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1816
+	if ($globalsatellite == 'satellite') {
1817
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1818
+	} else {
1819
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1820
+	}
1406 1821
 
1407 1822
 /*	
1408 1823
 	$globalSBS1Hosts = array();
@@ -1424,23 +1839,37 @@  discard block
 block discarded – undo
1424 1839
 	$name = $_POST['name'];
1425 1840
 	$format = $_POST['format'];
1426 1841
 	$timezones = $_POST['timezones'];
1427
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1428
-	else $sourcestats = array();
1429
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1430
-	else $noarchive = array();
1842
+	if (isset($_POST['sourcestats'])) {
1843
+		$sourcestats = $_POST['sourcestats'];
1844
+	} else {
1845
+		$sourcestats = array();
1846
+	}
1847
+	if (isset($_POST['noarchive'])) {
1848
+		$noarchive = $_POST['noarchive'];
1849
+	} else {
1850
+		$noarchive = array();
1851
+	}
1431 1852
 	$gSources = array();
1432 1853
 	$forcepilots = false;
1433 1854
 	foreach ($host as $key => $h) {
1434
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1435
-		else $cov = 'FALSE';
1436
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1437
-		else $arch = 'FALSE';
1855
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1856
+			$cov = 'TRUE';
1857
+		} else {
1858
+			$cov = 'FALSE';
1859
+		}
1860
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1861
+			$arch = 'TRUE';
1862
+		} else {
1863
+			$arch = 'FALSE';
1864
+		}
1438 1865
 		if (strpos($format[$key],'_callback')) {
1439 1866
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1440 1867
 		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1441 1868
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1442 1869
 		}
1443
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1870
+		if ($format[$key] == 'airwhere') {
1871
+			$forcepilots = true;
1872
+		}
1444 1873
 	}
1445 1874
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1446 1875
 
@@ -1471,7 +1900,9 @@  discard block
 block discarded – undo
1471 1900
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1472 1901
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1473 1902
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1474
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1903
+	} else {
1904
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1905
+	}
1475 1906
 
1476 1907
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1477 1908
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1512,7 +1943,9 @@  discard block
 block discarded – undo
1512 1943
 
1513 1944
 	// Create in settings.php keys not yet configurable if not already here
1514 1945
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1515
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1946
+	if (!isset($globalDebug)) {
1947
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1948
+	}
1516 1949
 
1517 1950
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1518 1951
 	if ($resetyearstats == 'resetyearstats') {
@@ -1555,37 +1988,56 @@  discard block
 block discarded – undo
1555 1988
 	}
1556 1989
 */
1557 1990
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1558
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1559
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1560
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1561
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1991
+	if ($globalsbs == 'sbs') {
1992
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1993
+	} else {
1994
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1995
+	}
1996
+	if ($globalaprs == 'aprs') {
1997
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1998
+	} else {
1999
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
2000
+	}
1562 2001
 	$va = false;
1563 2002
 	if ($globalivao == 'ivao') {
1564 2003
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1565 2004
 		$va = true;
1566
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2005
+	} else {
2006
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2007
+	}
1567 2008
 	if ($globalvatsim == 'vatsim') {
1568 2009
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1569 2010
 		$va = true;
1570
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2011
+	} else {
2012
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2013
+	}
1571 2014
 	if ($globalphpvms == 'phpvms') {
1572 2015
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1573 2016
 		$va = true;
1574
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2017
+	} else {
2018
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2019
+	}
1575 2020
 	if ($globalvam == 'vam') {
1576 2021
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1577 2022
 		$va = true;
1578
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2023
+	} else {
2024
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2025
+	}
1579 2026
 	if ($va) {
1580 2027
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1581
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2028
+	} else {
2029
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2030
+	}
1582 2031
 	if ($globalva == 'va' || $va) {
1583 2032
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1584 2033
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1585 2034
 	} else {
1586 2035
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1587
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1588
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2036
+		if ($forcepilots) {
2037
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
2038
+		} else {
2039
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2040
+		}
1589 2041
 	}
1590 2042
 	if ($globalvm == 'vm') {
1591 2043
 		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
@@ -1845,7 +2297,9 @@  discard block
 block discarded – undo
1845 2297
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1846 2298
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1847 2299
 
1848
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2300
+	if (!isset($globalTransaction)) {
2301
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2302
+	}
1849 2303
 
1850 2304
 	// Set some defaults values...
1851 2305
 	if (!isset($globalAircraftImageSources)) {
@@ -1860,15 +2314,23 @@  discard block
 block discarded – undo
1860 2314
 
1861 2315
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1862 2316
 
1863
-	if ($error == '') settings::modify_settings($settings);
1864
-	if ($error == '') settings::comment_settings($settings_comment);
2317
+	if ($error == '') {
2318
+		settings::modify_settings($settings);
2319
+	}
2320
+	if ($error == '') {
2321
+		settings::comment_settings($settings_comment);
2322
+	}
1865 2323
 	if ($error != '') {
1866 2324
 		print '<div class="info column">'.$error.'</div>';
1867 2325
 		require('../footer.php');
1868 2326
 		exit;
1869 2327
 	} else {
1870
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1871
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2328
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2329
+			$_SESSION['waypoints'] = 1;
2330
+		}
2331
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2332
+			$_SESSION['owner'] = 1;
2333
+		}
1872 2334
 		if (isset($_POST['createdb'])) {
1873 2335
 			$_SESSION['install'] = 'database_create';
1874 2336
 		} else {
@@ -1905,10 +2367,18 @@  discard block
 block discarded – undo
1905 2367
 	$popw = false;
1906 2368
 	foreach ($_SESSION['done'] as $done) {
1907 2369
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1908
-	    if ($done == 'Create database') $pop = true;
1909
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1910
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1911
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2370
+	    if ($done == 'Create database') {
2371
+	    	$pop = true;
2372
+	    }
2373
+	    if ($_SESSION['install'] == 'database_create') {
2374
+	    	$pop = true;
2375
+	    }
2376
+	    if ($_SESSION['install'] == 'database_import') {
2377
+	    	$popi = true;
2378
+	    }
2379
+	    if ($_SESSION['install'] == 'waypoints') {
2380
+	    	$popw = true;
2381
+	    }
1912 2382
 	}
1913 2383
 	if ($pop) {
1914 2384
 	    sleep(5);
@@ -1919,7 +2389,9 @@  discard block
 block discarded – undo
1919 2389
 	} else if ($popw) {
1920 2390
 	    sleep(5);
1921 2391
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1922
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2392
+	} else {
2393
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2394
+	}
1923 2395
 	print '</div></ul>';
1924 2396
 	print '<div id="error"></div>';
1925 2397
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
require/class.ACARS.php 3 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	/**
35
-	* Change IATA to ICAO value for ident
36
-	*
37
-	* @param String $ident ident
38
-	* @return String the icao
39
-	*/
35
+	 * Change IATA to ICAO value for ident
36
+	 *
37
+	 * @param String $ident ident
38
+	 * @return String the icao
39
+	 */
40 40
 	public function ident2icao($ident) {
41 41
 		if (substr($ident,0,2) == 'AF') {
42 42
 			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	/**
55
-	* Deletes all info in the live table
56
-	*
57
-	* @return String success or false
58
-	*
59
-	*/
55
+	 * Deletes all info in the live table
56
+	 *
57
+	 * @return String success or false
58
+	 *
59
+	 */
60 60
 	public function deleteLiveAcarsData()
61 61
 	{
62 62
 		global $globalDBdriver;
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	}
77 77
 
78 78
 	/**
79
-	* Deletes all info in the archive table
80
-	*
81
-	* @return String success or false
82
-	*
83
-	*/
79
+	 * Deletes all info in the archive table
80
+	 *
81
+	 * @return String success or false
82
+	 *
83
+	 */
84 84
 	public function deleteArchiveAcarsData()
85 85
 	{
86 86
 		global $globalACARSArchiveKeepMonths, $globalDBdriver;
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 
103
-    /**
104
-     * Parse ACARS data
105
-     *
106
-     * @param String ACARS data in acarsdec data
107
-     *
108
-     * @return array
109
-     */
103
+	/**
104
+	 * Parse ACARS data
105
+	 *
106
+	 * @param String ACARS data in acarsdec data
107
+	 *
108
+	 * @return array
109
+	 */
110 110
 	public function parse($data) {
111 111
 		global $globalDebug;
112 112
 		//$Image = new Image($this->db);
@@ -736,11 +736,11 @@  discard block
 block discarded – undo
736 736
 	}
737 737
 
738 738
 	/**
739
-	* Add ACARS data
740
-	*
741
-	* @param String ACARS data in acarsdec data
742
-	*
743
-	*/
739
+	 * Add ACARS data
740
+	 *
741
+	 * @param String ACARS data in acarsdec data
742
+	 *
743
+	 */
744 744
 	public function add($data,$message = array()) {
745 745
 		global $globalDebug, $globalACARSArchive;
746 746
 		$Image = new Image($this->db);
@@ -787,18 +787,18 @@  discard block
 block discarded – undo
787 787
 		}
788 788
 	}
789 789
 
790
-    /**
791
-     * Add Live ACARS data in DB
792
-     *
793
-     * @param String $ident ident
794
-     * @param String $registration Registration of the aircraft
795
-     * @param String $label Label of the ACARS message
796
-     * @param String $block_id Block id of the ACARS message
797
-     * @param String $msg_no Number of the ACARS message
798
-     * @param String $message ACARS message
799
-     * @param string $decode
800
-     * @return bool
801
-     */
790
+	/**
791
+	 * Add Live ACARS data in DB
792
+	 *
793
+	 * @param String $ident ident
794
+	 * @param String $registration Registration of the aircraft
795
+	 * @param String $label Label of the ACARS message
796
+	 * @param String $block_id Block id of the ACARS message
797
+	 * @param String $msg_no Number of the ACARS message
798
+	 * @param String $message ACARS message
799
+	 * @param string $decode
800
+	 * @return bool
801
+	 */
802 802
 	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
803 803
 		global $globalDebug;
804 804
 		date_default_timezone_set('UTC');
@@ -836,18 +836,18 @@  discard block
 block discarded – undo
836 836
 		return false;
837 837
 	}
838 838
 
839
-    /**
840
-     * Add Archive ACARS data in DB
841
-     *
842
-     * @param String $ident ident
843
-     * @param String $registration Registration of the aircraft
844
-     * @param String $label Label of the ACARS message
845
-     * @param String $block_id Block id of the ACARS message
846
-     * @param String $msg_no Number of the ACARS message
847
-     * @param String $message ACARS message
848
-     * @param string $decode
849
-     * @return string
850
-     */
839
+	/**
840
+	 * Add Archive ACARS data in DB
841
+	 *
842
+	 * @param String $ident ident
843
+	 * @param String $registration Registration of the aircraft
844
+	 * @param String $label Label of the ACARS message
845
+	 * @param String $block_id Block id of the ACARS message
846
+	 * @param String $msg_no Number of the ACARS message
847
+	 * @param String $message ACARS message
848
+	 * @param string $decode
849
+	 * @return string
850
+	 */
851 851
 	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
852 852
 		global $globalDebug;
853 853
 		date_default_timezone_set('UTC');
@@ -879,11 +879,11 @@  discard block
 block discarded – undo
879 879
 	}
880 880
 
881 881
 	/**
882
-	* Get Message title from label from DB
883
-	*
884
-	* @param String $label
885
-	* @return String Return ACARS title
886
-	*/
882
+	 * Get Message title from label from DB
883
+	 *
884
+	 * @param String $label
885
+	 * @return String Return ACARS title
886
+	 */
887 887
 	public function getTitlefromLabel($label) {
888 888
 		$Connection = new Connection($this->db);
889 889
 		$this->db = $Connection->db;
@@ -902,10 +902,10 @@  discard block
 block discarded – undo
902 902
 	}
903 903
 
904 904
 	/**
905
-	* List all Message title & label from DB
906
-	*
907
-	* @return array Return ACARS data in array
908
-	*/
905
+	 * List all Message title & label from DB
906
+	 *
907
+	 * @return array Return ACARS data in array
908
+	 */
909 909
 	public function getAllTitleLabel() {
910 910
 		$query = "SELECT * FROM acars_label ORDER BY title";
911 911
 		$query_values = array();
@@ -922,11 +922,11 @@  discard block
 block discarded – undo
922 922
 	}
923 923
 
924 924
 	/**
925
-	* Get Live ACARS data from DB
926
-	*
927
-	* @param String $ident
928
-	* @return array Return ACARS data in array
929
-	*/
925
+	 * Get Live ACARS data from DB
926
+	 *
927
+	 * @param String $ident
928
+	 * @return array Return ACARS data in array
929
+	 */
930 930
 	public function getLiveAcarsData($ident) {
931 931
 		$query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC";
932 932
 		$query_values = array(':ident' => $ident);
@@ -942,13 +942,13 @@  discard block
 block discarded – undo
942 942
 		else return array();
943 943
 	}
944 944
 
945
-    /**
946
-     * Get Latest ACARS data from DB
947
-     *
948
-     * @param string $limit
949
-     * @param string $label
950
-     * @return array Return ACARS data in array
951
-     */
945
+	/**
946
+	 * Get Latest ACARS data from DB
947
+	 *
948
+	 * @param string $limit
949
+	 * @param string $label
950
+	 * @return array Return ACARS data in array
951
+	 */
952 952
 	public function getLatestAcarsData($limit = '',$label = '') {
953 953
 		global $globalURL;
954 954
 		$Image = new Image($this->db);
@@ -1036,13 +1036,13 @@  discard block
 block discarded – undo
1036 1036
 		else return array();
1037 1037
 	}
1038 1038
 
1039
-    /**
1040
-     * Get Archive ACARS data from DB
1041
-     *
1042
-     * @param string $limit
1043
-     * @param string $label
1044
-     * @return array Return ACARS data in array
1045
-     */
1039
+	/**
1040
+	 * Get Archive ACARS data from DB
1041
+	 *
1042
+	 * @param string $limit
1043
+	 * @param string $label
1044
+	 * @return array Return ACARS data in array
1045
+	 */
1046 1046
 	public function getArchiveAcarsData($limit = '',$label = '') {
1047 1047
 		global $globalURL;
1048 1048
 		$Image = new Image($this->db);
@@ -1131,17 +1131,17 @@  discard block
 block discarded – undo
1131 1131
 		} else return array();
1132 1132
 	}
1133 1133
 
1134
-    /**
1135
-     * Add ModeS data to DB
1136
-     *
1137
-     * @param String $ident ident
1138
-     * @param String $registration Registration of the aircraft
1139
-     * @param String $icao
1140
-     * @param String $ICAOTypeCode
1141
-     * @param string $latitude
1142
-     * @param string $longitude
1143
-     * @return string
1144
-     */
1134
+	/**
1135
+	 * Add ModeS data to DB
1136
+	 *
1137
+	 * @param String $ident ident
1138
+	 * @param String $registration Registration of the aircraft
1139
+	 * @param String $icao
1140
+	 * @param String $ICAOTypeCode
1141
+	 * @param string $latitude
1142
+	 * @param string $longitude
1143
+	 * @return string
1144
+	 */
1145 1145
 	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1146 1146
 		global $globalDebug, $globalDBdriver;
1147 1147
 		$ident = trim($ident);
Please login to merge, or discard this patch.
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	/*
22 22
 	 * Initialize DB connection
23 23
 	*/
24
-	public function __construct($dbc = null,$fromACARSscript = false) {
24
+	public function __construct($dbc = null, $fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27 27
 		if ($this->db === null) die('Error: No DB connection. (ACARS)');
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 	* @return String the icao
39 39
 	*/
40 40
 	public function ident2icao($ident) {
41
-		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
41
+		if (substr($ident, 0, 2) == 'AF') {
42
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
44 44
 		} else {
45 45
 			$Spotter = new Spotter($this->db);
46
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
46
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
47 47
 			if (isset($identicao[0])) {
48
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
48
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
49 49
 			} else $icao = $ident;
50 50
 		}
51 51
 		return $icao;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 			$sth = $this->db->prepare($query);
71 71
 			$sth->execute();
72
-		} catch(PDOException $e) {
72
+		} catch (PDOException $e) {
73 73
 			return "error";
74 74
 		}
75 75
 		return "success";
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 			$sth = $this->db->prepare($query);
95 95
 			$sth->execute();
96
-		} catch(PDOException $e) {
96
+		} catch (PDOException $e) {
97 97
 			return "error";
98 98
 		}
99 99
 		return "success";
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 		$ident = '';
120 120
 		$message = '';
121 121
 		$result = array();
122
-		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
125
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
122
+		$n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
123
+		if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
124
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
125
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
126 126
 		if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) {
127
-			$registration = str_replace('.','',$registration);
128
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
127
+			$registration = str_replace('.', '', $registration);
128
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
129 129
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
130 130
 		} else $message = $data;
131 131
 		$decode = array();
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 				$temp = '';
146 146
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
147 147
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
148
-					$latitude = $la / 10000.0;
149
-					$longitude = $ln / 10000.0;
148
+					$latitude = $la/10000.0;
149
+					$longitude = $ln/10000.0;
150 150
 					if ($lac == 'S') $latitude = '-'.$latitude;
151 151
 					if ($lnc == 'W') $longitude = '-'.$longitude;
152 152
 					// Temp not always available
153 153
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
154
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
155
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
154
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
155
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
156 156
 
157 157
 					//$icao = $Translation->checkTranslation($ident);
158 158
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 				$dhour = '';
165 165
 				$darr = '';
166 166
 				$ahour = '';
167
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
167
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
168 168
 				if ($n == 4 && strlen($darr) == 4) {
169
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
170
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
171
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
169
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
170
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
171
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
172 172
 					//$icao = ACARS->ident2icao($ident);
173 173
 					//$icao = $Translation->checkTranslation($ident);
174 174
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
175 175
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
176 176
 					$found = true;
177 177
 				}
178
-				elseif ($n == 2 || $n  == 4) {
179
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
178
+				elseif ($n == 2 || $n == 4) {
179
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
180 180
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
181 181
 					//$icao = ACARS->ident2icao($ident);
182 182
 					//$icao = $Translation->checkTranslation($ident);
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 				$ahour = '';
235 235
 				$aair = '';
236 236
 				$apiste = '';
237
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
237
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
238 238
 				if ($n > 8) {
239
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
240
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
241
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
239
+					if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
240
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
241
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
242 242
 					$icao = trim($aident);
243 243
 
244 244
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
264 264
 					$las = $las.'.'.$lass;
265 265
 					$lns = $lns.'.'.$lns;
266
-					$latitude = $las / 1000.0;
267
-					$longitude = $lns / 1000.0;
266
+					$latitude = $las/1000.0;
267
+					$longitude = $lns/1000.0;
268 268
 					if ($lac == 'S') $latitude = '-'.$latitude;
269 269
 					if ($lnc == 'W') $longitude = '-'.$longitude;
270 270
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
 				$alt = '';
360 360
 				$fuel = '';
361 361
 				$speed = '';
362
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
362
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
363 363
 				if ($n == 9) {
364 364
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
365 365
 					$icao = trim($aident);
366 366
 					$decode['icao'] = $icao;
367
-					$latitude = $las / 100.0;
368
-					$longitude = $lns / 100.0;
367
+					$latitude = $las/100.0;
368
+					$longitude = $lns/100.0;
369 369
 					if ($lac == 'S') $latitude = '-'.$latitude;
370 370
 					if ($lnc == 'W') $longitude = '-'.$longitude;
371 371
 
372
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
372
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
373 373
 					$found = true;
374 374
 				}
375 375
 			}
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 					if ($lac == 'S') $latitude = '-'.$latitude;
389 389
 					if ($lnc == 'W') $longitude = '-'.$longitude;
390 390
 
391
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
391
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
392 392
 					$found = true;
393 393
 				}
394 394
 			}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 				$dair = '';
422 422
 				$darr = '';
423 423
 				$aident = '';
424
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
424
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
425 425
 				if ($n == 8) {
426 426
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
427 427
 					$icao = trim($aident);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				*/
454 454
 				$dair = '';
455 455
 				$darr = '';
456
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
456
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
457 457
 				if ($n == 3) {
458 458
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459 459
 					//$icao = $Translation->checkTranslation($ident);
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 				*/
469 469
 				$dair = '';
470 470
 				$darr = '';
471
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
471
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
472 472
 				if ($n == 3) {
473 473
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
474 474
 					//$icao = $Translation->checkTranslation($ident);
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 				}
479 479
 			}
480 480
 			if (!$found) {
481
-				$n = sscanf($message,'MET01%4c',$airport);
481
+				$n = sscanf($message, 'MET01%4c', $airport);
482 482
 				if ($n == 1) {
483 483
 					if ($globalDebug) echo 'airport name : '.$airport;
484 484
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -486,241 +486,241 @@  discard block
 block discarded – undo
486 486
 				}
487 487
 			}
488 488
 			if ($label == 'H1') {
489
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
490
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
489
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
490
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
491 491
 				}
492
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
493
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
492
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
493
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
494 494
 				}
495
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
496
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
495
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
496
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
497 497
 				}
498
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
499
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
498
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
499
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
500 500
 				}
501
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
502
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
501
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
502
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
503 503
 				}
504
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
505
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
504
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
505
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
506 506
 				}
507
-				elseif (preg_match(':^#M1AAEP:',$message)) {
508
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
507
+				elseif (preg_match(':^#M1AAEP:', $message)) {
508
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
509 509
 				}
510
-				elseif (preg_match(':^#M2APWD:',$message)) {
511
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
510
+				elseif (preg_match(':^#M2APWD:', $message)) {
511
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
512 512
 				}
513
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
514
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
513
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
514
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
515 515
 				}
516
-				elseif (preg_match(':^#CF:',$message)) {
517
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
516
+				elseif (preg_match(':^#CF:', $message)) {
517
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
518 518
 				}
519
-				elseif (preg_match(':^#DF:',$message)) {
520
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
519
+				elseif (preg_match(':^#DF:', $message)) {
520
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
521 521
 				}
522
-				elseif (preg_match(':^#EC:',$message)) {
523
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
522
+				elseif (preg_match(':^#EC:', $message)) {
523
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
524 524
 				}
525
-				elseif (preg_match(':^#EI:',$message)) {
526
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
525
+				elseif (preg_match(':^#EI:', $message)) {
526
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
527 527
 				}
528
-				elseif (preg_match(':^#H1:',$message)) {
529
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
528
+				elseif (preg_match(':^#H1:', $message)) {
529
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
530 530
 				}
531
-				elseif (preg_match(':^#H2:',$message)) {
532
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
531
+				elseif (preg_match(':^#H2:', $message)) {
532
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
533 533
 				}
534
-				elseif (preg_match(':^#HD:',$message)) {
535
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
534
+				elseif (preg_match(':^#HD:', $message)) {
535
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
536 536
 				}
537
-				elseif (preg_match(':^#M1:',$message)) {
538
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
537
+				elseif (preg_match(':^#M1:', $message)) {
538
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
539 539
 				}
540
-				elseif (preg_match(':^#M2:',$message)) {
541
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
540
+				elseif (preg_match(':^#M2:', $message)) {
541
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
542 542
 				}
543
-				elseif (preg_match(':^#M3:',$message)) {
544
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
543
+				elseif (preg_match(':^#M3:', $message)) {
544
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
545 545
 				}
546
-				elseif (preg_match(':^#MD:',$message)) {
547
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
546
+				elseif (preg_match(':^#MD:', $message)) {
547
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
548 548
 				}
549
-				elseif (preg_match(':^#PS:',$message)) {
550
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
549
+				elseif (preg_match(':^#PS:', $message)) {
550
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
551 551
 				}
552
-				elseif (preg_match(':^#S1:',$message)) {
553
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
552
+				elseif (preg_match(':^#S1:', $message)) {
553
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
554 554
 				}
555
-				elseif (preg_match(':^#S2:',$message)) {
556
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
555
+				elseif (preg_match(':^#S2:', $message)) {
556
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
557 557
 				}
558
-				elseif (preg_match(':^#SD:',$message)) {
559
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
558
+				elseif (preg_match(':^#SD:', $message)) {
559
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
560 560
 				}
561
-				elseif (preg_match(':^#T[0-8]:',$message)) {
562
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
561
+				elseif (preg_match(':^#T[0-8]:', $message)) {
562
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
563 563
 				}
564
-				elseif (preg_match(':^#WO:',$message)) {
565
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
564
+				elseif (preg_match(':^#WO:', $message)) {
565
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
566 566
 				}
567
-				elseif (preg_match(':^#A1:',$message)) {
568
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
567
+				elseif (preg_match(':^#A1:', $message)) {
568
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
569 569
 				}
570
-				elseif (preg_match(':^#A3:',$message)) {
571
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
570
+				elseif (preg_match(':^#A3:', $message)) {
571
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
572 572
 				}
573
-				elseif (preg_match(':^#A4:',$message)) {
574
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
573
+				elseif (preg_match(':^#A4:', $message)) {
574
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
575 575
 				}
576
-				elseif (preg_match(':^#A6:',$message)) {
577
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
576
+				elseif (preg_match(':^#A6:', $message)) {
577
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
578 578
 				}
579
-				elseif (preg_match(':^#A8:',$message)) {
580
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
579
+				elseif (preg_match(':^#A8:', $message)) {
580
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
581 581
 				}
582
-				elseif (preg_match(':^#A9:',$message)) {
583
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
582
+				elseif (preg_match(':^#A9:', $message)) {
583
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
584 584
 				}
585
-				elseif (preg_match(':^#A0:',$message)) {
586
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
585
+				elseif (preg_match(':^#A0:', $message)) {
586
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
587 587
 				}
588
-				elseif (preg_match(':^#AA:',$message)) {
589
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
588
+				elseif (preg_match(':^#AA:', $message)) {
589
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
590 590
 				}
591
-				elseif (preg_match(':^#AB:',$message)) {
592
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
591
+				elseif (preg_match(':^#AB:', $message)) {
592
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
593 593
 				}
594
-				elseif (preg_match(':^#AC:',$message)) {
595
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
594
+				elseif (preg_match(':^#AC:', $message)) {
595
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
596 596
 				}
597
-				elseif (preg_match(':^#AD:',$message)) {
598
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
597
+				elseif (preg_match(':^#AD:', $message)) {
598
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
599 599
 				}
600
-				elseif (preg_match(':^#AF:',$message)) {
601
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
600
+				elseif (preg_match(':^#AF:', $message)) {
601
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
602 602
 				}
603
-				elseif (preg_match(':^#B1:',$message)) {
604
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
603
+				elseif (preg_match(':^#B1:', $message)) {
604
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
605 605
 				}
606
-				elseif (preg_match(':^#B2:',$message)) {
607
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
606
+				elseif (preg_match(':^#B2:', $message)) {
607
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
608 608
 				}
609
-				elseif (preg_match(':^#B3:',$message)) {
610
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
609
+				elseif (preg_match(':^#B3:', $message)) {
610
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
611 611
 				}
612
-				elseif (preg_match(':^#B4:',$message)) {
613
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
612
+				elseif (preg_match(':^#B4:', $message)) {
613
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
614 614
 				}
615
-				elseif (preg_match(':^#B6:',$message)) {
616
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
615
+				elseif (preg_match(':^#B6:', $message)) {
616
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
617 617
 				}
618
-				elseif (preg_match(':^#B8:',$message)) {
619
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
618
+				elseif (preg_match(':^#B8:', $message)) {
619
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
620 620
 				}
621
-				elseif (preg_match(':^#B9:',$message)) {
622
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
621
+				elseif (preg_match(':^#B9:', $message)) {
622
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
623 623
 				}
624
-				elseif (preg_match(':^#B0:',$message)) {
625
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
624
+				elseif (preg_match(':^#B0:', $message)) {
625
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
626 626
 				}
627
-				elseif (preg_match(':^#BA:',$message)) {
628
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
627
+				elseif (preg_match(':^#BA:', $message)) {
628
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
629 629
 				}
630
-				elseif (preg_match(':^#BB:',$message)) {
631
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
630
+				elseif (preg_match(':^#BB:', $message)) {
631
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
632 632
 				}
633
-				elseif (preg_match(':^#BC:',$message)) {
634
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
633
+				elseif (preg_match(':^#BC:', $message)) {
634
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
635 635
 				}
636
-				elseif (preg_match(':^#BD:',$message)) {
637
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
636
+				elseif (preg_match(':^#BD:', $message)) {
637
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
638 638
 				}
639
-				elseif (preg_match(':^#BE:',$message)) {
640
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
639
+				elseif (preg_match(':^#BE:', $message)) {
640
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
641 641
 				}
642
-				elseif (preg_match(':^#BF:',$message)) {
643
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
642
+				elseif (preg_match(':^#BF:', $message)) {
643
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
644 644
 				}
645
-				elseif (preg_match(':^#H3:',$message)) {
646
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
645
+				elseif (preg_match(':^#H3:', $message)) {
646
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
647 647
 				}
648 648
 			}
649 649
 			if ($label == '10') {
650
-				if (preg_match(':^DTO01:',$message)) {
651
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
650
+				if (preg_match(':^DTO01:', $message)) {
651
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
652 652
 				}
653
-				elseif (preg_match(':^AIS01:',$message)) {
654
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
653
+				elseif (preg_match(':^AIS01:', $message)) {
654
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
655 655
 				}
656
-				elseif (preg_match(':^FTX01:',$message)) {
657
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
656
+				elseif (preg_match(':^FTX01:', $message)) {
657
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
658 658
 				}
659
-				elseif (preg_match(':^FPL01:',$message)) {
660
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
659
+				elseif (preg_match(':^FPL01:', $message)) {
660
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
661 661
 				}
662
-				elseif (preg_match(':^WAB01:',$message)) {
663
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
662
+				elseif (preg_match(':^WAB01:', $message)) {
663
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
664 664
 				}
665
-				elseif (preg_match(':^MET01:',$message)) {
666
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
665
+				elseif (preg_match(':^MET01:', $message)) {
666
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
667 667
 				}
668
-				elseif (preg_match(':^WAB02:',$message)) {
669
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
668
+				elseif (preg_match(':^WAB02:', $message)) {
669
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
670 670
 				}
671 671
 			}
672 672
 			if ($label == '15') {
673
-				if (preg_match(':^FST01:',$message)) {
674
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
673
+				if (preg_match(':^FST01:', $message)) {
674
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
675 675
 				}
676 676
 			}
677 677
 			if (!$found && $label == 'SA') {
678
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
678
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
679 679
 				if ($n == 4) {
680 680
 					$vsta = array('Version' => $version);
681 681
 					if ($state == 'E') {
682
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
682
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
683 683
 					}
684 684
 					elseif ($state == 'L') {
685
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
685
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
686 686
 					}
687 687
 					else {
688
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
688
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
689 689
 					}
690 690
 					if ($type == 'V') {
691
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
691
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
692 692
 					}
693 693
 					elseif ($type == 'S') {
694
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
694
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
695 695
 					}
696 696
 					elseif ($type == 'H') {
697
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
697
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
698 698
 					}
699 699
 					elseif ($type == 'G') {
700
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
700
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
701 701
 					}
702 702
 					elseif ($type == 'C') {
703
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
703
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
704 704
 					}
705 705
 					elseif ($type == '2') {
706
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
706
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
707 707
 					}
708 708
 					elseif ($type == 'X') {
709
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
709
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
710 710
 					}
711 711
 					elseif ($type == 'I') {
712
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
712
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
713 713
 					}
714 714
 					else {
715
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
715
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
716 716
 					}
717
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
718
-					$decode = array_merge($vsta,$decode);
717
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
718
+					$decode = array_merge($vsta, $decode);
719 719
 				}
720 720
 			}
721 721
 
722 722
 			$title = $this->getTitlefromLabel($label);
723
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
723
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
724 724
 			/*
725 725
 			// Business jets always use GS0001
726 726
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -741,21 +741,21 @@  discard block
 block discarded – undo
741 741
 	* @param String ACARS data in acarsdec data
742 742
 	*
743 743
 	*/
744
-	public function add($data,$message = array()) {
744
+	public function add($data, $message = array()) {
745 745
 		global $globalDebug, $globalACARSArchive;
746 746
 		$Image = new Image($this->db);
747 747
 		$Schedule = new Schedule($this->db);
748 748
 		$Translation = new Translation($this->db);
749 749
 
750
-		$message = array_merge($message,$this->parse($data));
750
+		$message = array_merge($message, $this->parse($data));
751 751
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
752
-			$ident = (string)$message['ident'];
752
+			$ident = (string) $message['ident'];
753 753
 			$label = $message['label'];
754 754
 			$block_id = $message['block_id'];
755 755
 			$msg_no = $message['msg_no'];
756 756
 			$msg = $message['message'];
757 757
 			$decode = $message['decode'];
758
-			$registration = (string)$message['registration'];
758
+			$registration = (string) $message['registration'];
759 759
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
760 760
 			else $latitude = '';
761 761
 			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
@@ -769,20 +769,20 @@  discard block
 block discarded – undo
769 769
 				$Image->addSpotterImage($registration);
770 770
 			}
771 771
 			// Business jets always use GS0001
772
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
772
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
773 773
 			if ($globalDebug && isset($info) && $info != '') echo $info;
774 774
 			if (count($decode) > 0) $decode_json = json_encode($decode);
775 775
 			else $decode_json = '';
776 776
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
777
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
777
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
778 778
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
779
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
779
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
780 780
 			}
781
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
782
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
783
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
781
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
782
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
783
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
784 784
 			if ($globalDebug && count($decode) > 0) {
785
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
785
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
786 786
 			}
787 787
 		}
788 788
 	}
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
      * @param string $decode
800 800
      * @return bool
801 801
      */
802
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
802
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
803 803
 		global $globalDebug;
804 804
 		date_default_timezone_set('UTC');
805 805
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -807,22 +807,22 @@  discard block
 block discarded – undo
807 807
 			$this->db = $Connection->db;
808 808
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
809 809
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
810
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
810
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
811 811
 			try {
812 812
 				$stht = $this->db->prepare($query_test);
813 813
 				$stht->execute($query_test_values);
814
-			} catch(PDOException $e) {
814
+			} catch (PDOException $e) {
815 815
 				echo "error : ".$e->getMessage();
816 816
 				return false;
817 817
 			}
818 818
 			if ($stht->fetchColumn() == 0) {
819 819
 				if ($globalDebug) echo "Add Live ACARS data...";
820 820
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
821
-				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
821
+				$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s"));
822 822
 				try {
823 823
 					$sth = $this->db->prepare($query);
824 824
 					$sth->execute($query_values);
825
-				} catch(PDOException $e) {
825
+				} catch (PDOException $e) {
826 826
 					echo "error : ".$e->getMessage();
827 827
 					return false;
828 828
 				}
@@ -848,10 +848,10 @@  discard block
 block discarded – undo
848 848
      * @param string $decode
849 849
      * @return string
850 850
      */
851
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
851
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
852 852
 		global $globalDebug;
853 853
 		date_default_timezone_set('UTC');
854
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
854
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
855 855
 			/*
856 856
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
857 857
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 			*/
867 867
 			if ($globalDebug) echo "Add Live ACARS data...";
868 868
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
869
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
869
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
870 870
 			try {
871 871
 				$sth = $this->db->prepare($query);
872 872
 				$sth->execute($query_values);
873
-			} catch(PDOException $e) {
873
+			} catch (PDOException $e) {
874 874
 				return "error : ".$e->getMessage();
875 875
 			}
876 876
 			if ($globalDebug) echo "Done\n";
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 		try {
893 893
 			$sth = $this->db->prepare($query);
894 894
 			$sth->execute($query_values);
895
-		} catch(PDOException $e) {
895
+		} catch (PDOException $e) {
896 896
 			echo "error : ".$e->getMessage();
897 897
 			return '';
898 898
 		}
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 		try {
913 913
 			$sth = $this->db->prepare($query);
914 914
 			$sth->execute($query_values);
915
-		} catch(PDOException $e) {
915
+		} catch (PDOException $e) {
916 916
 			echo "error : ".$e->getMessage();
917 917
 			return array();
918 918
 		}
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 		try {
934 934
 			$sth = $this->db->prepare($query);
935 935
 			$sth->execute($query_values);
936
-		} catch(PDOException $e) {
936
+		} catch (PDOException $e) {
937 937
 			echo "error : ".$e->getMessage();
938 938
 			return array();
939 939
 		}
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
      * @param string $label
950 950
      * @return array Return ACARS data in array
951 951
      */
952
-	public function getLatestAcarsData($limit = '',$label = '') {
952
+	public function getLatestAcarsData($limit = '', $label = '') {
953 953
 		global $globalURL;
954 954
 		$Image = new Image($this->db);
955 955
 		$Spotter = new Spotter($this->db);
@@ -960,8 +960,8 @@  discard block
 block discarded – undo
960 960
 		if ($limit != "")
961 961
 		{
962 962
 			$limit_array = explode(",", $limit);
963
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
964
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
963
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
964
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
965 965
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
966 966
 			{
967 967
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 		try {
978 978
 			$sth = $this->db->prepare($query);
979 979
 			$sth->execute($query_values);
980
-		} catch(PDOException $e) {
980
+		} catch (PDOException $e) {
981 981
 			echo "error : ".$e->getMessage();
982 982
 			return array();
983 983
 		}
@@ -985,39 +985,39 @@  discard block
 block discarded – undo
985 985
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
986 986
 			$data = array();
987 987
 			if ($row['registration'] != '') {
988
-				$row['registration'] = str_replace('.','',$row['registration']);
988
+				$row['registration'] = str_replace('.', '', $row['registration']);
989 989
 				$image_array = $Image->getSpotterImage($row['registration']);
990
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
991
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
992
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
990
+				if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
991
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
992
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
993 993
 			if ($row['registration'] == '') $row['registration'] = 'NA';
994 994
 			if ($row['ident'] == '') $row['ident'] = 'NA';
995
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
995
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
996 996
 			if (isset($identicao[0])) {
997
-				if (substr($row['ident'],0,2) == 'AF') {
998
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1000
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1001
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
997
+				if (substr($row['ident'], 0, 2) == 'AF') {
998
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1000
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1001
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1002 1002
 			} else $icao = $row['ident'];
1003
-			$icao = $Translation->checkTranslation($icao,false);
1004
-			$decode = json_decode($row['decode'],true);
1003
+			$icao = $Translation->checkTranslation($icao, false);
1004
+			$decode = json_decode($row['decode'], true);
1005 1005
 			$found = false;
1006
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1006
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1007 1007
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1008 1008
 				if (isset($airport_info[0]['icao'])) {
1009 1009
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1010 1010
 					$found = true;
1011 1011
 				}
1012 1012
 			}
1013
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1013
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1014 1014
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1015 1015
 				if (isset($airport_info[0]['icao'])) {
1016 1016
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1017 1017
 					$found = true;
1018 1018
 				}
1019 1019
 			}
1020
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1020
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1021 1021
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1022 1022
 				if (isset($airport_info[0]['icao'])) {
1023 1023
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 				}
1026 1026
 			}
1027 1027
 			if ($found) $row['decode'] = json_encode($decode);
1028
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1028
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1029 1029
 			$result[] = $data;
1030 1030
 			$i++;
1031 1031
 		}
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
      * @param string $label
1044 1044
      * @return array Return ACARS data in array
1045 1045
      */
1046
-	public function getArchiveAcarsData($limit = '',$label = '') {
1046
+	public function getArchiveAcarsData($limit = '', $label = '') {
1047 1047
 		global $globalURL;
1048 1048
 		$Image = new Image($this->db);
1049 1049
 		$Spotter = new Spotter($this->db);
@@ -1053,8 +1053,8 @@  discard block
 block discarded – undo
1053 1053
 		if ($limit != "")
1054 1054
 		{
1055 1055
 			$limit_array = explode(",", $limit);
1056
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1057
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1056
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1057
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1058 1058
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1059 1059
 			{
1060 1060
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1075,45 +1075,45 @@  discard block
 block discarded – undo
1075 1075
 		try {
1076 1076
 			$sth = $this->db->prepare($query);
1077 1077
 			$sth->execute($query_values);
1078
-		} catch(PDOException $e) {
1078
+		} catch (PDOException $e) {
1079 1079
 			echo "error : ".$e->getMessage();
1080 1080
 			return array();
1081 1081
 		}
1082
-		$i=0;
1082
+		$i = 0;
1083 1083
 		$result = array();
1084 1084
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1085 1085
 			$data = array();
1086 1086
 			if ($row['registration'] != '') {
1087
-				$row['registration'] = str_replace('.','',$row['registration']);
1087
+				$row['registration'] = str_replace('.', '', $row['registration']);
1088 1088
 				$image_array = $Image->getSpotterImage($row['registration']);
1089
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1090
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1091
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1089
+				if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
1090
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1091
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1092 1092
 			$icao = '';
1093 1093
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1094 1094
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1095
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1095
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1096 1096
 			if (isset($identicao[0])) {
1097
-				if (substr($row['ident'],0,2) == 'AF') {
1098
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1100
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1101
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1097
+				if (substr($row['ident'], 0, 2) == 'AF') {
1098
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1100
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1101
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1102 1102
 			} else $icao = $row['ident'];
1103 1103
 			$icao = $Translation->checkTranslation($icao);
1104
-			$decode = json_decode($row['decode'],true);
1104
+			$decode = json_decode($row['decode'], true);
1105 1105
 			$found = false;
1106
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1106
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1107 1107
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1108 1108
 				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1109 1109
 				$found = true;
1110 1110
 			}
1111
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1111
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1112 1112
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1113 1113
 				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1114 1114
 				$found = true;
1115 1115
 			}
1116
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1116
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1117 1117
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1118 1118
 				if (isset($airport_info[0]['icao'])) {
1119 1119
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 				}
1122 1122
 			}
1123 1123
 			if ($found) $row['decode'] = json_encode($decode);
1124
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1124
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1125 1125
 			$result[] = $data;
1126 1126
 			$i++;
1127 1127
 		}
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
      * @param string $longitude
1143 1143
      * @return string
1144 1144
      */
1145
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1145
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1146 1146
 		global $globalDebug, $globalDBdriver;
1147 1147
 		$ident = trim($ident);
1148 1148
 		$Translation = new Translation($this->db);
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			if ($globalDebug) echo "Ident or registration null, exit\n";
1156 1156
 			return '';
1157 1157
 		}
1158
-		$registration = str_replace('.','',$registration);
1158
+		$registration = str_replace('.', '', $registration);
1159 1159
 		$ident = $Translation->ident2icao($ident);
1160 1160
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1161 1161
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 		try {
1165 1165
 			$sthsi = $this->db->prepare($querysi);
1166 1166
 			$sthsi->execute($querysi_values);
1167
-		} catch(PDOException $e) {
1167
+		} catch (PDOException $e) {
1168 1168
 			if ($globalDebug) echo $e->getMessage();
1169 1169
 			return "error : ".$e->getMessage();
1170 1170
 		}
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 			$Translation = new Translation($this->db);
1175 1175
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1176 1176
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1177
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1178
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1177
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1178
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1179 1179
 		} else {
1180 1180
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1181 1181
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 				try {
1184 1184
 					$sth = $this->db->prepare($query);
1185 1185
 					$sth->execute($query_values);
1186
-				} catch(PDOException $e) {
1186
+				} catch (PDOException $e) {
1187 1187
 					if ($globalDebug) echo $e->getMessage();
1188 1188
 					return "error : ".$e->getMessage();
1189 1189
 				}
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 				$sth->closeCursor();
1192 1192
 				if (isset($result['modes'])) $hex = $result['modes'];
1193 1193
 				else $hex = '';
1194
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1194
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1195 1195
 				if ($this->fromACARSscript) $this->SI->add($SI_data);
1196 1196
 			}
1197 1197
 		}
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 		try {
1202 1202
 			$sth = $this->db->prepare($query);
1203 1203
 			$sth->execute($query_values);
1204
-		} catch(PDOException $e) {
1204
+		} catch (PDOException $e) {
1205 1205
 			if ($globalDebug) echo $e->getMessage();
1206 1206
 			return "error : ".$e->getMessage();
1207 1207
 		}
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1212 1212
 			else $ModeS = '';
1213 1213
 			if ($ModeS == '') {
1214
-				$id = explode('-',$result['flightaware_id']);
1214
+				$id = explode('-', $result['flightaware_id']);
1215 1215
 				$ModeS = $id[0];
1216 1216
 			}
1217 1217
 			if ($ModeS != '') {
@@ -1221,20 +1221,20 @@  discard block
 block discarded – undo
1221 1221
 				try {
1222 1222
 					$sthc = $this->db->prepare($queryc);
1223 1223
 					$sthc->execute($queryc_values);
1224
-				} catch(PDOException $e) {
1224
+				} catch (PDOException $e) {
1225 1225
 					if ($globalDebug) echo $e->getMessage();
1226 1226
 					return "error : ".$e->getMessage();
1227 1227
 				}
1228 1228
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1229 1229
 				$sthc->closeCursor();
1230
-				if (count($row) ==  0) {
1230
+				if (count($row) == 0) {
1231 1231
 					if ($globalDebug) echo " Add to ModeS table - ";
1232 1232
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1233
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1233
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1234 1234
 					try {
1235 1235
 						$sthi = $this->db->prepare($queryi);
1236 1236
 						$sthi->execute($queryi_values);
1237
-					} catch(PDOException $e) {
1237
+					} catch (PDOException $e) {
1238 1238
 						if ($globalDebug) echo $e->getMessage();
1239 1239
 						return "error : ".$e->getMessage();
1240 1240
 					}
@@ -1242,15 +1242,15 @@  discard block
 block discarded – undo
1242 1242
 					if ($globalDebug) echo " Update ModeS table - ";
1243 1243
 					if ($ICAOTypeCode != '') {
1244 1244
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1245
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1245
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1246 1246
 					} else {
1247 1247
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1248
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1248
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1249 1249
 					}
1250 1250
 					try {
1251 1251
 						$sthi = $this->db->prepare($queryi);
1252 1252
 						$sthi->execute($queryi_values);
1253
-					} catch(PDOException $e) {
1253
+					} catch (PDOException $e) {
1254 1254
 						if ($globalDebug) echo $e->getMessage();
1255 1255
 						return "error : ".$e->getMessage();
1256 1256
 					}
@@ -1287,12 +1287,12 @@  discard block
 block discarded – undo
1287 1287
 					elseif ($globalDBdriver == 'pgsql') {
1288 1288
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1289 1289
 					}
1290
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1290
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1291 1291
 				}
1292 1292
 				try {
1293 1293
 					$sthi = $this->db->prepare($queryi);
1294 1294
 					$sthi->execute($queryi_values);
1295
-				} catch(PDOException $e) {
1295
+				} catch (PDOException $e) {
1296 1296
 					if ($globalDebug) echo $e->getMessage();
1297 1297
 					return "error : ".$e->getMessage();
1298 1298
 				}
Please login to merge, or discard this patch.
Braces   +415 added lines, -263 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null,$fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection. (ACARS)');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection. (ACARS)');
29
+		}
28 30
 		if ($fromACARSscript) {
29 31
 			$this->fromACARSscript = true;
30 32
 			$this->SI = new SpotterImport($this->db);
@@ -39,14 +41,19 @@  discard block
 block discarded – undo
39 41
 	*/
40 42
 	public function ident2icao($ident) {
41 43
 		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
44
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
45
+				$icao = $ident;
46
+			} else {
47
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
48
+			}
44 49
 		} else {
45 50
 			$Spotter = new Spotter($this->db);
46 51
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
47 52
 			if (isset($identicao[0])) {
48 53
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
49
-			} else $icao = $ident;
54
+			} else {
55
+				$icao = $ident;
56
+			}
50 57
 		}
51 58
 		return $icao;
52 59
 	}
@@ -120,14 +127,24 @@  discard block
 block discarded – undo
120 127
 		$message = '';
121 128
 		$result = array();
122 129
 		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
125
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
130
+		if ($n == 0) {
131
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
132
+		}
133
+		if ($n == 0) {
134
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
135
+		}
136
+		if ($n == 0) {
137
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
138
+		}
126 139
 		if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) {
127 140
 			$registration = str_replace('.','',$registration);
128 141
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
129
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
130
-		} else $message = $data;
142
+			if ($globalDebug) {
143
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
144
+			}
145
+		} else {
146
+			$message = $data;
147
+		}
131 148
 		$decode = array();
132 149
 		$found = false;
133 150
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -147,12 +164,21 @@  discard block
 block discarded – undo
147 164
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
148 165
 					$latitude = $la / 10000.0;
149 166
 					$longitude = $ln / 10000.0;
150
-					if ($lac == 'S') $latitude = '-'.$latitude;
151
-					if ($lnc == 'W') $longitude = '-'.$longitude;
167
+					if ($lac == 'S') {
168
+						$latitude = '-'.$latitude;
169
+					}
170
+					if ($lnc == 'W') {
171
+						$longitude = '-'.$longitude;
172
+					}
152 173
 					// Temp not always available
153
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
154
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
155
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
174
+					if ($globalDebug) {
175
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
176
+					}
177
+					if ($temp == '') {
178
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
179
+					} else {
180
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
181
+					}
156 182
 
157 183
 					//$icao = $Translation->checkTranslation($ident);
158 184
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -166,25 +192,35 @@  discard block
 block discarded – undo
166 192
 				$ahour = '';
167 193
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
168 194
 				if ($n == 4 && strlen($darr) == 4) {
169
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
170
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
171
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
195
+					if ($dhour != '') {
196
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
197
+					}
198
+					if ($ahour != '') {
199
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
200
+					}
201
+					if ($globalDebug) {
202
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
203
+					}
172 204
 					//$icao = ACARS->ident2icao($ident);
173 205
 					//$icao = $Translation->checkTranslation($ident);
174 206
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
175 207
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
176 208
 					$found = true;
177
-				}
178
-				elseif ($n == 2 || $n  == 4) {
179
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
180
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
209
+				} elseif ($n == 2 || $n  == 4) {
210
+					if ($dhour != '') {
211
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
212
+					}
213
+					if ($globalDebug) {
214
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
215
+					}
181 216
 					//$icao = ACARS->ident2icao($ident);
182 217
 					//$icao = $Translation->checkTranslation($ident);
183 218
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
184 219
 					$found = true;
185
-				}
186
-				elseif ($n == 1) {
187
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
220
+				} elseif ($n == 1) {
221
+					if ($globalDebug) {
222
+						echo 'airport arrival : '.$darr."\n";
223
+					}
188 224
 					//$icao = ACARS->ident2icao($ident);
189 225
 					//$icao = $Translation->checkTranslation($ident);
190 226
 					$decode = array('Arrival airport' => $darr);
@@ -202,7 +238,9 @@  discard block
 block discarded – undo
202 238
 				$darr = '';
203 239
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
204 240
 				if ($n == 4) {
205
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
241
+					if ($globalDebug) {
242
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
243
+					}
206 244
 					//$icao = ACARS->ident2icao($ident);
207 245
 					//$icao = $Translation->checkTranslation($ident);
208 246
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -236,14 +274,23 @@  discard block
 block discarded – undo
236 274
 				$apiste = '';
237 275
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
238 276
 				if ($n > 8) {
239
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
240
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
241
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
277
+					if ($globalDebug) {
278
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
279
+					}
280
+					if ($dhour != '') {
281
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
282
+					}
283
+					if ($ahour != '') {
284
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
285
+					}
242 286
 					$icao = trim($aident);
243 287
 
244 288
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
245
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
246
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
289
+					if ($ahour == '') {
290
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
291
+					} else {
292
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
293
+					}
247 294
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
248 295
 					$decode['icao'] = $icao;
249 296
 					$found = true;
@@ -265,9 +312,15 @@  discard block
 block discarded – undo
265 312
 					$lns = $lns.'.'.$lns;
266 313
 					$latitude = $las / 1000.0;
267 314
 					$longitude = $lns / 1000.0;
268
-					if ($lac == 'S') $latitude = '-'.$latitude;
269
-					if ($lnc == 'W') $longitude = '-'.$longitude;
270
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
315
+					if ($lac == 'S') {
316
+						$latitude = '-'.$latitude;
317
+					}
318
+					if ($lnc == 'W') {
319
+						$longitude = '-'.$longitude;
320
+					}
321
+					if ($globalDebug) {
322
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
323
+					}
271 324
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
272 325
 					$found = true;
273 326
 				}
@@ -285,7 +338,9 @@  discard block
 block discarded – undo
285 338
 				$darr = '';
286 339
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
287 340
 				if ($n == 4) {
288
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
341
+					if ($globalDebug) {
342
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
343
+					}
289 344
 					//$icao = $Translation->checkTranslation($ident);
290 345
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
291 346
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -298,7 +353,9 @@  discard block
 block discarded – undo
298 353
 				$darr = '';
299 354
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
300 355
 				if ($n == 4) {
301
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
356
+					if ($globalDebug) {
357
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
358
+					}
302 359
 					//$icao = $Translation->checkTranslation($ident);
303 360
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
304 361
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -311,7 +368,9 @@  discard block
 block discarded – undo
311 368
 				$darr = '';
312 369
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
313 370
 				if ($n == 2) {
314
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
371
+					if ($globalDebug) {
372
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
373
+					}
315 374
 					//$icao = $Translation->checkTranslation($ident);
316 375
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
317 376
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -325,7 +384,9 @@  discard block
 block discarded – undo
325 384
 				$darr = '';
326 385
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
327 386
 				if ($n == 6) {
328
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
387
+					if ($globalDebug) {
388
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
389
+					}
329 390
 					//$icao = $Translation->checkTranslation($ident);
330 391
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
331 392
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -338,7 +399,9 @@  discard block
 block discarded – undo
338 399
 				$darr = '';
339 400
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
340 401
 				if ($n == 7) {
341
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
402
+					if ($globalDebug) {
403
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
404
+					}
342 405
 					//$icao = $Translation->checkTranslation($ident);
343 406
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
344 407
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -366,8 +429,12 @@  discard block
 block discarded – undo
366 429
 					$decode['icao'] = $icao;
367 430
 					$latitude = $las / 100.0;
368 431
 					$longitude = $lns / 100.0;
369
-					if ($lac == 'S') $latitude = '-'.$latitude;
370
-					if ($lnc == 'W') $longitude = '-'.$longitude;
432
+					if ($lac == 'S') {
433
+						$latitude = '-'.$latitude;
434
+					}
435
+					if ($lnc == 'W') {
436
+						$longitude = '-'.$longitude;
437
+					}
371 438
 
372 439
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
373 440
 					$found = true;
@@ -385,8 +452,12 @@  discard block
 block discarded – undo
385 452
 				if ($n == 4) {
386 453
 					$latitude = $las;
387 454
 					$longitude = $lns;
388
-					if ($lac == 'S') $latitude = '-'.$latitude;
389
-					if ($lnc == 'W') $longitude = '-'.$longitude;
455
+					if ($lac == 'S') {
456
+						$latitude = '-'.$latitude;
457
+					}
458
+					if ($lnc == 'W') {
459
+						$longitude = '-'.$longitude;
460
+					}
390 461
 
391 462
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
392 463
 					$found = true;
@@ -402,7 +473,9 @@  discard block
 block discarded – undo
402 473
 				$darr = '';
403 474
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
404 475
 				if ($n == 5) {
405
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
476
+					if ($globalDebug) {
477
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
478
+					}
406 479
 					//$icao = $Translation->checkTranslation($ident);
407 480
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
408 481
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -423,7 +496,9 @@  discard block
 block discarded – undo
423 496
 				$aident = '';
424 497
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
425 498
 				if ($n == 8) {
426
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
499
+					if ($globalDebug) {
500
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
501
+					}
427 502
 					$icao = trim($aident);
428 503
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
429 504
 					$decode['icao'] = $icao;
@@ -440,7 +515,9 @@  discard block
 block discarded – undo
440 515
 				$darr = '';
441 516
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
442 517
 				if ($n == 5) {
443
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
518
+					if ($globalDebug) {
519
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
520
+					}
444 521
 					//$icao = $Translation->checkTranslation($ident);
445 522
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
446 523
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -455,7 +532,9 @@  discard block
 block discarded – undo
455 532
 				$darr = '';
456 533
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
457 534
 				if ($n == 3) {
458
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
535
+					if ($globalDebug) {
536
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
537
+					}
459 538
 					//$icao = $Translation->checkTranslation($ident);
460 539
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
461 540
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -470,7 +549,9 @@  discard block
 block discarded – undo
470 549
 				$darr = '';
471 550
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
472 551
 				if ($n == 3) {
473
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
552
+					if ($globalDebug) {
553
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
554
+					}
474 555
 					//$icao = $Translation->checkTranslation($ident);
475 556
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
476 557
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -480,7 +561,9 @@  discard block
 block discarded – undo
480 561
 			if (!$found) {
481 562
 				$n = sscanf($message,'MET01%4c',$airport);
482 563
 				if ($n == 1) {
483
-					if ($globalDebug) echo 'airport name : '.$airport;
564
+					if ($globalDebug) {
565
+						echo 'airport name : '.$airport;
566
+					}
484 567
 					$decode = array('Airport/Waypoint name' => $airport);
485 568
 					$found = true;
486 569
 				}
@@ -488,184 +571,126 @@  discard block
 block discarded – undo
488 571
 			if ($label == 'H1') {
489 572
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
490 573
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
491
-				}
492
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
574
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
493 575
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
494
-				}
495
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
576
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
496 577
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
497
-				}
498
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
578
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
499 579
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
500
-				}
501
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
580
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
502 581
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
503
-				}
504
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
582
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
505 583
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
506
-				}
507
-				elseif (preg_match(':^#M1AAEP:',$message)) {
584
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
508 585
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
509
-				}
510
-				elseif (preg_match(':^#M2APWD:',$message)) {
586
+				} elseif (preg_match(':^#M2APWD:',$message)) {
511 587
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
512
-				}
513
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
588
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
514 589
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
515
-				}
516
-				elseif (preg_match(':^#CF:',$message)) {
590
+				} elseif (preg_match(':^#CF:',$message)) {
517 591
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
518
-				}
519
-				elseif (preg_match(':^#DF:',$message)) {
592
+				} elseif (preg_match(':^#DF:',$message)) {
520 593
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
521
-				}
522
-				elseif (preg_match(':^#EC:',$message)) {
594
+				} elseif (preg_match(':^#EC:',$message)) {
523 595
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
524
-				}
525
-				elseif (preg_match(':^#EI:',$message)) {
596
+				} elseif (preg_match(':^#EI:',$message)) {
526 597
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
527
-				}
528
-				elseif (preg_match(':^#H1:',$message)) {
598
+				} elseif (preg_match(':^#H1:',$message)) {
529 599
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
530
-				}
531
-				elseif (preg_match(':^#H2:',$message)) {
600
+				} elseif (preg_match(':^#H2:',$message)) {
532 601
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
533
-				}
534
-				elseif (preg_match(':^#HD:',$message)) {
602
+				} elseif (preg_match(':^#HD:',$message)) {
535 603
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
536
-				}
537
-				elseif (preg_match(':^#M1:',$message)) {
604
+				} elseif (preg_match(':^#M1:',$message)) {
538 605
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
539
-				}
540
-				elseif (preg_match(':^#M2:',$message)) {
606
+				} elseif (preg_match(':^#M2:',$message)) {
541 607
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
542
-				}
543
-				elseif (preg_match(':^#M3:',$message)) {
608
+				} elseif (preg_match(':^#M3:',$message)) {
544 609
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
545
-				}
546
-				elseif (preg_match(':^#MD:',$message)) {
610
+				} elseif (preg_match(':^#MD:',$message)) {
547 611
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
548
-				}
549
-				elseif (preg_match(':^#PS:',$message)) {
612
+				} elseif (preg_match(':^#PS:',$message)) {
550 613
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
551
-				}
552
-				elseif (preg_match(':^#S1:',$message)) {
614
+				} elseif (preg_match(':^#S1:',$message)) {
553 615
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
554
-				}
555
-				elseif (preg_match(':^#S2:',$message)) {
616
+				} elseif (preg_match(':^#S2:',$message)) {
556 617
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
557
-				}
558
-				elseif (preg_match(':^#SD:',$message)) {
618
+				} elseif (preg_match(':^#SD:',$message)) {
559 619
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
560
-				}
561
-				elseif (preg_match(':^#T[0-8]:',$message)) {
620
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
562 621
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
563
-				}
564
-				elseif (preg_match(':^#WO:',$message)) {
622
+				} elseif (preg_match(':^#WO:',$message)) {
565 623
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
566
-				}
567
-				elseif (preg_match(':^#A1:',$message)) {
624
+				} elseif (preg_match(':^#A1:',$message)) {
568 625
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
569
-				}
570
-				elseif (preg_match(':^#A3:',$message)) {
626
+				} elseif (preg_match(':^#A3:',$message)) {
571 627
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
572
-				}
573
-				elseif (preg_match(':^#A4:',$message)) {
628
+				} elseif (preg_match(':^#A4:',$message)) {
574 629
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
575
-				}
576
-				elseif (preg_match(':^#A6:',$message)) {
630
+				} elseif (preg_match(':^#A6:',$message)) {
577 631
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
578
-				}
579
-				elseif (preg_match(':^#A8:',$message)) {
632
+				} elseif (preg_match(':^#A8:',$message)) {
580 633
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
581
-				}
582
-				elseif (preg_match(':^#A9:',$message)) {
634
+				} elseif (preg_match(':^#A9:',$message)) {
583 635
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
584
-				}
585
-				elseif (preg_match(':^#A0:',$message)) {
636
+				} elseif (preg_match(':^#A0:',$message)) {
586 637
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
587
-				}
588
-				elseif (preg_match(':^#AA:',$message)) {
638
+				} elseif (preg_match(':^#AA:',$message)) {
589 639
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
590
-				}
591
-				elseif (preg_match(':^#AB:',$message)) {
640
+				} elseif (preg_match(':^#AB:',$message)) {
592 641
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
593
-				}
594
-				elseif (preg_match(':^#AC:',$message)) {
642
+				} elseif (preg_match(':^#AC:',$message)) {
595 643
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
596
-				}
597
-				elseif (preg_match(':^#AD:',$message)) {
644
+				} elseif (preg_match(':^#AD:',$message)) {
598 645
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
599
-				}
600
-				elseif (preg_match(':^#AF:',$message)) {
646
+				} elseif (preg_match(':^#AF:',$message)) {
601 647
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
602
-				}
603
-				elseif (preg_match(':^#B1:',$message)) {
648
+				} elseif (preg_match(':^#B1:',$message)) {
604 649
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
605
-				}
606
-				elseif (preg_match(':^#B2:',$message)) {
650
+				} elseif (preg_match(':^#B2:',$message)) {
607 651
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
608
-				}
609
-				elseif (preg_match(':^#B3:',$message)) {
652
+				} elseif (preg_match(':^#B3:',$message)) {
610 653
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
611
-				}
612
-				elseif (preg_match(':^#B4:',$message)) {
654
+				} elseif (preg_match(':^#B4:',$message)) {
613 655
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
614
-				}
615
-				elseif (preg_match(':^#B6:',$message)) {
656
+				} elseif (preg_match(':^#B6:',$message)) {
616 657
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
617
-				}
618
-				elseif (preg_match(':^#B8:',$message)) {
658
+				} elseif (preg_match(':^#B8:',$message)) {
619 659
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
620
-				}
621
-				elseif (preg_match(':^#B9:',$message)) {
660
+				} elseif (preg_match(':^#B9:',$message)) {
622 661
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
623
-				}
624
-				elseif (preg_match(':^#B0:',$message)) {
662
+				} elseif (preg_match(':^#B0:',$message)) {
625 663
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
626
-				}
627
-				elseif (preg_match(':^#BA:',$message)) {
664
+				} elseif (preg_match(':^#BA:',$message)) {
628 665
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
629
-				}
630
-				elseif (preg_match(':^#BB:',$message)) {
666
+				} elseif (preg_match(':^#BB:',$message)) {
631 667
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
632
-				}
633
-				elseif (preg_match(':^#BC:',$message)) {
668
+				} elseif (preg_match(':^#BC:',$message)) {
634 669
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
635
-				}
636
-				elseif (preg_match(':^#BD:',$message)) {
670
+				} elseif (preg_match(':^#BD:',$message)) {
637 671
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
638
-				}
639
-				elseif (preg_match(':^#BE:',$message)) {
672
+				} elseif (preg_match(':^#BE:',$message)) {
640 673
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
641
-				}
642
-				elseif (preg_match(':^#BF:',$message)) {
674
+				} elseif (preg_match(':^#BF:',$message)) {
643 675
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
644
-				}
645
-				elseif (preg_match(':^#H3:',$message)) {
676
+				} elseif (preg_match(':^#H3:',$message)) {
646 677
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
647 678
 				}
648 679
 			}
649 680
 			if ($label == '10') {
650 681
 				if (preg_match(':^DTO01:',$message)) {
651 682
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
652
-				}
653
-				elseif (preg_match(':^AIS01:',$message)) {
683
+				} elseif (preg_match(':^AIS01:',$message)) {
654 684
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
655
-				}
656
-				elseif (preg_match(':^FTX01:',$message)) {
685
+				} elseif (preg_match(':^FTX01:',$message)) {
657 686
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
658
-				}
659
-				elseif (preg_match(':^FPL01:',$message)) {
687
+				} elseif (preg_match(':^FPL01:',$message)) {
660 688
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
661
-				}
662
-				elseif (preg_match(':^WAB01:',$message)) {
689
+				} elseif (preg_match(':^WAB01:',$message)) {
663 690
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
664
-				}
665
-				elseif (preg_match(':^MET01:',$message)) {
691
+				} elseif (preg_match(':^MET01:',$message)) {
666 692
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
667
-				}
668
-				elseif (preg_match(':^WAB02:',$message)) {
693
+				} elseif (preg_match(':^WAB02:',$message)) {
669 694
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
670 695
 				}
671 696
 			}
@@ -680,38 +705,28 @@  discard block
 block discarded – undo
680 705
 					$vsta = array('Version' => $version);
681 706
 					if ($state == 'E') {
682 707
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
683
-					}
684
-					elseif ($state == 'L') {
708
+					} elseif ($state == 'L') {
685 709
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
686
-					}
687
-					else {
710
+					} else {
688 711
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
689 712
 					}
690 713
 					if ($type == 'V') {
691 714
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
692
-					}
693
-					elseif ($type == 'S') {
715
+					} elseif ($type == 'S') {
694 716
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
695
-					}
696
-					elseif ($type == 'H') {
717
+					} elseif ($type == 'H') {
697 718
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
698
-					}
699
-					elseif ($type == 'G') {
719
+					} elseif ($type == 'G') {
700 720
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
701
-					}
702
-					elseif ($type == 'C') {
721
+					} elseif ($type == 'C') {
703 722
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
704
-					}
705
-					elseif ($type == '2') {
723
+					} elseif ($type == '2') {
706 724
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
707
-					}
708
-					elseif ($type == 'X') {
725
+					} elseif ($type == 'X') {
709 726
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
710
-					}
711
-					elseif ($type == 'I') {
727
+					} elseif ($type == 'I') {
712 728
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
713
-					}
714
-					else {
729
+					} else {
715 730
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
716 731
 					}
717 732
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -720,7 +735,9 @@  discard block
 block discarded – undo
720 735
 			}
721 736
 
722 737
 			$title = $this->getTitlefromLabel($label);
723
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
738
+			if ($title != '') {
739
+				$decode = array_merge(array('Message title' => $title),$decode);
740
+			}
724 741
 			/*
725 742
 			// Business jets always use GS0001
726 743
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -756,31 +773,54 @@  discard block
 block discarded – undo
756 773
 			$msg = $message['message'];
757 774
 			$decode = $message['decode'];
758 775
 			$registration = (string)$message['registration'];
759
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
760
-			else $latitude = '';
761
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
762
-			else $longitude = '';
763
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
764
-			else $airicao = '';
765
-			if (isset($decode['icao'])) $icao = $decode['icao'];
766
-			else $icao = $Translation->checkTranslation($ident);
776
+			if (isset($decode['latitude'])) {
777
+				$latitude = $decode['latitude'];
778
+			} else {
779
+				$latitude = '';
780
+			}
781
+			if (isset($decode['longitude'])) {
782
+				$longitude = $decode['longitude'];
783
+			} else {
784
+				$longitude = '';
785
+			}
786
+			if (isset($decode['airicao'])) {
787
+				$airicao = $decode['airicao'];
788
+			} else {
789
+				$airicao = '';
790
+			}
791
+			if (isset($decode['icao'])) {
792
+				$icao = $decode['icao'];
793
+			} else {
794
+				$icao = $Translation->checkTranslation($ident);
795
+			}
767 796
 			$image_array = $Image->getSpotterImage($registration);
768 797
 			if (!isset($image_array[0]['registration'])) {
769 798
 				$Image->addSpotterImage($registration);
770 799
 			}
771 800
 			// Business jets always use GS0001
772
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
773
-			if ($globalDebug && isset($info) && $info != '') echo $info;
774
-			if (count($decode) > 0) $decode_json = json_encode($decode);
775
-			else $decode_json = '';
801
+			if ($ident != 'GS0001') {
802
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
803
+			}
804
+			if ($globalDebug && isset($info) && $info != '') {
805
+				echo $info;
806
+			}
807
+			if (count($decode) > 0) {
808
+				$decode_json = json_encode($decode);
809
+			} else {
810
+				$decode_json = '';
811
+			}
776 812
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
777 813
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
778 814
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
779 815
 				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
780 816
 			}
781 817
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
782
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
783
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
818
+			if (!isset($globalACARSArchive)) {
819
+				$globalACARSArchive = array('10','80','81','82','3F');
820
+			}
821
+			if ($result && in_array($label,$globalACARSArchive)) {
822
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
823
+			}
784 824
 			if ($globalDebug && count($decode) > 0) {
785 825
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
786 826
 			}
@@ -805,7 +845,9 @@  discard block
 block discarded – undo
805 845
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
806 846
 			$Connection = new Connection($this->db);
807 847
 			$this->db = $Connection->db;
808
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
848
+			if ($globalDebug) {
849
+				echo "Test if not already in Live ACARS table...";
850
+			}
809 851
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
810 852
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
811 853
 			try {
@@ -816,7 +858,9 @@  discard block
 block discarded – undo
816 858
 				return false;
817 859
 			}
818 860
 			if ($stht->fetchColumn() == 0) {
819
-				if ($globalDebug) echo "Add Live ACARS data...";
861
+				if ($globalDebug) {
862
+					echo "Add Live ACARS data...";
863
+				}
820 864
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
821 865
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
822 866
 				try {
@@ -827,10 +871,14 @@  discard block
 block discarded – undo
827 871
 					return false;
828 872
 				}
829 873
 			} else {
830
-				if ($globalDebug) echo "Data already in DB...\n";
874
+				if ($globalDebug) {
875
+					echo "Data already in DB...\n";
876
+				}
831 877
 				return false;
832 878
 			}
833
-			if ($globalDebug) echo "Done\n";
879
+			if ($globalDebug) {
880
+				echo "Done\n";
881
+			}
834 882
 			return true;
835 883
 		}
836 884
 		return false;
@@ -864,7 +912,9 @@  discard block
 block discarded – undo
864 912
 			    	    }
865 913
 				    if ($stht->fetchColumn() == 0) {
866 914
 			*/
867
-			if ($globalDebug) echo "Add Live ACARS data...";
915
+			if ($globalDebug) {
916
+				echo "Add Live ACARS data...";
917
+			}
868 918
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
869 919
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
870 920
 			try {
@@ -873,7 +923,9 @@  discard block
 block discarded – undo
873 923
 			} catch(PDOException $e) {
874 924
 				return "error : ".$e->getMessage();
875 925
 			}
876
-			if ($globalDebug) echo "Done\n";
926
+			if ($globalDebug) {
927
+				echo "Done\n";
928
+			}
877 929
 		}
878 930
 		return '';
879 931
 	}
@@ -897,8 +949,11 @@  discard block
 block discarded – undo
897 949
 			return '';
898 950
 		}
899 951
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
900
-		if (count($row) > 0) return $row[0]['title'];
901
-		else return '';
952
+		if (count($row) > 0) {
953
+			return $row[0]['title'];
954
+		} else {
955
+			return '';
956
+		}
902 957
 	}
903 958
 
904 959
 	/**
@@ -917,8 +972,11 @@  discard block
 block discarded – undo
917 972
 			return array();
918 973
 		}
919 974
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
920
-		if (count($row) > 0) return $row;
921
-		else return array();
975
+		if (count($row) > 0) {
976
+			return $row;
977
+		} else {
978
+			return array();
979
+		}
922 980
 	}
923 981
 
924 982
 	/**
@@ -938,8 +996,11 @@  discard block
 block discarded – undo
938 996
 			return array();
939 997
 		}
940 998
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
941
-		if (count($row) > 0) return $row[0];
942
-		else return array();
999
+		if (count($row) > 0) {
1000
+			return $row[0];
1001
+		} else {
1002
+			return array();
1003
+		}
943 1004
 	}
944 1005
 
945 1006
     /**
@@ -987,19 +1048,35 @@  discard block
 block discarded – undo
987 1048
 			if ($row['registration'] != '') {
988 1049
 				$row['registration'] = str_replace('.','',$row['registration']);
989 1050
 				$image_array = $Image->getSpotterImage($row['registration']);
990
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
991
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
992
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			if ($row['registration'] == '') $row['registration'] = 'NA';
994
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1051
+				if (count($image_array) > 0) {
1052
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1053
+				} else {
1054
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1055
+				}
1056
+			} else {
1057
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1058
+			}
1059
+			if ($row['registration'] == '') {
1060
+				$row['registration'] = 'NA';
1061
+			}
1062
+			if ($row['ident'] == '') {
1063
+				$row['ident'] = 'NA';
1064
+			}
995 1065
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
996 1066
 			if (isset($identicao[0])) {
997 1067
 				if (substr($row['ident'],0,2) == 'AF') {
998
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1000
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1068
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1069
+						$icao = $row['ident'];
1070
+					} else {
1071
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1072
+					}
1073
+				} else {
1074
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1075
+				}
1001 1076
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1002
-			} else $icao = $row['ident'];
1077
+			} else {
1078
+				$icao = $row['ident'];
1079
+			}
1003 1080
 			$icao = $Translation->checkTranslation($icao,false);
1004 1081
 			$decode = json_decode($row['decode'],true);
1005 1082
 			$found = false;
@@ -1024,7 +1101,9 @@  discard block
 block discarded – undo
1024 1101
 					$found = true;
1025 1102
 				}
1026 1103
 			}
1027
-			if ($found) $row['decode'] = json_encode($decode);
1104
+			if ($found) {
1105
+				$row['decode'] = json_encode($decode);
1106
+			}
1028 1107
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1029 1108
 			$result[] = $data;
1030 1109
 			$i++;
@@ -1032,8 +1111,9 @@  discard block
 block discarded – undo
1032 1111
 		if (isset($result)) {
1033 1112
 			$result[0]['query_number_rows'] = $i;
1034 1113
 			return $result;
1114
+		} else {
1115
+			return array();
1035 1116
 		}
1036
-		else return array();
1037 1117
 	}
1038 1118
 
1039 1119
     /**
@@ -1086,31 +1166,51 @@  discard block
 block discarded – undo
1086 1166
 			if ($row['registration'] != '') {
1087 1167
 				$row['registration'] = str_replace('.','',$row['registration']);
1088 1168
 				$image_array = $Image->getSpotterImage($row['registration']);
1089
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1090
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1091
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1169
+				if (count($image_array) > 0) {
1170
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1171
+				} else {
1172
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1173
+				}
1174
+			} else {
1175
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1176
+			}
1092 1177
 			$icao = '';
1093
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1094
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1178
+			if ($row['registration'] == '') {
1179
+				$row['registration'] = 'NA';
1180
+			}
1181
+			if ($row['ident'] == '') {
1182
+				$row['ident'] = 'NA';
1183
+			}
1095 1184
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1096 1185
 			if (isset($identicao[0])) {
1097 1186
 				if (substr($row['ident'],0,2) == 'AF') {
1098
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1100
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1187
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1188
+						$icao = $row['ident'];
1189
+					} else {
1190
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1191
+					}
1192
+				} else {
1193
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1194
+				}
1101 1195
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1102
-			} else $icao = $row['ident'];
1196
+			} else {
1197
+				$icao = $row['ident'];
1198
+			}
1103 1199
 			$icao = $Translation->checkTranslation($icao);
1104 1200
 			$decode = json_decode($row['decode'],true);
1105 1201
 			$found = false;
1106 1202
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1107 1203
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1108
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1204
+				if (isset($airport_info[0]['icao'])) {
1205
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1206
+				}
1109 1207
 				$found = true;
1110 1208
 			}
1111 1209
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1112 1210
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1113
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1211
+				if (isset($airport_info[0]['icao'])) {
1212
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1213
+				}
1114 1214
 				$found = true;
1115 1215
 			}
1116 1216
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1120,7 +1220,9 @@  discard block
 block discarded – undo
1120 1220
 					$found = true;
1121 1221
 				}
1122 1222
 			}
1123
-			if ($found) $row['decode'] = json_encode($decode);
1223
+			if ($found) {
1224
+				$row['decode'] = json_encode($decode);
1225
+			}
1124 1226
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1125 1227
 			$result[] = $data;
1126 1228
 			$i++;
@@ -1128,7 +1230,9 @@  discard block
 block discarded – undo
1128 1230
 		if (!empty($result)) {
1129 1231
 			$result[0]['query_number_rows'] = $i;
1130 1232
 			return $result;
1131
-		} else return array();
1233
+		} else {
1234
+			return array();
1235
+		}
1132 1236
 	}
1133 1237
 
1134 1238
     /**
@@ -1147,25 +1251,37 @@  discard block
 block discarded – undo
1147 1251
 		$ident = trim($ident);
1148 1252
 		$Translation = new Translation($this->db);
1149 1253
 		$Spotter = new Spotter($this->db);
1150
-		if ($globalDebug) echo "Test if we add ModeS data...";
1254
+		if ($globalDebug) {
1255
+			echo "Test if we add ModeS data...";
1256
+		}
1151 1257
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1152
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1153
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1258
+		if ($icao == '') {
1259
+			$icao = $Translation->checkTranslation($ident);
1260
+		}
1261
+		if ($globalDebug) {
1262
+			echo '- Ident : '.$icao.' - ';
1263
+		}
1154 1264
 		if ($ident == '' || $registration == '') {
1155
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1265
+			if ($globalDebug) {
1266
+				echo "Ident or registration null, exit\n";
1267
+			}
1156 1268
 			return '';
1157 1269
 		}
1158 1270
 		$registration = str_replace('.','',$registration);
1159 1271
 		$ident = $Translation->ident2icao($ident);
1160 1272
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1161
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1273
+		if ($globalDebug) {
1274
+			echo "Check if needed to add translation ".$ident.'... ';
1275
+		}
1162 1276
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1163 1277
 		$querysi_values = array(':registration' => $registration);
1164 1278
 		try {
1165 1279
 			$sthsi = $this->db->prepare($querysi);
1166 1280
 			$sthsi->execute($querysi_values);
1167 1281
 		} catch(PDOException $e) {
1168
-			if ($globalDebug) echo $e->getMessage();
1282
+			if ($globalDebug) {
1283
+				echo $e->getMessage();
1284
+			}
1169 1285
 			return "error : ".$e->getMessage();
1170 1286
 		}
1171 1287
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1173,9 +1289,14 @@  discard block
 block discarded – undo
1173 1289
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1174 1290
 			$Translation = new Translation($this->db);
1175 1291
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1176
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1177
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1178
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1292
+			if ($globalDebug) {
1293
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1294
+			}
1295
+			if ($ident != $trans_ident) {
1296
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1297
+			} elseif ($trans_ident == $ident) {
1298
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1299
+			}
1179 1300
 		} else {
1180 1301
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1181 1302
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1184,32 +1305,46 @@  discard block
 block discarded – undo
1184 1305
 					$sth = $this->db->prepare($query);
1185 1306
 					$sth->execute($query_values);
1186 1307
 				} catch(PDOException $e) {
1187
-					if ($globalDebug) echo $e->getMessage();
1308
+					if ($globalDebug) {
1309
+						echo $e->getMessage();
1310
+					}
1188 1311
 					return "error : ".$e->getMessage();
1189 1312
 				}
1190 1313
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1191 1314
 				$sth->closeCursor();
1192
-				if (isset($result['modes'])) $hex = $result['modes'];
1193
-				else $hex = '';
1315
+				if (isset($result['modes'])) {
1316
+					$hex = $result['modes'];
1317
+				} else {
1318
+					$hex = '';
1319
+				}
1194 1320
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1195
-				if ($this->fromACARSscript) $this->SI->add($SI_data);
1321
+				if ($this->fromACARSscript) {
1322
+					$this->SI->add($SI_data);
1323
+				}
1196 1324
 			}
1197 1325
 		}
1198
-		if ($globalDebug) echo 'Done'."\n";
1326
+		if ($globalDebug) {
1327
+			echo 'Done'."\n";
1328
+		}
1199 1329
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1200 1330
 		$query_values = array(':ident' => $icao);
1201 1331
 		try {
1202 1332
 			$sth = $this->db->prepare($query);
1203 1333
 			$sth->execute($query_values);
1204 1334
 		} catch(PDOException $e) {
1205
-			if ($globalDebug) echo $e->getMessage();
1335
+			if ($globalDebug) {
1336
+				echo $e->getMessage();
1337
+			}
1206 1338
 			return "error : ".$e->getMessage();
1207 1339
 		}
1208 1340
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1209 1341
 		$sth->closeCursor();
1210 1342
 		if (isset($result['flightaware_id'])) {
1211
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1212
-			else $ModeS = '';
1343
+			if (isset($result['ModeS'])) {
1344
+				$ModeS = $result['ModeS'];
1345
+			} else {
1346
+				$ModeS = '';
1347
+			}
1213 1348
 			if ($ModeS == '') {
1214 1349
 				$id = explode('-',$result['flightaware_id']);
1215 1350
 				$ModeS = $id[0];
@@ -1222,24 +1357,32 @@  discard block
 block discarded – undo
1222 1357
 					$sthc = $this->db->prepare($queryc);
1223 1358
 					$sthc->execute($queryc_values);
1224 1359
 				} catch(PDOException $e) {
1225
-					if ($globalDebug) echo $e->getMessage();
1360
+					if ($globalDebug) {
1361
+						echo $e->getMessage();
1362
+					}
1226 1363
 					return "error : ".$e->getMessage();
1227 1364
 				}
1228 1365
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1229 1366
 				$sthc->closeCursor();
1230 1367
 				if (count($row) ==  0) {
1231
-					if ($globalDebug) echo " Add to ModeS table - ";
1368
+					if ($globalDebug) {
1369
+						echo " Add to ModeS table - ";
1370
+					}
1232 1371
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1233 1372
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1234 1373
 					try {
1235 1374
 						$sthi = $this->db->prepare($queryi);
1236 1375
 						$sthi->execute($queryi_values);
1237 1376
 					} catch(PDOException $e) {
1238
-						if ($globalDebug) echo $e->getMessage();
1377
+						if ($globalDebug) {
1378
+							echo $e->getMessage();
1379
+						}
1239 1380
 						return "error : ".$e->getMessage();
1240 1381
 					}
1241 1382
 				} else {
1242
-					if ($globalDebug) echo " Update ModeS table - ";
1383
+					if ($globalDebug) {
1384
+						echo " Update ModeS table - ";
1385
+					}
1243 1386
 					if ($ICAOTypeCode != '') {
1244 1387
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1245 1388
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1251,7 +1394,9 @@  discard block
 block discarded – undo
1251 1394
 						$sthi = $this->db->prepare($queryi);
1252 1395
 						$sthi->execute($queryi_values);
1253 1396
 					} catch(PDOException $e) {
1254
-						if ($globalDebug) echo $e->getMessage();
1397
+						if ($globalDebug) {
1398
+							echo $e->getMessage();
1399
+						}
1255 1400
 						return "error : ".$e->getMessage();
1256 1401
 					}
1257 1402
 				}
@@ -1272,7 +1417,9 @@  discard block
 block discarded – undo
1272 1417
 					    return "error : ".$e->getMessage();
1273 1418
 				}
1274 1419
 				*/
1275
-				if ($globalDebug) echo " Update Spotter_output table - ";
1420
+				if ($globalDebug) {
1421
+					echo " Update Spotter_output table - ";
1422
+				}
1276 1423
 				if ($ICAOTypeCode != '') {
1277 1424
 					if ($globalDBdriver == 'mysql') {
1278 1425
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1283,8 +1430,7 @@  discard block
 block discarded – undo
1283 1430
 				} else {
1284 1431
 					if ($globalDBdriver == 'mysql') {
1285 1432
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1286
-					}
1287
-					elseif ($globalDBdriver == 'pgsql') {
1433
+					} elseif ($globalDBdriver == 'pgsql') {
1288 1434
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1289 1435
 					}
1290 1436
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1293,14 +1439,20 @@  discard block
 block discarded – undo
1293 1439
 					$sthi = $this->db->prepare($queryi);
1294 1440
 					$sthi->execute($queryi_values);
1295 1441
 				} catch(PDOException $e) {
1296
-					if ($globalDebug) echo $e->getMessage();
1442
+					if ($globalDebug) {
1443
+						echo $e->getMessage();
1444
+					}
1297 1445
 					return "error : ".$e->getMessage();
1298 1446
 				}
1299 1447
 			}
1300 1448
 		} else {
1301
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1449
+			if ($globalDebug) {
1450
+				echo " Can't find ModeS in spotter_output - ";
1451
+			}
1452
+		}
1453
+		if ($globalDebug) {
1454
+			echo "Done\n";
1302 1455
 		}
1303
-		if ($globalDebug) echo "Done\n";
1304 1456
 		return '';
1305 1457
 	}
1306 1458
 }
Please login to merge, or discard this patch.