Completed
Push — master ( 3a8aa2...f2121d )
by Yannick
31:04
created
scripts/daemon-spotter.php 1 patch
Spacing   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106 106
     if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
107
+    $SI = new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
111 111
     $SI->connect();
112 112
 */
113
-} else $SI=new SpotterImport($Connection->db);
113
+} else $SI = new SpotterImport($Connection->db);
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     $MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127
-$SBS=new SBS();
127
+$SBS = new SBS();
128 128
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
129
-	$ACARS=new ACARS($Connection->db,true);
130
-	$Source=new Source($Connection->db);
129
+	$ACARS = new ACARS($Connection->db, true);
130
+	$Source = new Source($Connection->db);
131 131
 }
132
-$Common=new Common();
132
+$Common = new Common();
133 133
 date_default_timezone_set('UTC');
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
137
+    pcntl_signal(SIGINT, function() {
138 138
         global $sockets;
139 139
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140 140
         die("Bye!\n");
@@ -150,30 +150,30 @@  discard block
 block discarded – undo
150 150
 
151 151
 function connect_all($hosts) {
152 152
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
153
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
154 154
     $reset++;
155 155
     if ($globalDebug) echo 'Connect to all...'."\n";
156 156
     foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
160
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
+            if (preg_match('/deltadb.txt$/i', $host)) {
162 162
         	//$formats[$id] = 'deltadbtxt';
163 163
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 164
         	//$last_exec['deltadbtxt'] = 0;
165 165
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
166
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
167 167
         	//$formats[$id] = 'vatsimtxt';
168 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 169
         	//$last_exec['vatsimtxt'] = 0;
170 170
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
171
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
172 172
         	//$formats[$id] = 'aircraftlistjson';
173 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 174
         	//$last_exec['aircraftlistjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/opensky/i',$host)) {
176
+    	    } else if (preg_match('/opensky/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftlistjson';
178 178
         	$globalSources[$id]['format'] = 'opensky';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         	    exit(0);
191 191
         	}
192 192
     	    */
193
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
193
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
194 194
         	//$formats[$id] = 'planeupdatefaa';
195 195
         	$globalSources[$id]['format'] = 'planeupdatefaa';
196 196
         	//$last_exec['planeupdatefaa'] = 0;
@@ -199,32 +199,32 @@  discard block
 block discarded – undo
199 199
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200 200
         	    exit(0);
201 201
         	}
202
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
202
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
203 203
         	//$formats[$id] = 'phpvmacars';
204 204
         	$globalSources[$id]['format'] = 'phpvmacars';
205 205
         	//$last_exec['phpvmacars'] = 0;
206 206
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
207
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
207
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
208 208
         	//$formats[$id] = 'phpvmacars';
209 209
         	$globalSources[$id]['format'] = 'vam';
210 210
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
211
-            } else if (preg_match('/whazzup/i',$host)) {
211
+            } else if (preg_match('/whazzup/i', $host)) {
212 212
         	//$formats[$id] = 'whazzup';
213 213
         	$globalSources[$id]['format'] = 'whazzup';
214 214
         	//$last_exec['whazzup'] = 0;
215 215
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
216
-            } else if (preg_match('/blitzortung/i',$host)) {
216
+            } else if (preg_match('/blitzortung/i', $host)) {
217 217
         	$globalSources[$id]['format'] = 'blitzortung';
218 218
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
219
-            } else if (preg_match('/airwhere/i',$host)) {
219
+            } else if (preg_match('/airwhere/i', $host)) {
220 220
         	$globalSources[$id]['format'] = 'airwhere';
221 221
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
222
-            } else if (preg_match('/recentpireps/i',$host)) {
222
+            } else if (preg_match('/recentpireps/i', $host)) {
223 223
         	//$formats[$id] = 'pirepsjson';
224 224
         	$globalSources[$id]['format'] = 'pirepsjson';
225 225
         	//$last_exec['pirepsjson'] = 0;
226 226
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
227
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
227
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
228 228
         	//$formats[$id] = 'fr24json';
229 229
         	$globalSources[$id]['format'] = 'fr24json';
230 230
         	//$last_exec['fr24json'] = 0;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
234 234
         	    exit(0);
235 235
         	}
236
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
236
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
237 237
         	//$formats[$id] = 'fr24json';
238 238
         	$globalSources[$id]['format'] = 'myshiptracking';
239 239
         	//$last_exec['fr24json'] = 0;
@@ -243,22 +243,22 @@  discard block
 block discarded – undo
243 243
         	    exit(0);
244 244
         	}
245 245
             //} else if (preg_match('/10001/',$host)) {
246
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
246
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
247 247
         	//$formats[$id] = 'tsv';
248 248
         	$globalSources[$id]['format'] = 'tsv';
249 249
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
250 250
             }
251
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
251
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
252 252
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
253
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
253
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
254 254
     		    if ($idf !== false) {
255 255
     			$httpfeeds[$id] = $idf;
256 256
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
257 257
     		    }
258 258
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
259 259
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
260
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
261
-	    $hostport = explode(':',$host);
260
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
261
+	    $hostport = explode(':', $host);
262 262
 	    if (isset($hostport[1])) {
263 263
 		$port = $hostport[1];
264 264
 		$hostn = $hostport[0];
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
 	    }
269 269
 	    $Common = new Common();
270 270
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
271
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
271
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
272 272
     	    } else {
273
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
273
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
274 274
 	    }
275 275
 	    if ($s) {
276 276
     	        $sockets[$id] = $s;
277 277
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
278
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
278
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
279 279
 			//$formats[$id] = 'aprs';
280 280
 			$globalSources[$id]['format'] = 'aprs';
281 281
 			//$aprs_connect = 0;
282 282
 			//$use_aprs = true;
283
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
283
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
284 284
 			$globalSources[$id]['format'] = 'vrstcp';
285 285
     		    } elseif ($port == '10001') {
286 286
         		//$formats[$id] = 'tsv';
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
320 320
 else $timeout = 20;
321 321
 $errno = '';
322
-$errstr='';
322
+$errstr = '';
323 323
 
324 324
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
325 325
 /* Initiate connections to all the hosts simultaneously */
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 //connect_all($globalSources);
328 328
 
329 329
 if (isset($globalProxy) && $globalProxy) {
330
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
330
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
331 331
 } else {
332 332
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
333 333
 }
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 
358 358
 if ($use_aprs) {
359 359
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
360
-	$APRS=new APRS();
360
+	$APRS = new APRS();
361 361
 	$aprs_connect = 0;
362 362
 	$aprs_keep = 120;
363 363
 	$aprs_last_tx = time();
364 364
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
365
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
365
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
366 366
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
367
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
367
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
368 368
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
369
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
369
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
370 370
 	if ($aprs_full) $aprs_filter = '';
371 371
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
372 372
 	else $aprs_pass = '-1';
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
 sleep(1);
381 381
 if ($globalDebug) echo "SCAN MODE \n\n";
382 382
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
383
-$endtime = time()+$globalCronEnd;
383
+$endtime = time() + $globalCronEnd;
384 384
 $i = 1;
385 385
 $tt = array();
386 386
 // Delete all ATC
387 387
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
388
-	$ATC=new ATC($Connection->db);
388
+	$ATC = new ATC($Connection->db);
389 389
 }
390 390
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
391 391
 	$ATC->deleteAll();
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 
394 394
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
395 395
 while ($i > 0) {
396
-    if (!$globalDaemon) $i = $endtime-time();
396
+    if (!$globalDaemon) $i = $endtime - time();
397 397
     // Delete old ATC
398 398
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
399 399
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	}
408 408
 	if ($max != $globalMinFetch) {
409 409
 	    if ($globalDebug) echo 'Sleeping...'."\n";
410
-	    sleep($globalMinFetch-$max+2);
410
+	    sleep($globalMinFetch - $max + 2);
411 411
 	}
412 412
     }
413 413
 
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 	    //$buffer = $Common->getData($hosts[$id]);
427 427
 	    $buffer = $Common->getData($value['host']);
428 428
 	    if ($buffer != '') $reset = 0;
429
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
430
-	    $buffer = explode('\n',$buffer);
429
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
430
+	    $buffer = explode('\n', $buffer);
431 431
 	    foreach ($buffer as $line) {
432 432
     		if ($line != '' && count($line) > 7) {
433 433
     		    $line = explode(',', $line);
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
 	    )
461 461
 	) {
462 462
 	    date_default_timezone_set('CET');
463
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
463
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
464 464
 	    date_default_timezone_set('UTC');
465 465
 	    if ($buffer != '') $reset = 0;
466
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
467
-	    $buffer = explode('\n',$buffer);
466
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
467
+	    $buffer = explode('\n', $buffer);
468 468
 	    foreach ($buffer as $line) {
469 469
 		if ($line != '') {
470 470
 		    //echo "'".$line."'\n";
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
483 483
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
484 484
 		    if (isset($ais_data['timestamp'])) {
485
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
485
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
486 486
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
487 487
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
488 488
 			    $add = true;
@@ -505,12 +505,12 @@  discard block
 block discarded – undo
505 505
 	    $w = $e = null;
506 506
 	    
507 507
 	    if (isset($arr[$id])) {
508
-		$nn = stream_select($arr,$w,$e,$timeout);
508
+		$nn = stream_select($arr, $w, $e, $timeout);
509 509
 		if ($nn > 0) {
510 510
 		    foreach ($httpfeeds as $feed) {
511
-			$buffer = stream_get_line($feed,2000,"\n");
512
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
513
-			$buffer = explode('\n',$buffer);
511
+			$buffer = stream_get_line($feed, 2000, "\n");
512
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
513
+			$buffer = explode('\n', $buffer);
514 514
 			foreach ($buffer as $line) {
515 515
 			    if ($line != '') {
516 516
 				$ais_data = $AIS->parse_line(trim($line));
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
529 529
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
530 530
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
531
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
531
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
532 532
 				if (isset($ais_data['timestamp'])) {
533
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
533
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
534 534
 				} else {
535 535
 				    $data['datetime'] = date('Y-m-d H:i:s');
536 536
 				}
@@ -561,10 +561,10 @@  discard block
 block discarded – undo
561 561
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
562 562
 	    )
563 563
 	) {
564
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
564
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
565 565
 	    if ($buffer != '') {
566 566
 		//echo $buffer;
567
-		$all_data = json_decode($buffer,true);
567
+		$all_data = json_decode($buffer, true);
568 568
 		//print_r($all_data);
569 569
 		if (isset($all_data[0]['DATA'])) {
570 570
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 			    $data['ident'] = $line['NAME'];
574 574
 			    $data['mmsi'] = $line['MMSI'];
575 575
 			    if (strlen($data['mmsi']) > 9) {
576
-				$data['mmsi'] = substr($data['mmsi'],-9);
576
+				$data['mmsi'] = substr($data['mmsi'], -9);
577 577
 			    }
578 578
 			    $data['speed'] = $line['SOG'];
579 579
 			    $data['heading'] = $line['COG'];
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
583 583
 			    $data['imo'] = $line['IMO'];
584 584
 			    //$data['arrival_code'] = $ais_data['destination'];
585
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
585
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
586 586
 			    $data['format_source'] = 'myshiptracking';
587 587
 			    $data['id_source'] = $id_source;
588 588
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -599,9 +599,9 @@  discard block
 block discarded – undo
599 599
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
600 600
 	    )
601 601
 	) {
602
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
602
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
603 603
 	    if ($buffer != '') {
604
-		$all_data = json_decode($buffer,true);
604
+		$all_data = json_decode($buffer, true);
605 605
 		if (isset($all_data[0]['mmsi'])) {
606 606
 		    foreach ($all_data as $line) {
607 607
 			if ($line != '') {
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	) {
636 636
 	    $buffer = $Common->getData($value['host']);
637 637
 	    if ($buffer != '') {
638
-		$all_data = json_decode($buffer,true);
638
+		$all_data = json_decode($buffer, true);
639 639
 		if (isset($all_data['features'][0]['id'])) {
640 640
 		    foreach ($all_data['features'] as $line) {
641 641
 			$data = array();
@@ -668,27 +668,27 @@  discard block
 block discarded – undo
668 668
 	    )
669 669
 	) {
670 670
 	    echo 'download...';
671
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
671
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
672 672
 	    echo 'done !'."\n";
673 673
 	    if ($buffer != '') $reset = 0;
674
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
675
-	    $buffer = explode('\n',$buffer);
674
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
675
+	    $buffer = explode('\n', $buffer);
676 676
 	    foreach ($buffer as $line) {
677 677
 		if ($line != '') {
678 678
 		    $data = array();
679
-		    $data['mmsi'] = (int)substr($line,0,9);
680
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
679
+		    $data['mmsi'] = (int) substr($line, 0, 9);
680
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
681 681
 		    //$data['status'] = substr($line,21,2);
682 682
 		    //$data['type'] = substr($line,24,3);
683
-		    $data['latitude'] = substr($line,29,9);
684
-		    $data['longitude'] = substr($line,41,9);
685
-		    $data['speed'] = round(substr($line,51,5));
683
+		    $data['latitude'] = substr($line, 29, 9);
684
+		    $data['longitude'] = substr($line, 41, 9);
685
+		    $data['speed'] = round(substr($line, 51, 5));
686 686
 		    //$data['course'] = substr($line,57,5);
687
-		    $data['heading'] = round(substr($line,63,3));
687
+		    $data['heading'] = round(substr($line, 63, 3));
688 688
 		    //$data['draft'] = substr($line,67,4);
689 689
 		    //$data['length'] = substr($line,72,3);
690 690
 		    //$data['beam'] = substr($line,76,2);
691
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
691
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
692 692
 		    //$data['callsign'] = trim(substr($line,100,7);
693 693
 		    //$data['dest'] = substr($line,108,20);
694 694
 		    //$data['etaDate'] = substr($line,129,5);
@@ -721,8 +721,8 @@  discard block
 block discarded – undo
721 721
 	) {
722 722
 	    //$buffer = $Common->getData($hosts[$id]);
723 723
 	    $buffer = $Common->getData($value['host']);
724
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
725
-	    $buffer = explode('\n',$buffer);
724
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
725
+	    $buffer = explode('\n', $buffer);
726 726
 	    $reset = 0;
727 727
 	    foreach ($buffer as $line) {
728 728
     		if ($line != '') {
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
734 734
 			$data['pilot_id'] = $line[1];
735 735
 			$data['pilot_name'] = $line[2];
736
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
736
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
737 737
 			$data['ident'] = $line[0]; // ident
738 738
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
739 739
 			$data['speed'] = $line[8]; // speed
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
750 750
 			//if (isset($line[37])) $data['last_update'] = $line[37];
751 751
 		        $data['departure_airport_icao'] = $line[11];
752
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
752
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
753 753
 		        $data['arrival_airport_icao'] = $line[13];
754 754
 			$data['frequency'] = $line[4];
755 755
 			$data['type'] = $line[18];
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
     			$data['id_source'] = $id_source;
759 759
 	    		//$data['arrival_airport_time'] = ;
760 760
 	    		if ($line[9] != '') {
761
-	    		    $aircraft_data = explode('/',$line[9]);
761
+	    		    $aircraft_data = explode('/', $line[9]);
762 762
 	    		    if (isset($aircraft_data[1])) {
763 763
 	    			$data['aircraft_icao'] = $aircraft_data[1];
764 764
 	    		    }
@@ -773,9 +773,9 @@  discard block
 block discarded – undo
773 773
     			if ($line[3] == 'PILOT') $SI->add($data);
774 774
 			elseif ($line[3] == 'ATC') {
775 775
 				//print_r($data);
776
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
777
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
778
-				$typec = substr($data['ident'],-3);
776
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
777
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
778
+				$typec = substr($data['ident'], -3);
779 779
 				if ($typec == 'APP') $data['type'] = 'Approach';
780 780
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
781 781
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
788 788
 				if (!isset($data['source_name'])) $data['source_name'] = '';
789 789
 				if (isset($ATC)) {
790
-					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']);
791
-					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']);
790
+					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']);
791
+					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']);
792 792
 				}
793 793
 			}
794 794
     			unset($data);
@@ -804,24 +804,24 @@  discard block
 block discarded – undo
804 804
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
805 805
     	    )
806 806
     	) {
807
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
807
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
808 808
 	    if ($buffer != '') {
809 809
 		$all_data = simplexml_load_string($buffer);
810
-		foreach($all_data->children() as $childdata) {
810
+		foreach ($all_data->children() as $childdata) {
811 811
 			$data = array();
812 812
 			$line = $childdata;
813 813
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
814
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
815
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
816
-			$data['latitude'] = (float)$line['pktLatitude'];
817
-			$data['longitude'] = (float)$line['pktLongitude'];
818
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
819
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
820
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
814
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
815
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
816
+			$data['latitude'] = (float) $line['pktLatitude'];
817
+			$data['longitude'] = (float) $line['pktLongitude'];
818
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
819
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
820
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
821 821
 			$data['altitude_relative'] = 'AMSL';
822
-			$data['pilot_id'] = (int)$line['pktPilotID'];
822
+			$data['pilot_id'] = (int) $line['pktPilotID'];
823 823
 			$data['aircraft_icao'] = 'PARAGLIDER';
824
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
824
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
825 825
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
826 826
 			$data['format_source'] = $value['format'];
827 827
 			$SI->add($data);
@@ -829,22 +829,22 @@  discard block
 block discarded – undo
829 829
 		}
830 830
 	    }
831 831
 	    $Source->deleteOldLocationByType('gs');
832
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
832
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
833 833
 	    if ($buffer != '') {
834 834
 		$all_data = simplexml_load_string($buffer);
835
-		foreach($all_data->children() as $childdata) {
835
+		foreach ($all_data->children() as $childdata) {
836 836
 			$data = array();
837 837
 			$line = $childdata;
838
-			$data['id'] = (int)$line['gsID'];
839
-			$data['latitude'] = (float)$line['gsLatitude'];
840
-			$data['longitude'] = (float)$line['gsLongitude'];
841
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
838
+			$data['id'] = (int) $line['gsID'];
839
+			$data['latitude'] = (float) $line['gsLatitude'];
840
+			$data['longitude'] = (float) $line['gsLongitude'];
841
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
842 842
 			$data['altitude_relative'] = 'AMSL';
843
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
843
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
844 844
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
845
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
845
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
846 846
 			} else {
847
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
847
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
848 848
 			}
849 849
 			unset($data);
850 850
 		}
@@ -862,9 +862,9 @@  discard block
 block discarded – undo
862 862
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
863 863
 	    )
864 864
 	) {
865
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
865
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
866 866
 	    if ($buffer != '') {
867
-	        $all_data = json_decode($buffer,true);
867
+	        $all_data = json_decode($buffer, true);
868 868
 		if (isset($all_data['acList'])) {
869 869
 		    $reset = 0;
870 870
 		    foreach ($all_data['acList'] as $line) {
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
881 881
 			$data['emergency'] = ''; // emergency
882 882
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
883
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
883
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
884 884
 			else $data['datetime'] = date('Y-m-d H:i:s');
885 885
 			//$data['datetime'] = date('Y-m-d H:i:s');
886 886
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 			$data['verticalrate'] = $line['vrt']; // verticale rate
906 906
 			$data['squawk'] = $line['squawk']; // squawk
907 907
 			$data['emergency'] = ''; // emergency
908
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
908
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
909 909
 			else $data['datetime'] = date('Y-m-d H:i:s');
910 910
 			$data['format_source'] = 'aircraftlistjson';
911 911
 			$data['id_source'] = $id_source;
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
     	    )
927 927
     	) {
928 928
 	    $buffer = $Common->getData($value['host']);
929
-	    $all_data = json_decode($buffer,true);
929
+	    $all_data = json_decode($buffer, true);
930 930
 	    if (isset($all_data['planes'])) {
931 931
 		$reset = 0;
932 932
 		foreach ($all_data['planes'] as $key => $line) {
@@ -943,12 +943,12 @@  discard block
 block discarded – undo
943 943
 		    $data['emergency'] = ''; // emergency
944 944
 		    $data['registration'] = $line[2];
945 945
 		    $data['aircraft_icao'] = $line[0];
946
-		    $deparr = explode('-',$line[1]);
946
+		    $deparr = explode('-', $line[1]);
947 947
 		    if (count($deparr) == 2) {
948 948
 			$data['departure_airport_icao'] = $deparr[0];
949 949
 			$data['arrival_airport_icao'] = $deparr[1];
950 950
 		    }
951
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
951
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
952 952
 	    	    $data['format_source'] = 'planeupdatefaa';
953 953
     		    $data['id_source'] = $id_source;
954 954
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 	    )
967 967
 	) {
968 968
 	    $buffer = $Common->getData($value['host']);
969
-	    $all_data = json_decode($buffer,true);
969
+	    $all_data = json_decode($buffer, true);
970 970
 	    if (isset($all_data['states'])) {
971 971
 		$reset = 0;
972 972
 		foreach ($all_data['states'] as $key => $line) {
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 		    //$data['emergency'] = ''; // emergency
984 984
 		    //$data['registration'] = $line[2];
985 985
 		    //$data['aircraft_icao'] = $line[0];
986
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
986
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
987 987
 		    $data['format_source'] = 'opensky';
988 988
 		    $data['id_source'] = $id_source;
989 989
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 	) {
1003 1003
 	    //$buffer = $Common->getData($hosts[$id]);
1004 1004
 	    $buffer = $Common->getData($value['host']);
1005
-	    $all_data = json_decode($buffer,true);
1005
+	    $all_data = json_decode($buffer, true);
1006 1006
 	    if (!empty($all_data)) $reset = 0;
1007 1007
 	    foreach ($all_data as $key => $line) {
1008 1008
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1040,11 +1040,11 @@  discard block
 block discarded – undo
1040 1040
 	    )
1041 1041
 	) {
1042 1042
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1043
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1043
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1044 1044
 	    //echo $buffer;
1045
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1046
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1047
-	    $all_data = json_decode($buffer,true);
1045
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1046
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1047
+	    $all_data = json_decode($buffer, true);
1048 1048
 	    if (json_last_error() != JSON_ERROR_NONE) {
1049 1049
 		die(json_last_error_msg());
1050 1050
 	    }
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 			//$data['departure_airport_iata'] = $line[11];
1068 1068
 			//$data['arrival_airport_iata'] = $line[12];
1069 1069
 	    		//$data['emergency'] = ''; // emergency
1070
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1070
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1071 1071
 	    		$data['format_source'] = 'radarvirtueljson';
1072 1072
     			$data['id_source'] = $id_source;
1073 1073
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1088,14 +1088,14 @@  discard block
 block discarded – undo
1088 1088
 	) {
1089 1089
 	    //$buffer = $Common->getData($hosts[$id]);
1090 1090
 	    $buffer = $Common->getData($value['host'].'?'.time());
1091
-	    $all_data = json_decode(utf8_encode($buffer),true);
1091
+	    $all_data = json_decode(utf8_encode($buffer), true);
1092 1092
 	    
1093 1093
 	    if (isset($all_data['pireps'])) {
1094 1094
 		$reset = 0;
1095 1095
 	        foreach ($all_data['pireps'] as $line) {
1096 1096
 		    $data = array();
1097 1097
 		    $data['id'] = $line['id'];
1098
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1098
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1099 1099
 		    $data['ident'] = $line['callsign']; // ident
1100 1100
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1101 1101
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1125,9 +1125,9 @@  discard block
 block discarded – undo
1125 1125
 			$SI->add($data);
1126 1126
 		    //    print_r($data);
1127 1127
     		    } elseif ($line['icon'] == 'ct') {
1128
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1129
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1130
-			$typec = substr($data['ident'],-3);
1128
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1129
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1130
+			$typec = substr($data['ident'], -3);
1131 1131
 			$data['type'] = '';
1132 1132
 			if ($typec == 'APP') $data['type'] = 'Approach';
1133 1133
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1139 1139
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1140 1140
 			else $data['type'] = 'Observer';
1141
-			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']);
1141
+			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']);
1142 1142
 		    }
1143 1143
 		    unset($data);
1144 1144
 		}
@@ -1155,14 +1155,14 @@  discard block
 block discarded – undo
1155 1155
 	    //$buffer = $Common->getData($hosts[$id]);
1156 1156
 	    if ($globalDebug) echo 'Get Data...'."\n";
1157 1157
 	    $buffer = $Common->getData($value['host']);
1158
-	    $all_data = json_decode($buffer,true);
1158
+	    $all_data = json_decode($buffer, true);
1159 1159
 	    if ($buffer != '' && is_array($all_data)) {
1160 1160
 		$reset = 0;
1161 1161
 		foreach ($all_data as $line) {
1162 1162
 	    	    $data = array();
1163 1163
 	    	    //$data['id'] = $line['id']; // id not usable
1164 1164
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1165
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1165
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1166 1166
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1167 1167
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1168 1168
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 	    	    //$data['datetime'] = $line['lastupdate'];
1178 1178
 	    	    //$data['last_update'] = $line['lastupdate'];
1179 1179
 	    	    if (isset($value['timezone'])) {
1180
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1180
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1181 1181
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1182 1182
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1183 1183
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1190,14 +1190,14 @@  discard block
 block discarded – undo
1190 1190
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1191 1191
 		    if (isset($line['aircraftname'])) {
1192 1192
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1193
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1194
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1193
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1194
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1195 1195
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1196 1196
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1197 1197
 	    		else {
1198
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1199
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1200
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1198
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1199
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1200
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1201 1201
 	    		}
1202 1202
 	    	    }
1203 1203
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1222,14 +1222,14 @@  discard block
 block discarded – undo
1222 1222
 	    //$buffer = $Common->getData($hosts[$id]);
1223 1223
 	    if ($globalDebug) echo 'Get Data...'."\n";
1224 1224
 	    $buffer = $Common->getData($value['host']);
1225
-	    $all_data = json_decode($buffer,true);
1225
+	    $all_data = json_decode($buffer, true);
1226 1226
 	    if ($buffer != '' && is_array($all_data)) {
1227 1227
 		$reset = 0;
1228 1228
 		foreach ($all_data as $line) {
1229 1229
 	    	    $data = array();
1230 1230
 	    	    //$data['id'] = $line['id']; // id not usable
1231 1231
 	    	    $data['id'] = trim($line['flight_id']);
1232
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1232
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1233 1233
 	    	    $data['pilot_name'] = $line['pilot_name'];
1234 1234
 	    	    $data['pilot_id'] = $line['pilot_id'];
1235 1235
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1273,24 +1273,24 @@  discard block
 block discarded – undo
1273 1273
 	    //$buffer = $Common->getData($hosts[$id]);
1274 1274
 	    if ($globalDebug) echo 'Get Data...'."\n";
1275 1275
 	    $buffer = $Common->getData($value['host']);
1276
-	    $all_data = json_decode($buffer,true);
1276
+	    $all_data = json_decode($buffer, true);
1277 1277
 	    if ($buffer != '') {
1278 1278
 		$Source->deleteLocationBySource('blitzortung');
1279
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1280
-		$buffer = explode('\n',$buffer);
1279
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1280
+		$buffer = explode('\n', $buffer);
1281 1281
 		foreach ($buffer as $buffer_line) {
1282
-		    $line = json_decode($buffer_line,true);
1282
+		    $line = json_decode($buffer_line, true);
1283 1283
 		    if (isset($line['time'])) {
1284 1284
 			$data = array();
1285 1285
 			$data['altitude'] = $line['alt']; // altitude
1286 1286
 			$data['latitude'] = $line['lat']; // lat
1287 1287
 			$data['longitude'] = $line['lon']; // long
1288
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1288
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1289 1289
 			$data['id_source'] = $id_source;
1290 1290
 			$data['format_source'] = 'blitzortung';
1291 1291
 			$SI->add($data);
1292 1292
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1293
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1293
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1294 1294
 			unset($data);
1295 1295
 		    }
1296 1296
 		}
@@ -1315,11 +1315,11 @@  discard block
 block discarded – undo
1315 1315
 		    //$value = $formats[$nb];
1316 1316
 		    $format = $globalSources[$nb]['format'];
1317 1317
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1318
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1318
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1319 1319
 		    } elseif ($format == 'vrstcp') {
1320 1320
 			$buffer = @socket_read($r, 6000);
1321 1321
 		    } else {
1322
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1322
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1323 1323
 		    }
1324 1324
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1325 1325
 		    //echo $buffer."\n";
@@ -1328,8 +1328,8 @@  discard block
 block discarded – undo
1328 1328
 		    $error = false;
1329 1329
 		    //$SI::del();
1330 1330
 		    if ($format == 'vrstcp') {
1331
-			$buffer = explode('},{',$buffer);
1332
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1331
+			$buffer = explode('},{', $buffer);
1332
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1333 1333
 		    // SBS format is CSV format
1334 1334
 		    if ($buffer !== FALSE && $buffer != '') {
1335 1335
 			$tt[$format] = 0;
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1364 1364
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1365 1365
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1366
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1366
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1367 1367
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1368 1368
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1369 1369
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1370 1370
 
1371 1371
 			    if (isset($ais_data['timestamp'])) {
1372
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1372
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1373 1373
 			    } else {
1374 1374
 				$data['datetime'] = date('Y-m-d H:i:s');
1375 1375
 			    }
@@ -1380,10 +1380,10 @@  discard block
 block discarded – undo
1380 1380
                         } elseif ($format == 'flightgearsp') {
1381 1381
                     	    //echo $buffer."\n";
1382 1382
                     	    if (strlen($buffer) > 5) {
1383
-				$line = explode(',',$buffer);
1383
+				$line = explode(',', $buffer);
1384 1384
 				$data = array();
1385 1385
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1386
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1386
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1387 1387
 				$data['ident'] = $line[6];
1388 1388
 				$data['aircraft_name'] = $line[7];
1389 1389
 				$data['longitude'] = $line[1];
@@ -1400,16 +1400,16 @@  discard block
 block discarded – undo
1400 1400
                         } elseif ($format == 'acars') {
1401 1401
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1402 1402
 			    $ACARS->add(trim($buffer));
1403
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1403
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1404 1404
 			    $ACARS->deleteLiveAcarsData();
1405 1405
 			} elseif ($format == 'flightgearmp') {
1406
-			    if (substr($buffer,0,1) != '#') {
1406
+			    if (substr($buffer, 0, 1) != '#') {
1407 1407
 				$data = array();
1408 1408
 				//echo $buffer."\n";
1409
-				$line = explode(' ',$buffer);
1409
+				$line = explode(' ', $buffer);
1410 1410
 				if (count($line) == 11) {
1411
-				    $userserver = explode('@',$line[0]);
1412
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1411
+				    $userserver = explode('@', $line[0]);
1412
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1413 1413
 				    $data['ident'] = $userserver[0];
1414 1414
 				    $data['registration'] = $userserver[0];
1415 1415
 				    $data['latitude'] = $line[4];
@@ -1417,8 +1417,8 @@  discard block
 block discarded – undo
1417 1417
 				    $data['altitude'] = $line[6];
1418 1418
 				    $data['datetime'] = date('Y-m-d H:i:s');
1419 1419
 				    $aircraft_type = $line[10];
1420
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1421
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1420
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1421
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1422 1422
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1423 1423
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1424 1424
 				}
@@ -1427,8 +1427,8 @@  discard block
 block discarded – undo
1427 1427
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1428 1428
 			    die;
1429 1429
 			} elseif ($format == 'vrstcp') {
1430
-			    foreach($buffer as $all_data) {
1431
-				$line = json_decode('{'.$all_data.'}',true);
1430
+			    foreach ($buffer as $all_data) {
1431
+				$line = json_decode('{'.$all_data.'}', true);
1432 1432
 				$data = array();
1433 1433
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1434 1434
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1454,16 +1454,16 @@  discard block
 block discarded – undo
1454 1454
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1455 1455
 				unset($data);
1456 1456
 			    }
1457
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1457
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1458 1458
 			    $line = explode("\t", $buffer);
1459
-			    for($k = 0; $k < count($line); $k=$k+2) {
1459
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1460 1460
 				$key = $line[$k];
1461
-			        $lined[$key] = $line[$k+1];
1461
+			        $lined[$key] = $line[$k + 1];
1462 1462
 			    }
1463 1463
     			    if (count($lined) > 3) {
1464 1464
     				$data['hex'] = $lined['hexid'];
1465 1465
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1466
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1466
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1467 1467
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1468 1468
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1469 1469
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1482,22 +1482,22 @@  discard block
 block discarded – undo
1482 1482
     			    } else $error = true;
1483 1483
 			} elseif ($format == 'aprs' && $use_aprs) {
1484 1484
 			    if ($aprs_connect == 0) {
1485
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1485
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1486 1486
 				$aprs_connect = 1;
1487 1487
 			    }
1488 1488
 			    
1489
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1489
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1490 1490
 				$aprs_last_tx = time();
1491 1491
 				$data_aprs = "# Keep alive";
1492
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1492
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1493 1493
 			    }
1494 1494
 			    
1495 1495
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1496 1496
 			    //echo 'APRS data : '.$buffer."\n";
1497
-			    $buffer = str_replace('APRS <- ','',$buffer);
1498
-			    $buffer = str_replace('APRS -> ','',$buffer);
1497
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1498
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1499 1499
 			    //echo $buffer."\n";
1500
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1500
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1501 1501
 				$line = $APRS->parse($buffer);
1502 1502
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1503 1503
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1513 1513
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1514 1514
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1515
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1515
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1516 1516
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1517 1517
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1518 1518
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1594,29 +1594,29 @@  discard block
 block discarded – undo
1594 1594
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1595 1595
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1596 1596
 					$Source->deleteOldLocationByType('gs');
1597
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1598
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1597
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1598
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1599 1599
 					} else {
1600
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1600
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1601 1601
 					}
1602 1602
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1603 1603
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1604 1604
 					if ($globalDebug) echo '# Weather Station added'."\n";
1605 1605
 					$Source->deleteOldLocationByType('wx');
1606 1606
 					$weather_data = json_encode($line);
1607
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1608
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1607
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1608
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1609 1609
 					} else {
1610
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1610
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1611 1611
 					}
1612 1612
 				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1613 1613
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1614 1614
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1615 1615
 					$Source->deleteOldLocationByType('lightning');
1616
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1617
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1616
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1617
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1618 1618
 					} else {
1619
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1619
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1620 1620
 					}
1621 1621
 				    } elseif ($globalDebug) {
1622 1622
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 				    unset($data);
1626 1626
 				}
1627 1627
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1628
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1628
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1629 1629
 				}
1630 1630
 				/*
1631 1631
 				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')) {
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 				*/
1635 1635
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1636 1636
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1637
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1637
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1638 1638
 					$Source->deleteOldLocationByType('lightning');
1639 1639
 					$Source->deleteOldLocationByType('wx');
1640 1640
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1719,7 +1719,7 @@  discard block
 block discarded – undo
1719 1719
 				connect_all($sourceee);
1720 1720
 				$sourceee = array();
1721 1721
 				//connect_all($globalSources);
1722
-				$tt[$format]=0;
1722
+				$tt[$format] = 0;
1723 1723
 				break;
1724 1724
 			    }
1725 1725
 			}
@@ -1728,14 +1728,14 @@  discard block
 block discarded – undo
1728 1728
 	    } else {
1729 1729
 		$error = socket_strerror(socket_last_error());
1730 1730
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1731
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1731
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1732 1732
 			if (isset($globalDebug)) echo "Restarting...\n";
1733 1733
 			// Restart the script if possible
1734 1734
 			if (is_array($sockets)) {
1735 1735
 			    if ($globalDebug) echo "Shutdown all sockets...";
1736 1736
 			    
1737 1737
 			    foreach ($sockets as $sock) {
1738
-				@socket_shutdown($sock,2);
1738
+				@socket_shutdown($sock, 2);
1739 1739
 				@socket_close($sock);
1740 1740
 			    }
1741 1741
 			    
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		if (isset($this->all_tracked[$key]['id'])) {
60 60
 		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
61 61
     		    $Marine = new Marine($this->db);
62
-    		    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
62
+    		    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
63 63
 		}
64 64
 	    }
65 65
 	}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
72 72
 	foreach ($this->all_tracked as $key => $flight) {
73 73
     	    if (isset($flight['lastupdate'])) {
74
-        	if ($flight['lastupdate'] < (time()-3000)) {
74
+        	if ($flight['lastupdate'] < (time() - 3000)) {
75 75
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76 76
             		if (isset($this->all_tracked[$key]['id'])) {
77 77
             		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             		    //$real_arrival = $this->arrival($key);
84 84
             		    $Marine = new Marine($this->db);
85 85
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
86
-				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
86
+				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
87 87
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
88 88
 			    }
89 89
 			    // Put in archive
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
     }
98 98
 
99 99
     public function add($line) {
100
-	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
100
+	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine;
101 101
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
102 102
 	date_default_timezone_set('UTC');
103 103
 	$dataFound = false;
104 104
 	$send = false;
105 105
 	
106 106
 	// SBS format is CSV format
107
-	if(is_array($line) && isset($line['mmsi'])) {
107
+	if (is_array($line) && isset($line['mmsi'])) {
108 108
 	    //print_r($line);
109 109
   	    if (isset($line['mmsi'])) {
110 110
 
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 		
130 130
 		if (!isset($this->all_tracked[$id])) {
131 131
 		    $this->all_tracked[$id] = array();
132
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
133
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
134
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
132
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0));
133
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => ''));
134
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
135 135
 		    if (!isset($line['id'])) {
136 136
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
137
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
138
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
137
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
138
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
139 139
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
140 140
 		}
141 141
 		
142 142
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
143
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
143
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
144 144
 		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
145 145
 			$Marine = new Marine($this->db);
146 146
 			$identity = $Marine->getIdentity($line['mmsi']);
@@ -154,64 +154,64 @@  discard block
 block discarded – undo
154 154
 		    }
155 155
 		}
156 156
 		if (isset($line['type_id'])) {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
157
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
158 158
 		}
159 159
 		if (isset($line['type']) && $line['type'] != '') {
160
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
160
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
161 161
 		}
162 162
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
163
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type']));
164 164
 		}
165 165
 		if (isset($line['imo']) && $line['imo'] != '') {
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
166
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
167 167
 		}
168 168
 		if (isset($line['callsign']) && $line['callsign'] != '') {
169
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
169
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
170 170
 		}
171 171
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
172
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
173 173
 		}
174 174
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
175
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
175
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
176 176
 		}
177 177
 
178 178
 
179 179
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
180 180
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
181
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
181
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
182 182
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
183 183
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
184 184
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
185 185
 				$timeelapsed = microtime(true);
186 186
 				$Marine = new Marine($this->db);
187 187
 				$fromsource = NULL;
188
-				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
188
+				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
189 189
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
190 190
 				$Marine->db = null;
191
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
191
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
192 192
 			    }
193 193
 			}
194 194
 		    }
195
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
195
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
196 196
 		}
197 197
 
198
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
198
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
199 199
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
200
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
200
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
201 201
 		    } else {
202 202
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
203 203
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
204 204
 				return '';
205 205
 		    }
206
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
206
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
207 207
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
208 208
 			return '';
209
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
209
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
210 210
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
211 211
 			return '';
212 212
 		} elseif (!isset($line['datetime'])) {
213 213
 			date_default_timezone_set('UTC');
214
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
214
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
215 215
 		} else {
216 216
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
217 217
 			return '';
@@ -219,24 +219,24 @@  discard block
 block discarded – undo
219 219
 
220 220
 
221 221
 		if (isset($line['speed'])) {
222
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
223
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
222
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
223
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
224 224
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
225
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
225
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
226 226
 		    if ($distance > 1000 && $distance < 10000) {
227 227
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
228 228
 			$speed = $speed*3.6;
229
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
229
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
230 230
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
231 231
 		    }
232 232
 		}
233 233
 
234 234
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
235
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
235
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
236 236
 	    	    else unset($timediff);
237
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
237
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
238 238
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
239
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
239
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
240 240
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
241 241
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
242 242
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 				$timeelapsed = microtime(true);
246 246
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
247 247
 				    $Marine = new Marine($this->db);
248
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
248
+				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
249 249
 				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
250 250
 				    $Marine->db = null;
251
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
251
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
252 252
 				}
253 253
 				$this->tmd = 0;
254 254
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
@@ -257,52 +257,52 @@  discard block
 block discarded – undo
257 257
 
258 258
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
259 259
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
260
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
260
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
261 261
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
262 262
 				    $dataFound = true;
263 263
 				    $this->all_tracked[$id]['time_last_coord'] = time();
264 264
 				}
265
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
265
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
266 266
 			}
267 267
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
268 268
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
269 269
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
270
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
270
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
271 271
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
272 272
 				    $dataFound = true;
273 273
 				    $this->all_tracked[$id]['time_last_coord'] = time();
274 274
 				}
275
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
275
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
276 276
 			}
277 277
 
278 278
 		    } else if ($globalDebug && $timediff > 20) {
279 279
 			$this->tmd = $this->tmd + 1;
280 280
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
281
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
282
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
281
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
282
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
283 283
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
284 284
 		    }
285 285
 		}
286 286
 		if (isset($line['last_update']) && $line['last_update'] != '') {
287 287
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
288
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
288
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
289 289
 		}
290 290
 		if (isset($line['format_source']) && $line['format_source'] != '') {
291
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
291
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
292 292
 		}
293 293
 		if (isset($line['source_name']) && $line['source_name'] != '') {
294
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
294
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
295 295
 		}
296 296
 		if (isset($line['status']) && $line['status'] != '') {
297
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
297
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
298 298
 		}
299 299
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
300
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
300
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id']));
301 301
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
302 302
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
303 303
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
304 304
 				$Marine = new Marine($this->db);
305
-				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
305
+				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']);
306 306
 				unset($Marine);
307 307
 			    }
308 308
 			}
@@ -310,18 +310,18 @@  discard block
 block discarded – undo
310 310
 		}
311 311
 
312 312
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
313
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
313
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
314 314
 		}
315 315
 		
316 316
 		if (isset($line['heading']) && $line['heading'] != '') {
317
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
318
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
319
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
317
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
318
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
319
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
320 320
 		    //$dataFound = true;
321 321
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
322
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
323
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
324
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
322
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
323
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
324
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
325 325
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
326 326
   		}
327 327
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
332 332
 		    $this->all_tracked[$id]['lastupdate'] = time();
333 333
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
334
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
334
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
335 335
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
336 336
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
337 337
 				    if ($globalDebug) echo "Check if aircraft is already in DB...";
@@ -339,37 +339,37 @@  discard block
 block discarded – undo
339 339
 				    $MarineLive = new MarineLive($this->db);
340 340
 				    if (isset($line['id'])) {
341 341
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
342
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
342
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
343 343
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
344 344
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
345
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
345
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
346 346
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
347 347
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
348
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
348
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
349 349
 				    } else $recent_ident = '';
350
-				    $MarineLive->db=null;
350
+				    $MarineLive->db = null;
351 351
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
352 352
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
353 353
 				} else $recent_ident = '';
354 354
 			    } else {
355 355
 				$recent_ident = '';
356
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
356
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
357 357
 			    }
358 358
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
359
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
359
+			    if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
360 360
 			    {
361 361
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
362 362
 				//adds the spotter data for the archive
363 363
 				    $highlight = '';
364
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
364
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
365 365
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
366 366
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
367 367
 					    $timeelapsed = microtime(true);
368 368
 					    $Marine = new Marine($this->db);
369
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
369
+					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
370 370
 					    $Marine->db = null;
371 371
 					    if ($globalDebug && isset($result)) echo $result."\n";
372
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
372
+					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
373 373
 					}
374 374
 				    }
375 375
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
 					$Stats = new Stats($this->db);
378 378
 					if (!empty($this->stats)) {
379 379
 					    if ($globalDebug) echo 'Add source stats : ';
380
-				    	    foreach($this->stats as $date => $data) {
381
-						foreach($data as $source => $sourced) {
380
+				    	    foreach ($this->stats as $date => $data) {
381
+						foreach ($data as $source => $sourced) {
382 382
 					    	    //print_r($sourced);
383
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
384
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
383
+				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date);
384
+				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date);
385 385
 				    		    if (isset($sourced['msg'])) {
386 386
 				    			if (time() - $sourced['msg']['date'] > 10) {
387 387
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
388
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
388
+				    		    	    echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date);
389 389
 			    			    	    unset($this->stats[$date][$source]['msg']);
390 390
 			    				}
391 391
 			    			    }
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
410 410
 					$MarineLive = new MarineLive($this->db);
411 411
 					$MarineLive->deleteLiveMarineData();
412
-					$MarineLive->db=null;
412
+					$MarineLive->db = null;
413 413
 					if ($globalDebug) echo " Done\n";
414 414
 				    }
415 415
 				    $this->last_delete = time();
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
421 421
 				    if (isset($globalDaemon) && !$globalDaemon) {
422 422
 					$Marine = new Marine($this->db);
423
-					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
423
+					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
424 424
 					$Marine->db = null;
425 425
 				    }
426 426
 				}
@@ -435,20 +435,20 @@  discard block
 block discarded – undo
435 435
 		    $ignoreImport = false;
436 436
 
437 437
 		    if (!$ignoreImport) {
438
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
438
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
439 439
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
440 440
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
441 441
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
442 442
 					$timeelapsed = microtime(true);
443 443
 					$MarineLive = new MarineLive($this->db);
444
-					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
444
+					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
445 445
 					$MarineLive->db = null;
446 446
 					if ($globalDebug) echo $result."\n";
447
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
447
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
448 448
 				    }
449 449
 				}
450 450
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
451
-				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
451
+				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
452 452
 				}
453 453
 				$this->all_tracked[$id]['putinarchive'] = false;
454 454
 
@@ -467,19 +467,19 @@  discard block
 block discarded – undo
467 467
 							$latitude = $globalCenterLatitude;
468 468
 							$longitude = $globalCenterLongitude;
469 469
 						}
470
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
470
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
471 471
 					} else {
472 472
 						$latitude = $this->source_location[$source]['latitude'];
473 473
 						$longitude = $this->source_location[$source]['longitude'];
474 474
 					}
475
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
475
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
476 476
 					//$stats_heading = $stats_heading%22.5;
477 477
 					$stats_heading = round($stats_heading/22.5);
478
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
478
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
479 479
 					$current_date = date('Y-m-d');
480 480
 					if ($stats_heading == 16) $stats_heading = 0;
481 481
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
482
-						for ($i=0;$i<=15;$i++) {
482
+						for ($i = 0; $i <= 15; $i++) {
483 483
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
484 484
 						}
485 485
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -494,9 +494,9 @@  discard block
 block discarded – undo
494 494
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
495 495
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
496 496
 						    end($this->stats[$current_date][$source]['hist']);
497
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
497
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
498 498
 						} else $mini = 0;
499
-						for ($i=$mini;$i<=$distance;$i+=10) {
499
+						for ($i = $mini; $i <= $distance; $i += 10) {
500 500
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
501 501
 						}
502 502
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 
509 509
 				$this->all_tracked[$id]['lastupdate'] = time();
510 510
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
511
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
511
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
512 512
 			//$this->del();
513 513
 			
514 514
 			
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
39
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
41
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
73 73
 				}
74 74
 			}
75
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
75
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
76 76
 		}
77 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
79 79
 		}
80 80
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81 81
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
82 82
 		if ($filter_query_where != '') {
83
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
84 84
 		}
85 85
 		$filter_query = $filter_query_join.$filter_query_where;
86 86
 		return $filter_query;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 		if ($limit != '')
104 104
 		{
105 105
 			$limit_array = explode(',', $limit);
106
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
107
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
107
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
108 108
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
109 109
 			{
110 110
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
120 120
 			}
121 121
 		}
122
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
122
+		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
123 123
 
124 124
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
125 125
 		if ($globalDBdriver == 'mysql') {
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		} else {
129 129
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
130 130
 		}
131
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
131
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
132 132
 
133 133
 		return $spotter_array;
134 134
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		global $globalDBdriver, $globalLiveInterval;
145 145
 		date_default_timezone_set('UTC');
146 146
 
147
-		$filter_query = $this->getFilter($filter,true,true);
147
+		$filter_query = $this->getFilter($filter, true, true);
148 148
 
149 149
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
150 150
 		if ($globalDBdriver == 'mysql') {
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		try {
159 159
 			$sth = $this->db->prepare($query);
160 160
 			$sth->execute();
161
-		} catch(PDOException $e) {
161
+		} catch (PDOException $e) {
162 162
 			echo $e->getMessage();
163 163
 			die;
164 164
 		}
@@ -173,19 +173,19 @@  discard block
 block discarded – undo
173 173
 	* @return Array the spotter information
174 174
 	*
175 175
 	*/
176
-	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false)
176
+	public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false)
177 177
 	{
178 178
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
179 179
 		date_default_timezone_set('UTC');
180 180
 		$usecoord = false;
181 181
 		if (is_array($coord) && !empty($coord)) {
182
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
183
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
184
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
185
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
182
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
183
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
184
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
185
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
186 186
 			$usecoord = true;
187 187
 		}
188
-		$filter_query = $this->getFilter($filter,true,true);
188
+		$filter_query = $this->getFilter($filter, true, true);
189 189
 
190 190
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
191 191
 		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		try {
235 235
 			$sth = $this->db->prepare($query);
236 236
 			$sth->execute();
237
-		} catch(PDOException $e) {
237
+		} catch (PDOException $e) {
238 238
 			echo $e->getMessage();
239 239
 			die;
240 240
 		}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	public function getLiveMarineCount($filter = array())
252 252
 	{
253 253
 		global $globalDBdriver, $globalLiveInterval;
254
-		$filter_query = $this->getFilter($filter,true,true);
254
+		$filter_query = $this->getFilter($filter, true, true);
255 255
 
256 256
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
257 257
 		if ($globalDBdriver == 'mysql') {
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 		try {
263 263
 			$sth = $this->db->prepare($query);
264 264
 			$sth->execute();
265
-		} catch(PDOException $e) {
265
+		} catch (PDOException $e) {
266 266
 			echo $e->getMessage();
267 267
 			die;
268 268
 		}
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 		$filter_query = $this->getFilter($filter);
286 286
 
287 287
 		if (is_array($coord)) {
288
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
289
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
290
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
291
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
288
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
289
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
290
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
291
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
292 292
 		} else return array();
293 293
 		if ($globalDBdriver == 'mysql') {
294 294
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 		$filter_query = $this->getFilter($filter);
314 314
 
315 315
 		if (is_array($coord)) {
316
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
317
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
318
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
319
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
316
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
317
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
318
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
319
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
320 320
 		} else return array();
321 321
 		/*
322 322
 		if ($globalDBdriver == 'mysql') {
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
 		*/
332 332
 		if ($globalDBdriver == 'mysql') {
333 333
 			if (isset($globalArchive) && $globalArchive === TRUE) {
334
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
334
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
335 335
 				    FROM marine_live 
336 336
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date 
337 337
 				    AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
338 338
 				    AND marine_live.latitude <> 0 AND marine_live.longitude <> 0';
339 339
 			} else {
340
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
340
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
341 341
 				    FROM marine_live 
342 342
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
343 343
 				    FROM marine_live l 
@@ -349,14 +349,14 @@  discard block
 block discarded – undo
349 349
 			}
350 350
 		} else {
351 351
 			if (isset($globalArchive) && $globalArchive === TRUE) {
352
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
352
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
353 353
 				    FROM marine_live 
354 354
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date 
355 355
 				    AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
356 356
 				    AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
357 357
 				    AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'";
358 358
 			} else {
359
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
359
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
360 360
 				    FROM marine_live 
361 361
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
362 362
 				    FROM marine_live l 
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                 if ($interval == '1m')
414 414
                 {
415 415
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
416
-                } else if ($interval == '15m'){
416
+                } else if ($interval == '15m') {
417 417
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
418 418
                 } 
419 419
             }
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
422 422
         }
423 423
 
424
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
424
+                $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
425 425
                    WHERE marine_live.latitude <> '' 
426 426
                                    AND marine_live.longitude <> '' 
427 427
                    ".$additional_query."
428 428
                    HAVING distance < :radius  
429 429
                                    ORDER BY distance";
430 430
 
431
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
431
+                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
432 432
 
433 433
                 return $spotter_array;
434 434
         }
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
 		date_default_timezone_set('UTC');
447 447
 
448 448
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
449
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
449
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
450 450
 
451
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
451
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
452 452
 
453 453
 		return $spotter_array;
454 454
 	}
@@ -459,16 +459,16 @@  discard block
 block discarded – undo
459 459
 	* @return Array the spotter information
460 460
 	*
461 461
 	*/
462
-	public function getDateLiveMarineDataByIdent($ident,$date)
462
+	public function getDateLiveMarineDataByIdent($ident, $date)
463 463
 	{
464 464
 		$Marine = new Marine($this->db);
465 465
 		date_default_timezone_set('UTC');
466 466
 
467 467
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
468
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
468
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
469 469
 
470
-                $date = date('c',$date);
471
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
470
+                $date = date('c', $date);
471
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
472 472
 
473 473
 		return $spotter_array;
474 474
 	}
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 		date_default_timezone_set('UTC');
486 486
 
487 487
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
488
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
488
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
489 489
 
490
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
490
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
491 491
 
492 492
 		return $spotter_array;
493 493
 	}
@@ -498,15 +498,15 @@  discard block
 block discarded – undo
498 498
 	* @return Array the spotter information
499 499
 	*
500 500
 	*/
501
-	public function getDateLiveMarineDataById($id,$date)
501
+	public function getDateLiveMarineDataById($id, $date)
502 502
 	{
503 503
 		$Marine = new Marine($this->db);
504 504
 		date_default_timezone_set('UTC');
505 505
 
506 506
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
507
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
508
-                $date = date('c',$date);
509
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
507
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
508
+                $date = date('c', $date);
509
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
510 510
 
511 511
 		return $spotter_array;
512 512
 	}
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	* @return Array the spotter information
519 519
 	*
520 520
 	*/
521
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
521
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
522 522
 	{
523 523
 		global $globalDBdriver, $globalLiveInterval;
524 524
 		date_default_timezone_set('UTC');
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 		try {
538 538
 			$sth = $this->db->prepare($query);
539 539
 			$sth->execute(array(':id' => $id));
540
-		} catch(PDOException $e) {
540
+		} catch (PDOException $e) {
541 541
 			echo $e->getMessage();
542 542
 			die;
543 543
 		}
@@ -555,12 +555,12 @@  discard block
 block discarded – undo
555 555
 	{
556 556
 		date_default_timezone_set('UTC');
557 557
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
558
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
558
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
559 559
     		try {
560 560
 			
561 561
 			$sth = $this->db->prepare($query);
562 562
 			$sth->execute(array(':ident' => $ident));
563
-		} catch(PDOException $e) {
563
+		} catch (PDOException $e) {
564 564
 			echo $e->getMessage();
565 565
 			die;
566 566
 		}
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			
591 591
 			$sth = $this->db->prepare($query);
592 592
 			$sth->execute();
593
-		} catch(PDOException $e) {
593
+		} catch (PDOException $e) {
594 594
 			return "error";
595 595
 		}
596 596
 
@@ -613,14 +613,14 @@  discard block
 block discarded – undo
613 613
 				
614 614
 				$sth = $this->db->prepare($query);
615 615
 				$sth->execute();
616
-			} catch(PDOException $e) {
616
+			} catch (PDOException $e) {
617 617
 				return "error";
618 618
 			}
619 619
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
620 620
                         $i = 0;
621
-                        $j =0;
621
+                        $j = 0;
622 622
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
623
-			foreach($all as $row)
623
+			foreach ($all as $row)
624 624
 			{
625 625
 				$i++;
626 626
 				$j++;
@@ -628,9 +628,9 @@  discard block
 block discarded – undo
628 628
 					if ($globalDebug) echo ".";
629 629
 				    	try {
630 630
 						
631
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
631
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
632 632
 						$sth->execute();
633
-					} catch(PDOException $e) {
633
+					} catch (PDOException $e) {
634 634
 						return "error";
635 635
 					}
636 636
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -641,9 +641,9 @@  discard block
 block discarded – undo
641 641
 			if ($i > 0) {
642 642
     				try {
643 643
 					
644
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
644
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
645 645
 					$sth->execute();
646
-				} catch(PDOException $e) {
646
+				} catch (PDOException $e) {
647 647
 					return "error";
648 648
 				}
649 649
 			}
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 				
657 657
 				$sth = $this->db->prepare($query);
658 658
 				$sth->execute();
659
-			} catch(PDOException $e) {
659
+			} catch (PDOException $e) {
660 660
 				return "error";
661 661
 			}
662 662
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -704,13 +704,13 @@  discard block
 block discarded – undo
704 704
 	public function deleteLiveMarineDataByIdent($ident)
705 705
 	{
706 706
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
707
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
707
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
708 708
         
709 709
     		try {
710 710
 			
711 711
 			$sth = $this->db->prepare($query);
712 712
 			$sth->execute(array(':ident' => $ident));
713
-		} catch(PDOException $e) {
713
+		} catch (PDOException $e) {
714 714
 			return "error";
715 715
 		}
716 716
 
@@ -726,13 +726,13 @@  discard block
 block discarded – undo
726 726
 	public function deleteLiveMarineDataById($id)
727 727
 	{
728 728
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
729
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
729
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
730 730
         
731 731
     		try {
732 732
 			
733 733
 			$sth = $this->db->prepare($query);
734 734
 			$sth->execute(array(':id' => $id));
735
-		} catch(PDOException $e) {
735
+		} catch (PDOException $e) {
736 736
 			return "error";
737 737
 		}
738 738
 
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	{
751 751
 		global $globalDBdriver, $globalTimezone;
752 752
 		if ($globalDBdriver == 'mysql') {
753
-			$query  = 'SELECT marine_live.ident FROM marine_live 
753
+			$query = 'SELECT marine_live.ident FROM marine_live 
754 754
 				WHERE marine_live.ident = :ident 
755 755
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
756 756
 				AND marine_live.date < UTC_TIMESTAMP()';
757 757
 			$query_data = array(':ident' => $ident);
758 758
 		} else {
759
-			$query  = "SELECT marine_live.ident FROM marine_live 
759
+			$query = "SELECT marine_live.ident FROM marine_live 
760 760
 				WHERE marine_live.ident = :ident 
761 761
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
762 762
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -765,8 +765,8 @@  discard block
 block discarded – undo
765 765
 		
766 766
 		$sth = $this->db->prepare($query);
767 767
 		$sth->execute($query_data);
768
-		$ident_result='';
769
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
768
+		$ident_result = '';
769
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
770 770
 		{
771 771
 			$ident_result = $row['ident'];
772 772
 		}
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
 	{
784 784
 		global $globalDBdriver, $globalTimezone;
785 785
 		if ($globalDBdriver == 'mysql') {
786
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
786
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
787 787
 				WHERE marine_live.ident = :ident 
788 788
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
789 789
 //				AND marine_live.date < UTC_TIMESTAMP()";
790 790
 			$query_data = array(':ident' => $ident);
791 791
 		} else {
792
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
792
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
793 793
 				WHERE marine_live.ident = :ident 
794 794
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
795 795
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -798,8 +798,8 @@  discard block
 block discarded – undo
798 798
 		
799 799
 		$sth = $this->db->prepare($query);
800 800
 		$sth->execute($query_data);
801
-		$ident_result='';
802
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
801
+		$ident_result = '';
802
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
803 803
 		{
804 804
 			$ident_result = $row['fammarine_id'];
805 805
 		}
@@ -816,13 +816,13 @@  discard block
 block discarded – undo
816 816
 	{
817 817
 		global $globalDBdriver, $globalTimezone;
818 818
 		if ($globalDBdriver == 'mysql') {
819
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
819
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
820 820
 				WHERE marine_live.fammarine_id = :id 
821 821
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
822 822
 //				AND marine_live.date < UTC_TIMESTAMP()";
823 823
 			$query_data = array(':id' => $id);
824 824
 		} else {
825
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
825
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
826 826
 				WHERE marine_live.fammarine_id = :id 
827 827
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
828 828
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
 		
832 832
 		$sth = $this->db->prepare($query);
833 833
 		$sth->execute($query_data);
834
-		$ident_result='';
835
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
834
+		$ident_result = '';
835
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
836 836
 		{
837 837
 			$ident_result = $row['fammarine_id'];
838 838
 		}
@@ -849,13 +849,13 @@  discard block
 block discarded – undo
849 849
 	{
850 850
 		global $globalDBdriver, $globalTimezone;
851 851
 		if ($globalDBdriver == 'mysql') {
852
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
852
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
853 853
 				WHERE marine_live.mmsi = :mmsi 
854 854
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
855 855
 //				AND marine_live.date < UTC_TIMESTAMP()";
856 856
 			$query_data = array(':mmsi' => $mmsi);
857 857
 		} else {
858
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
858
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
859 859
 				WHERE marine_live.mmsi = :mmsi 
860 860
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
861 861
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -864,8 +864,8 @@  discard block
 block discarded – undo
864 864
 		
865 865
 		$sth = $this->db->prepare($query);
866 866
 		$sth->execute($query_data);
867
-		$ident_result='';
868
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
867
+		$ident_result = '';
868
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
869 869
 		{
870 870
 			$ident_result = $row['fammarine_id'];
871 871
 		}
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	* @return String success or false
884 884
 	*
885 885
 	*/
886
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
886
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
887 887
 	{
888 888
 		global $globalURL, $globalArchive, $globalDebug;
889 889
 		$Common = new Common();
@@ -935,26 +935,26 @@  discard block
 block discarded – undo
935 935
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
936 936
 
937 937
         
938
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
939
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
940
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
941
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
942
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
943
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
944
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
945
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
946
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
947
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
948
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
949
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
950
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
951
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
952
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
953
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
938
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
939
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
940
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
941
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
942
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
943
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
944
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
945
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
946
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
947
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
948
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
949
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
950
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
951
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
952
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
953
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
954 954
 		
955 955
 
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
956
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
957
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
958 958
             	if ($arrival_date == '') $arrival_date = NULL;
959 959
             	$query = '';
960 960
 		if ($globalArchive) {
@@ -964,19 +964,19 @@  discard block
 block discarded – undo
964 964
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
965 965
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
966 966
 
967
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
967
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
968 968
 		try {
969 969
 			$sth = $this->db->prepare($query);
970 970
 			$sth->execute($query_values);
971 971
 			$sth->closeCursor();
972
-		} catch(PDOException $e) {
972
+		} catch (PDOException $e) {
973 973
 			return "error : ".$e->getMessage();
974 974
 		}
975 975
 		
976 976
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
977 977
 			if ($globalDebug) echo '(Add to Marine archive : ';
978 978
 			$MarineArchive = new MarineArchive($this->db);
979
-			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country);
979
+			$result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country);
980 980
 			if ($globalDebug) echo $result.')';
981 981
 		}
982 982
 		return "success";
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 
985 985
 	public function getOrderBy()
986 986
 	{
987
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
987
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
988 988
 		return $orderby;
989 989
 	}
990 990
 
Please login to merge, or discard this patch.