Completed
Push — master ( d4dde6...45519d )
by Yannick
29:37
created
js/map.3d.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -413,7 +413,7 @@
 block discarded – undo
413 413
 <?php
414 414
 	if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) {
415 415
 		if (isset($_COOKIE['lastcentercoord'])) {
416
-			$lastcentercoord = explode(',',$_COOKIE['lastcentercoord']);
416
+			$lastcentercoord = explode(',', $_COOKIE['lastcentercoord']);
417 417
 			if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0;
418 418
 			else $zoom = $lastcentercoord[3];
419 419
 			$viewcenterlatitude = $lastcentercoord[0];
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Spacing   +157 added lines, -158 removed lines patch added patch discarded remove patch
@@ -167,8 +167,7 @@  discard block
 block discarded – undo
167 167
 	
168 168
 
169 169
     private function urshift($n, $s) {
170
-	return ($n >= 0) ? ($n >> $s) :
171
-	    (($n & 0x7fffffff) >> $s) | 
170
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
172 171
 		(0x40000000 >> ($s - 1));
173 172
     }
174 173
 
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 	//$split_input = str_split($input);
181 180
 
182 181
 	/* Find the end of header checking for NULL bytes while doing it. */
183
-	$splitpos = strpos($input,':');
182
+	$splitpos = strpos($input, ':');
184 183
 	
185 184
 	/* Check that end was found and body has at least one byte. */
186 185
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -190,15 +189,15 @@  discard block
 block discarded – undo
190 189
 	
191 190
 	if ($debug) echo 'input : '.$input."\n";
192 191
 	/* Save header and body. */
193
-	$body = substr($input,$splitpos+1,$input_len);
192
+	$body = substr($input, $splitpos + 1, $input_len);
194 193
 	$body_len = strlen($body);
195
-	$header = substr($input,0,$splitpos);
194
+	$header = substr($input, 0, $splitpos);
196 195
 	//$header_len = strlen($header);
197 196
 	if ($debug) echo 'header : '.$header."\n";
198 197
 	
199 198
 	/* Parse source, target and path. */
200 199
 	//FLRDF0A52>APRS,qAS,LSTB
201
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
200
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
202 201
 	    $ident = $matches[1];
203 202
 	    $all_elements = $matches[2];
204 203
 	    if ($ident == 'AIRCRAFT') {
@@ -215,14 +214,14 @@  discard block
 block discarded – undo
215 214
 	    if ($debug) 'No ident'."\n";
216 215
 	    return false;
217 216
 	}
218
-	$elements = explode(',',$all_elements);
217
+	$elements = explode(',', $all_elements);
219 218
 	$source = end($elements);
220 219
 	$result['source'] = $source;
221 220
 	foreach ($elements as $element) {
222
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
221
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
223 222
 	        //echo "ok";
224 223
 	        //if ($element == 'TCPIP*') return false;
225
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
224
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
226 225
 		if ($debug) echo 'element : '.$element."\n";
227 226
 		return false;
228 227
 	    }
@@ -235,14 +234,14 @@  discard block
 block discarded – undo
235 234
 	    */
236 235
 	}
237 236
 	
238
-	$type = substr($body,0,1);
237
+	$type = substr($body, 0, 1);
239 238
 	if ($debug) echo 'type : '.$type."\n";
240 239
 	if ($type == ';') {
241 240
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
242
-			$result['address'] = trim(substr($body,1,9));
241
+			$result['address'] = trim(substr($body, 1, 9));
243 242
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
244
-			$result['mmsi'] = trim(substr($body,1,9));
245
-		} else $result['ident'] = trim(substr($body,1,9));
243
+			$result['mmsi'] = trim(substr($body, 1, 9));
244
+		} else $result['ident'] = trim(substr($body, 1, 9));
246 245
 	} elseif ($type == ',') {
247 246
 		// Invalid data or test data
248 247
 		return false;
@@ -250,24 +249,24 @@  discard block
 block discarded – undo
250 249
 	
251 250
 	// Check for Timestamp
252 251
 	$find = false;
253
-	$body_parse = substr($body,1);
252
+	$body_parse = substr($body, 1);
254 253
 	//echo 'Body : '.$body."\n";
255
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
256
-	    $body_parse = substr($body_parse,10);
254
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
255
+	    $body_parse = substr($body_parse, 10);
257 256
 	    $find = true;
258 257
 	    //echo $body_parse."\n";
259 258
 	}
260
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
261
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
259
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
260
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
262 261
 	    $find = true;
263 262
 	    //echo $body_parse."\n";
264 263
 	}
265
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
266
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
264
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
265
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
267 266
 	    $find = true;
268 267
 	    //echo $body_parse."\n";
269 268
 	}
270
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
269
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
271 270
 	    $find = true;
272 271
 	    //print_r($matches);
273 272
 	    $timestamp = $matches[0];
@@ -282,19 +281,19 @@  discard block
 block discarded – undo
282 281
 		// This work or not ?
283 282
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
284 283
 	    }
285
-	    $body_parse = substr($body_parse,7);
284
+	    $body_parse = substr($body_parse, 7);
286 285
 	    $result['timestamp'] = $timestamp;
287 286
 	    //echo date('Ymd H:i:s',$timestamp);
288 287
 	}
289
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
288
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
290 289
 	    $find = true;
291 290
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
-	    $body_parse = substr($body_parse,8);
291
+	    $body_parse = substr($body_parse, 8);
293 292
 	    $result['timestamp'] = $timestamp;
294 293
 	    //echo date('Ymd H:i:s',$timestamp);
295 294
 	}
296 295
 	//if (strlen($body_parse) > 19) {
297
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
296
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
298 297
 		$find = true;
299 298
 		// 4658.70N/00707.78Ez
300 299
 		//print_r(str_split($body_parse));
@@ -321,11 +320,11 @@  discard block
 block discarded – undo
321 320
 	    */
322 321
 		$latitude = $lat + floatval($lat_min)/60;
323 322
 		$longitude = $lon + floatval($lon_min)/60;
324
-		if ($sind == 'S') $latitude = 0-$latitude;
325
-		if ($wind == 'W') $longitude = 0-$longitude;
323
+		if ($sind == 'S') $latitude = 0 - $latitude;
324
+		if ($wind == 'W') $longitude = 0 - $longitude;
326 325
 		$result['latitude'] = $latitude;
327 326
 		$result['longitude'] = $longitude;
328
-		$body_parse = substr($body_parse,18);
327
+		$body_parse = substr($body_parse, 18);
329 328
 		$body_parse_len = strlen($body_parse);
330 329
 	    }
331 330
 	    $body_parse_len = strlen($body_parse);
@@ -357,7 +356,7 @@  discard block
 block discarded – undo
357 356
 		//echo $body_parse;
358 357
 			//if ($type != ';' && $type != '>') {
359 358
 			if ($type != '') {
360
-			$body_parse = substr($body_parse,1);
359
+			$body_parse = substr($body_parse, 1);
361 360
 			$body_parse_len = strlen($body_parse);
362 361
 			$result['symbol_code'] = $symbol_code;
363 362
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -368,16 +367,16 @@  discard block
 block discarded – undo
368 367
 		    //$body_parse_len = strlen($body_parse);
369 368
 		    if ($body_parse_len >= 7) {
370 369
 			
371
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
-		    	    $course = substr($body_parse,0,3);
370
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
371
+		    	    $course = substr($body_parse, 0, 3);
373 372
 		    	    $tmp_s = intval($course);
374 373
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
-		    	    $speed = substr($body_parse,4,3);
374
+		    	    $speed = substr($body_parse, 4, 3);
376 375
 		    	    if ($speed != '...') {
377 376
 		    		//$result['speed'] = round($speed*1.852);
378 377
 		    		$result['speed'] = intval($speed);
379 378
 		    	    }
380
-		    	    $body_parse = substr($body_parse,7);
379
+		    	    $body_parse = substr($body_parse, 7);
381 380
 		        }
382 381
 		        // Check PHGR, PHG, RNG
383 382
 		    } 
@@ -387,12 +386,12 @@  discard block
 block discarded – undo
387 386
 		    }
388 387
 		    */
389 388
 		    if (strlen($body_parse) > 0) {
390
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
389
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
391 390
 		            $altitude = intval($matches[1]);
392 391
 		            //$result['altitude'] = round($altitude*0.3048);
393 392
 		            $result['altitude'] = $altitude;
394 393
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
394
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
396 395
 		        }
397 396
 		    }
398 397
 		    
@@ -404,13 +403,13 @@  discard block
 block discarded – undo
404 403
 		    */
405 404
 		    // DAO
406 405
 		    
407
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
406
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
408 407
 			    
409 408
 			    $dao = $matches[1];
410
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
409
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
411 410
 				$dao_split = str_split($dao);
412
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
411
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
412
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
414 413
 			    
415 414
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416 415
 				else $result['latitude'] += $lat_off;
@@ -418,50 +417,50 @@  discard block
 block discarded – undo
418 417
 				else $result['longitude'] += $lon_off;
419 418
 			    }
420 419
 			    
421
-		            $body_parse = substr($body_parse,6);
420
+		            $body_parse = substr($body_parse, 6);
422 421
 		    }
423 422
 		    //echo 'bodyparse : '.$body_parse."\n";
424
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
425
-			$result['ident'] = str_replace('_',' ',$matches[1]);
423
+		    if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
424
+			$result['ident'] = str_replace('_', ' ', $matches[1]);
426 425
 		    }
427
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
426
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
428 427
 			$result['squawk'] = $matches[1];
429 428
 		    }
430
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
429
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
431 430
 			$result['aircraft_icao'] = $matches[1];
432 431
 		    }
433
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
432
+		    if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) {
434 433
 			$result['verticalrate'] = $matches[1];
435 434
 		    }
436
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
435
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
437 436
 			$result['typeid'] = $matches[1];
438 437
 		    }
439
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
438
+		    if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
440 439
 			$result['statusid'] = $matches[1];
441 440
 		    }
442
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
441
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
443 442
 			$result['imo'] = $matches[1];
444 443
 		    }
445
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
444
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
446 445
 			$result['arrival_date'] = $matches[1];
447 446
 		    }
448
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
449
-			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
447
+		    if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
448
+			$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
450 449
 		    }
451 450
 		    // OGN comment
452 451
 		   // echo "Before OGN : ".$body_parse."\n";
453 452
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
453
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
455 454
 			$id = $matches[1];
456 455
 			//$mode = substr($id,0,2);
457
-			$address = substr($id,2);
456
+			$address = substr($id, 2);
458 457
 			//print_r($matches);
459
-			$addressType = (intval(substr($id,0,2),16))&3;
458
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
460 459
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
461 460
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
462 461
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
463 462
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
464
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
463
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
465 464
 			$result['aircrafttype_code'] = $aircraftType;
466 465
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
467 466
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -478,7 +477,7 @@  discard block
 block discarded – undo
478 477
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
479 478
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
480 479
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
481
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
480
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
482 481
 			$result['stealth'] = $stealth;
483 482
 			$result['address'] = $address;
484 483
 		    }
@@ -490,96 +489,96 @@  discard block
 block discarded – undo
490 489
 		    //$body_parse = substr($body_parse,1);
491 490
 		    //$body_parse_len = strlen($body_parse);
492 491
 		    //echo 'weather'."\n";
493
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
492
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
494 493
 			    $result['wind_dir'] = intval($matches[1]);
495
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
499
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
495
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
496
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
497
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
498
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
500 499
 			$result['wind_dir'] = intval($matches[1]);
501
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
502
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
503
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
504
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
505
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
500
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
501
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
502
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
503
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
504
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
506 505
 			$result['wind_dir'] = intval($matches[1]);
507
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
508
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
509
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
510
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
506
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
507
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
508
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
509
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
511 510
 			$result['wind_dir'] = intval($matches[1]);
512
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
513
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
514
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
511
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
512
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
513
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
515 514
 		    }
516 515
 		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517 516
 		    //g012t088r000p000P000h38b10110
518 517
 		    //g011t086r000p000P000h29b10198
519
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
520
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
523
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
524
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
518
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
519
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
520
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
521
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
522
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
523
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
525 524
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
527
-		        $body_parse = substr($body_parse,strlen($matches[0]));
528
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
529
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
532
-			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
533
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
525
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
526
+		        $body_parse = substr($body_parse, strlen($matches[0]));
527
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
528
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
529
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
530
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
531
+			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1);
532
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
534 533
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
536
-		        $body_parse = substr($body_parse,strlen($matches[0]));
537
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
538
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
541
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
542
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
534
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
535
+		        $body_parse = substr($body_parse, strlen($matches[0]));
536
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
537
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
538
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
539
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
540
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
541
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
543 542
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
545
-		        $body_parse = substr($body_parse,strlen($matches[0]));
546
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
547
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
543
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
544
+		        $body_parse = substr($body_parse, strlen($matches[0]));
545
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
546
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
547
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
548
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
549
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
551 550
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
553
-		        $body_parse = substr($body_parse,strlen($matches[0]));
554
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
555
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
551
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
552
+		        $body_parse = substr($body_parse, strlen($matches[0]));
553
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
554
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
555
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
556
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
557
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
559 558
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
561
-		        $body_parse = substr($body_parse,strlen($matches[0]));
562
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
563
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
560
+		        $body_parse = substr($body_parse, strlen($matches[0]));
561
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
562
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
563
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
564
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
565
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
567 566
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
569
-		        $body_parse = substr($body_parse,strlen($matches[0]));
570
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
571
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
567
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
568
+		        $body_parse = substr($body_parse, strlen($matches[0]));
569
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
570
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
571
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
573 572
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574
-			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
575
-		        $body_parse = substr($body_parse,strlen($matches[0]));
576
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
577
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
573
+			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1);
574
+		        $body_parse = substr($body_parse, strlen($matches[0]));
575
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
576
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
577
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
578
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
580 579
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
582
-		        $body_parse = substr($body_parse,strlen($matches[0]));
580
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
581
+		        $body_parse = substr($body_parse, strlen($matches[0]));
583 582
 		    }
584 583
 		    $result['comment'] = trim($body_parse);
585 584
 		}
@@ -587,42 +586,42 @@  discard block
 block discarded – undo
587 586
 
588 587
 	    }
589 588
 	//}
590
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
589
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
590
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
592 591
 	if ($debug) print_r($result);
593 592
 	return $result;
594 593
     }
595 594
     
596 595
     public function connect() {
597
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
596
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
598 597
 	$aprs_connect = 0;
599 598
 	$aprs_keep = 120;
600 599
 	$aprs_last_tx = time();
601 600
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
602
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
601
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
603 602
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
604
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
603
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
605 604
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
606 605
 	else $aprs_pass = '-1';
607 606
 	
608
-	$aprs_filter  = '';
607
+	$aprs_filter = '';
609 608
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
610 609
 	$Common = new Common();
611
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
610
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
612 611
 	if ($s !== false) {
613 612
 		echo 'Connected to APRS server! '."\n";
614 613
 		$authstart = time();
615 614
 		$this->socket = $s;
616
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
617
-		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
618
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
615
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
616
+		socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1);
617
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
619 618
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
620 619
 			    echo 'APRS user verified !'."\n";
621 620
 			    $this->connected = true;
622 621
 			    return true;
623 622
 			    break;
624 623
 			}
625
-			if (time()-$authstart > 5) {
624
+			if (time() - $authstart > 5) {
626 625
 			    echo 'APRS timeout'."\n";
627 626
 			    break;
628 627
 			}
@@ -637,7 +636,7 @@  discard block
 block discarded – undo
637 636
     public function send($data) {
638 637
 	global $globalDebug;
639 638
 	if ($this->connected === false) $this->connect();
640
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
639
+	$send = socket_send($this->socket, $data, strlen($data), 0);
641 640
 	if ($send === FALSE) {
642 641
 		if ($globalDebug) echo 'Reconnect...';
643 642
 		socket_close($this->socket);
@@ -647,17 +646,17 @@  discard block
 block discarded – undo
647 646
 }
648 647
 
649 648
 class APRSSpotter extends APRS {
650
-	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
649
+	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
651 650
 		$Common = new Common();
652 651
 		date_default_timezone_set('UTC');
653 652
 		if ($latitude != '' && $longitude != '') {
654 653
 			$lat = $latitude;
655 654
 			$long = $longitude;
656
-			$latitude = $Common->convertDM($latitude,'latitude');
657
-			$longitude = $Common->convertDM($longitude,'longitude');
658
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
659
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
660
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
655
+			$latitude = $Common->convertDM($latitude, 'latitude');
656
+			$longitude = $Common->convertDM($longitude, 'longitude');
657
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
658
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
659
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
661 660
 			$w = $w1.$w2;
662 661
 			//$w = '00';
663 662
 			$custom = '';
@@ -684,26 +683,26 @@  discard block
 block discarded – undo
684 683
 			$geoid= round($GeoidClass->get($lat,$long)*3.28084,2);
685 684
 			$altitude_real = round($altitude_real + $geoid);
686 685
 			*/
687
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
686
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
688 687
 		}
689 688
 	}
690 689
 }
691 690
 class APRSMarine extends APRS {
692
-	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) {
691
+	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) {
693 692
 		$Common = new Common();
694 693
 		date_default_timezone_set('UTC');
695 694
 		if ($latitude != '' && $longitude != '') {
696
-			$latitude = $Common->convertDM($latitude,'latitude');
697
-			$longitude = $Common->convertDM($longitude,'longitude');
698
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
699
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
700
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
695
+			$latitude = $Common->convertDM($latitude, 'latitude');
696
+			$longitude = $Common->convertDM($longitude, 'longitude');
697
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
698
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
699
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
701 700
 			$w = $w1.$w2;
702 701
 			//$w = '00';
703 702
 			$custom = '';
704 703
 			if ($ident != '') {
705 704
 				if ($custom != '') $custom .= '/';
706
-				$custom .= 'CS='.str_replace(' ','_',$ident);
705
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
707 706
 			}
708 707
 			if ($typeid != '') {
709 708
 				if ($custom != '') $custom .= '/';
@@ -723,11 +722,11 @@  discard block
 block discarded – undo
723 722
 			}
724 723
 			if ($arrival_code != '') {
725 724
 				if ($custom != '') $custom .= '/';
726
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
725
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
727 726
 			}
728 727
 			if ($custom != '') $custom = ' '.$custom;
729 728
 			$altitude = 0;
730
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
729
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
731 730
 		}
732 731
 	}
733 732
 }
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Spacing   +85 added lines, -85 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,65 +154,65 @@  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'])));
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
157
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
158
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id']));
159 159
 		}
160 160
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
161
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
162 162
 		}
163 163
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type']));
165 165
 		}
166 166
 		if (isset($line['imo']) && $line['imo'] != '') {
167
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
167
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
168 168
 		}
169 169
 		if (isset($line['callsign']) && $line['callsign'] != '') {
170
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
170
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
171 171
 		}
172 172
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
173
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
173
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
174 174
 		}
175 175
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
176
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
176
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
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
-				$Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
190
+				$Marine->addIdentity($this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['type']);
191 191
 				$Marine->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 			    }
194 194
 			}
195 195
 		    }
196
-		    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
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
197 197
 		}
198 198
 
199
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
199
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) {
200 200
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
201
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
201
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
202 202
 		    } else {
203 203
 				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";
204 204
 				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";
205 205
 				return '';
206 206
 		    }
207
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
207
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) {
208 208
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
209 209
 			return '';
210
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
210
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) {
211 211
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
212 212
 			return '';
213 213
 		} elseif (!isset($line['datetime'])) {
214 214
 			date_default_timezone_set('UTC');
215
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
215
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
216 216
 		} else {
217 217
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!";
218 218
 			return '';
@@ -220,24 +220,24 @@  discard block
 block discarded – undo
220 220
 
221 221
 
222 222
 		if (isset($line['speed'])) {
223
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
224
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
223
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
224
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
225 225
 		} 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'])) {
226
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
226
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
227 227
 		    if ($distance > 1000 && $distance < 10000) {
228 228
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
229 229
 			$speed = $speed*3.6;
230
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
230
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
231 231
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
232 232
 		    }
233 233
 		}
234 234
 
235 235
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
236
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
236
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
237 237
 	    	    else unset($timediff);
238
-	    	    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
+	    	    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')))) {
239 239
 			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'])) {
240
-			    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
+			    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'])) {
241 241
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
242 242
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
243 243
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 				$timeelapsed = microtime(true);
247 247
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
248 248
 				    $Marine = new Marine($this->db);
249
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
249
+				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
250 250
 				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
251 251
 				    $Marine->db = null;
252
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
252
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
253 253
 				}
254 254
 				$this->tmd = 0;
255 255
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
@@ -258,52 +258,52 @@  discard block
 block discarded – undo
258 258
 
259 259
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
260 260
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
261
-				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
+				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') {
262 262
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
263 263
 				    $dataFound = true;
264 264
 				    $this->all_tracked[$id]['time_last_coord'] = time();
265 265
 				}
266
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
266
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
267 267
 			}
268 268
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
269 269
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
270 270
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
-				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
+				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') {
272 272
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
273 273
 				    $dataFound = true;
274 274
 				    $this->all_tracked[$id]['time_last_coord'] = time();
275 275
 				}
276
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
276
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
277 277
 			}
278 278
 
279 279
 		    } else if ($globalDebug && $timediff > 20) {
280 280
 			$this->tmd = $this->tmd + 1;
281 281
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
282
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
283
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
282
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
283
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
284 284
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
285 285
 		    }
286 286
 		}
287 287
 		if (isset($line['last_update']) && $line['last_update'] != '') {
288 288
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
289
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
289
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
290 290
 		}
291 291
 		if (isset($line['format_source']) && $line['format_source'] != '') {
292
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
292
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
293 293
 		}
294 294
 		if (isset($line['source_name']) && $line['source_name'] != '') {
295
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
295
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
296 296
 		}
297 297
 		if (isset($line['status']) && $line['status'] != '') {
298
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
298
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
299 299
 		}
300 300
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
301
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
301
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id']));
302 302
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
303 303
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
304 304
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
305 305
 				$Marine = new Marine($this->db);
306
-				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
306
+				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']);
307 307
 				unset($Marine);
308 308
 			    }
309 309
 			}
@@ -311,18 +311,18 @@  discard block
 block discarded – undo
311 311
 		}
312 312
 
313 313
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
314
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
314
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
315 315
 		}
316 316
 		
317 317
 		if (isset($line['heading']) && $line['heading'] != '') {
318
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
319
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
320
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
318
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
319
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
320
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
321 321
 		    //$dataFound = true;
322 322
   		} 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']) {
323
-  		    $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']);
324
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
325
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
323
+  		    $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']);
324
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
325
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
326 326
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
327 327
   		}
328 328
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
333 333
 		    $this->all_tracked[$id]['lastupdate'] = time();
334 334
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
335
-		        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
+		        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'])) {
336 336
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
337 337
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
338 338
 				    if ($globalDebug) echo "Check if vessel is already in DB...";
@@ -340,37 +340,37 @@  discard block
 block discarded – undo
340 340
 				    $MarineLive = new MarineLive($this->db);
341 341
 				    if (isset($line['id'])) {
342 342
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
343
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
343
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
344 344
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
345 345
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
346
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
346
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
347 347
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
348 348
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
349
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
349
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
350 350
 				    } else $recent_ident = '';
351
-				    $MarineLive->db=null;
351
+				    $MarineLive->db = null;
352 352
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
353 353
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
354 354
 				} else $recent_ident = '';
355 355
 			    } else {
356 356
 				$recent_ident = '';
357
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
357
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
358 358
 			    }
359 359
 			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
360
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
360
+			    if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
361 361
 			    {
362 362
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
363 363
 				//adds the spotter data for the archive
364 364
 				    $highlight = '';
365
-				    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
+				    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')));
366 366
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
367 367
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
368 368
 					    $timeelapsed = microtime(true);
369 369
 					    $Marine = new Marine($this->db);
370
-					    $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
+					    $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']);
371 371
 					    $Marine->db = null;
372 372
 					    if ($globalDebug && isset($result)) echo $result."\n";
373
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
373
+					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
374 374
 					}
375 375
 				    }
376 376
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
@@ -378,15 +378,15 @@  discard block
 block discarded – undo
378 378
 					$Stats = new Stats($this->db);
379 379
 					if (!empty($this->stats)) {
380 380
 					    if ($globalDebug) echo 'Add source stats : ';
381
-				    	    foreach($this->stats as $date => $data) {
382
-						foreach($data as $source => $sourced) {
381
+				    	    foreach ($this->stats as $date => $data) {
382
+						foreach ($data as $source => $sourced) {
383 383
 					    	    //print_r($sourced);
384
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
385
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
384
+				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date);
385
+				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date);
386 386
 				    		    if (isset($sourced['msg'])) {
387 387
 				    			if (time() - $sourced['msg']['date'] > 10) {
388 388
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
389
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
389
+				    		    	    echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date);
390 390
 			    			    	    unset($this->stats[$date][$source]['msg']);
391 391
 			    				}
392 392
 			    			    }
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
411 411
 					$MarineLive = new MarineLive($this->db);
412 412
 					$MarineLive->deleteLiveMarineData();
413
-					$MarineLive->db=null;
413
+					$MarineLive->db = null;
414 414
 					if ($globalDebug) echo " Done\n";
415 415
 				    }
416 416
 				    $this->last_delete = time();
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
422 422
 				    if (isset($globalDaemon) && !$globalDaemon) {
423 423
 					$Marine = new Marine($this->db);
424
-					$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
+					$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']);
425 425
 					$Marine->db = null;
426 426
 				    }
427 427
 				}
@@ -436,20 +436,20 @@  discard block
 block discarded – undo
436 436
 		    $ignoreImport = false;
437 437
 
438 438
 		    if (!$ignoreImport) {
439
-			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
+			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'])) {
440 440
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
441 441
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
442 442
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
443 443
 					$timeelapsed = microtime(true);
444 444
 					$MarineLive = new MarineLive($this->db);
445
-					$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
+					$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']);
446 446
 					$MarineLive->db = null;
447 447
 					if ($globalDebug) echo $result."\n";
448
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
448
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
449 449
 				    }
450 450
 				}
451 451
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
452
-				    $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
+				    $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']);
453 453
 				}
454 454
 				$this->all_tracked[$id]['putinarchive'] = false;
455 455
 
@@ -468,19 +468,19 @@  discard block
 block discarded – undo
468 468
 							$latitude = $globalCenterLatitude;
469 469
 							$longitude = $globalCenterLongitude;
470 470
 						}
471
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
471
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
472 472
 					} else {
473 473
 						$latitude = $this->source_location[$source]['latitude'];
474 474
 						$longitude = $this->source_location[$source]['longitude'];
475 475
 					}
476
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
476
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
477 477
 					//$stats_heading = $stats_heading%22.5;
478 478
 					$stats_heading = round($stats_heading/22.5);
479
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
479
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
480 480
 					$current_date = date('Y-m-d');
481 481
 					if ($stats_heading == 16) $stats_heading = 0;
482 482
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
483
-						for ($i=0;$i<=15;$i++) {
483
+						for ($i = 0; $i <= 15; $i++) {
484 484
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
485 485
 						}
486 486
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -495,9 +495,9 @@  discard block
 block discarded – undo
495 495
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
496 496
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
497 497
 						    end($this->stats[$current_date][$source]['hist']);
498
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
498
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
499 499
 						} else $mini = 0;
500
-						for ($i=$mini;$i<=$distance;$i+=10) {
500
+						for ($i = $mini; $i <= $distance; $i += 10) {
501 501
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
502 502
 						}
503 503
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 
510 510
 				$this->all_tracked[$id]['lastupdate'] = time();
511 511
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
512
-			} 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
+			} 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";
513 513
 			//$this->del();
514 514
 			
515 515
 			
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Spacing   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @return Array the SQL part
18 18
 	*/
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 spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
39
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.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'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.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']."'";
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76 76
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77 77
 		if ($filter_query_where != '') {
78
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
79 79
 		}
80 80
 		$filter_query = $filter_query_join.$filter_query_where;
81 81
 		return $filter_query;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	* @return Array the spotter information
91 91
 	*
92 92
 	*/
93
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
93
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
94 94
 	{
95 95
 		date_default_timezone_set('UTC');
96 96
 		if (!is_string($query))
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 			$sth = $this->db->prepare($query.$limitQuery);
111 111
 			$sth->execute($params);
112 112
 		} catch (PDOException $e) {
113
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
113
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
114 114
 			exit();
115 115
 		}
116 116
 		
117 117
 		$num_rows = 0;
118 118
 		$spotter_array = array();
119
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
119
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
120 120
 		{
121 121
 			$num_rows++;
122 122
 			$temp_array = array();
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 			}
149 149
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
150 150
 
151
-			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
151
+			if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
152 152
 			{
153 153
 				$Image = new Image($this->db);
154
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
154
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
155 155
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
156 156
 				unset($Image);
157 157
 				if (count($image_array) > 0) {
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
 				{
188 188
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
189 189
 				} else {
190
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
190
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
191 191
 				}
192 192
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
193
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
194
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
193
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
194
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
195 195
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
196 196
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
197 197
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
198 198
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
199
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
200
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
199
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
200
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
201 201
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
202 202
 					}
203 203
 				}
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 		if ($limit != "")
231 231
 		{
232 232
 			$limit_array = explode(",", $limit);
233
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
234
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
233
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
234
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
235 235
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
236 236
 			{
237 237
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -245,8 +245,8 @@  discard block
 block discarded – undo
245 245
 		} else {
246 246
 			$orderby_query = " ORDER BY marine_output.date DESC";
247 247
 		}
248
-		$query  = $global_query.$filter_query." ".$orderby_query;
249
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
248
+		$query = $global_query.$filter_query." ".$orderby_query;
249
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
250 250
 		return $spotter_array;
251 251
 	}
252 252
     
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 		if ($id == '') return array();
265 265
 		$additional_query = "marine_output.fammarine_id = :id";
266 266
 		$query_values = array(':id' => $id);
267
-		$query  = $global_query." WHERE ".$additional_query." ";
268
-		$spotter_array = $this->getDataFromDB($query,$query_values);
267
+		$query = $global_query." WHERE ".$additional_query." ";
268
+		$spotter_array = $this->getDataFromDB($query, $query_values);
269 269
 		return $spotter_array;
270 270
 	}
271 271
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 		$query_values = array();
285 285
 		$limit_query = '';
286 286
 		$additional_query = '';
287
-		$filter_query = $this->getFilter($filter,true,true);
287
+		$filter_query = $this->getFilter($filter, true, true);
288 288
 		if ($ident != "")
289 289
 		{
290 290
 			if (!is_string($ident))
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 		{
301 301
 			$limit_array = explode(",", $limit);
302 302
 			
303
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
304
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
303
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
304
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
305 305
 			
306 306
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
307 307
 			{
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		return $spotter_array;
326 326
 	}
327 327
 	
328
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
328
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
329 329
 	{
330 330
 		global $global_query, $globalTimezone, $globalDBdriver;
331 331
 		
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		$limit_query = '';
334 334
 		$additional_query = '';
335 335
 
336
-		$filter_query = $this->getFilter($filter,true,true);
336
+		$filter_query = $this->getFilter($filter, true, true);
337 337
 		
338 338
 		if ($date != "")
339 339
 		{
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
 		{
360 360
 			$limit_array = explode(",", $limit);
361 361
 			
362
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
363
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
362
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
363
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
364 364
 			
365 365
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
366 366
 			{
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
 	* @return Array list of source name
392 392
 	*
393 393
 	*/
394
-	public function getAllSourceName($type = '',$filters = array())
394
+	public function getAllSourceName($type = '', $filters = array())
395 395
 	{
396
-		$filter_query = $this->getFilter($filters,true,true);
396
+		$filter_query = $this->getFilter($filters, true, true);
397 397
 		$query_values = array();
398
-		$query  = "SELECT DISTINCT marine_output.source_name 
398
+		$query = "SELECT DISTINCT marine_output.source_name 
399 399
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
400 400
 		if ($type != '') {
401 401
 			$query_values = array(':type' => $type);
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 		$source_array = array();
411 411
 		$temp_array = array();
412 412
 		
413
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
413
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
414 414
 		{
415 415
 			$temp_array['source_name'] = $row['source_name'];
416 416
 			$source_array[] = $temp_array;
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 	*/
428 428
 	public function getAllIdents($filters = array())
429 429
 	{
430
-		$filter_query = $this->getFilter($filters,true,true);
431
-		$query  = "SELECT DISTINCT marine_output.ident
430
+		$filter_query = $this->getFilter($filters, true, true);
431
+		$query = "SELECT DISTINCT marine_output.ident
432 432
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
433 433
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
434 434
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 		$ident_array = array();
439 439
 		$temp_array = array();
440 440
 		
441
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
441
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
442 442
 		{
443 443
 			$temp_array['ident'] = $row['ident'];
444 444
 			$ident_array[] = $temp_array;
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 	*/
456 456
 	public function getIdentity($mmsi)
457 457
 	{
458
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
458
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
459 459
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
460 460
 		$sth = $this->db->prepare($query);
461 461
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -468,23 +468,23 @@  discard block
 block discarded – undo
468 468
 	* Add identity
469 469
 	*
470 470
 	*/
471
-	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
471
+	public function addIdentity($mmsi, $imo, $ident, $callsign, $type)
472 472
 	{
473
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
473
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
474 474
 		if ($mmsi != '') {
475
-			$imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT);
476
-			$ident = filter_var($ident,FILTER_SANITIZE_STRING);
477
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
478
-			$type = filter_var($type,FILTER_SANITIZE_STRING);
475
+			$imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT);
476
+			$ident = filter_var($ident, FILTER_SANITIZE_STRING);
477
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
478
+			$type = filter_var($type, FILTER_SANITIZE_STRING);
479 479
 			$identinfo = $this->getIdentity($mmsi);
480 480
 			if (empty($identinfo)) {
481
-				$query  = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
481
+				$query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
482 482
 				$sth = $this->db->prepare($query);
483
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type));
483
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type));
484 484
 			} elseif ($ident != '' && $identinfo['ship_name'] != $ident) {
485
-				$query  = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
485
+				$query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
486 486
 				$sth = $this->db->prepare($query);
487
-				$sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type));
487
+				$sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type));
488 488
 			}
489 489
 		}
490 490
 	}
@@ -505,12 +505,12 @@  discard block
 block discarded – undo
505 505
 		} else $offset = '+00:00';
506 506
 
507 507
 		if ($globalDBdriver == 'mysql') {
508
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
508
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
509 509
 								FROM marine_output
510 510
 								WHERE marine_output.date <> '' 
511 511
 								ORDER BY marine_output.date ASC LIMIT 0,100";
512 512
 		} else {
513
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
513
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
514 514
 								FROM marine_output
515 515
 								WHERE marine_output.date <> '' 
516 516
 								ORDER BY marine_output.date ASC LIMIT 0,100";
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 		$date_array = array();
523 523
 		$temp_array = array();
524 524
 		
525
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
525
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
526 526
 		{
527 527
 			$temp_array['date'] = $row['date'];
528 528
 
@@ -540,10 +540,10 @@  discard block
 block discarded – undo
540 540
 	* @return String success or false
541 541
 	*
542 542
 	*/
543
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
543
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
544 544
 	{
545 545
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
546
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
546
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
547 547
 		try {
548 548
 			$sth = $this->db->prepare($query);
549 549
 			$sth->execute($query_values);
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
 	* @return String success or false
563 563
 	*
564 564
 	*/
565
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
565
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
566 566
 	{
567 567
 
568 568
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
569
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
569
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
570 570
 
571 571
 		try {
572 572
 			$sth = $this->db->prepare($query);
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
590 590
 	{
591 591
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
592
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
592
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
593 593
 
594 594
 		try {
595 595
 			$sth = $this->db->prepare($query);
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 	* @param String $verticalrate vertival rate of flight
628 628
 	* @return String success or false
629 629
 	*/
630
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
630
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '')
631 631
 	{
632 632
 		global $globalURL, $globalMarineImageFetch;
633 633
 		
@@ -694,31 +694,31 @@  discard block
 block discarded – undo
694 694
 		}
695 695
 
696 696
     
697
-		if ($date == "" || strtotime($date) < time()-20*60)
697
+		if ($date == "" || strtotime($date) < time() - 20*60)
698 698
 		{
699 699
 			$date = date("Y-m-d H:i:s", time());
700 700
 		}
701 701
 
702
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
703
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
704
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
705
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
706
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
707
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
708
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
709
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
710
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
711
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
712
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
713
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
714
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
715
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
702
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
703
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
704
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
705
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
706
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
707
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
708
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
709
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
710
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
711
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
712
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
713
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
714
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
715
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
716 716
 	
717 717
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
718 718
 			$Image = new Image($this->db);
719
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
719
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
720 720
 			if (!isset($image_array[0]['mmsi'])) {
721
-				$Image->addMarineImage($mmsi,$imo,$ident);
721
+				$Image->addMarineImage($mmsi, $imo, $ident);
722 722
 			}
723 723
 			unset($Image);
724 724
 		}
@@ -730,10 +730,10 @@  discard block
 block discarded – undo
730 730
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
731 731
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
732 732
                 if ($arrival_date == '') $arrival_date = NULL;
733
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
733
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
734 734
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
735 735
 
736
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
736
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
737 737
 		try {
738 738
 		        
739 739
 			$sth = $this->db->prepare($query);
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
 	{
759 759
 		global $globalDBdriver, $globalTimezone;
760 760
 		if ($globalDBdriver == 'mysql') {
761
-			$query  = "SELECT marine_output.ident FROM marine_output 
761
+			$query = "SELECT marine_output.ident FROM marine_output 
762 762
 								WHERE marine_output.ident = :ident 
763 763
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
764 764
 								AND marine_output.date < UTC_TIMESTAMP()";
765 765
 			$query_data = array(':ident' => $ident);
766 766
 		} else {
767
-			$query  = "SELECT marine_output.ident FROM marine_output 
767
+			$query = "SELECT marine_output.ident FROM marine_output 
768 768
 								WHERE marine_output.ident = :ident 
769 769
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
770 770
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
 		
774 774
 		$sth = $this->db->prepare($query);
775 775
 		$sth->execute($query_data);
776
-    		$ident_result='';
777
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
776
+    		$ident_result = '';
777
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
778 778
 		{
779 779
 			$ident_result = $row['ident'];
780 780
 		}
@@ -800,8 +800,8 @@  discard block
 block discarded – undo
800 800
 				return false;
801 801
 			} else {
802 802
 				$q_array = explode(" ", $q);
803
-				foreach ($q_array as $q_item){
804
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
803
+				foreach ($q_array as $q_item) {
804
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
805 805
 					$additional_query .= " AND (";
806 806
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
807 807
 					$additional_query .= ")";
@@ -809,11 +809,11 @@  discard block
 block discarded – undo
809 809
 			}
810 810
 		}
811 811
 		if ($globalDBdriver == 'mysql') {
812
-			$query  = "SELECT marine_output.* FROM marine_output 
812
+			$query = "SELECT marine_output.* FROM marine_output 
813 813
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
814 814
 				AND marine_output.date < UTC_TIMESTAMP()";
815 815
 		} else {
816
-			$query  = "SELECT marine_output.* FROM marine_output 
816
+			$query = "SELECT marine_output.* FROM marine_output 
817 817
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
818 818
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
819 819
 		}
@@ -832,16 +832,16 @@  discard block
 block discarded – undo
832 832
 	*
833 833
 	*/
834 834
 
835
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
835
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
836 836
 	{
837 837
 		global $globalDBdriver, $globalArchive;
838 838
 		//$filter_query = $this->getFilter($filters,true,true);
839
-		$Connection= new Connection($this->db);
839
+		$Connection = new Connection($this->db);
840 840
 		if (!$Connection->tableExists('countries')) return array();
841 841
 		require_once('class.SpotterLive.php');
842 842
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
843 843
 			$MarineLive = new MarineLive($this->db);
844
-			$filter_query = $MarineLive->getFilter($filters,true,true);
844
+			$filter_query = $MarineLive->getFilter($filters, true, true);
845 845
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
846 846
 			if ($olderthanmonths > 0) {
847 847
 				if ($globalDBdriver == 'mysql') {
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 		} else {
862 862
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
863 863
 			$MarineArchive = new MarineArchive($this->db);
864
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
864
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
865 865
 			$filter_query .= " over_country <> ''";
866 866
 			if ($olderthanmonths > 0) {
867 867
 				if ($globalDBdriver == 'mysql') {
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 		$flight_array = array();
890 890
 		$temp_array = array();
891 891
         
892
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
892
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
893 893
 		{
894 894
 			$temp_array['marine_count'] = $row['nb'];
895 895
 			$temp_array['marine_country'] = $row['name'];
@@ -908,11 +908,11 @@  discard block
 block discarded – undo
908 908
 	* @return Array the callsign list
909 909
 	*
910 910
 	*/
911
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
911
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
912 912
 	{
913 913
 		global $globalDBdriver;
914
-		$filter_query = $this->getFilter($filters,true,true);
915
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
914
+		$filter_query = $this->getFilter($filters, true, true);
915
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
916 916
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
917 917
 		 if ($olderthanmonths > 0) {
918 918
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -926,28 +926,28 @@  discard block
 block discarded – undo
926 926
 		if ($year != '') {
927 927
 			if ($globalDBdriver == 'mysql') {
928 928
 				$query .= " AND YEAR(marine_output.date) = :year";
929
-				$query_values = array_merge($query_values,array(':year' => $year));
929
+				$query_values = array_merge($query_values, array(':year' => $year));
930 930
 			} else {
931 931
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
932
-				$query_values = array_merge($query_values,array(':year' => $year));
932
+				$query_values = array_merge($query_values, array(':year' => $year));
933 933
 			}
934 934
 		}
935 935
 		if ($month != '') {
936 936
 			if ($globalDBdriver == 'mysql') {
937 937
 				$query .= " AND MONTH(marine_output.date) = :month";
938
-				$query_values = array_merge($query_values,array(':month' => $month));
938
+				$query_values = array_merge($query_values, array(':month' => $month));
939 939
 			} else {
940 940
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
941
-				$query_values = array_merge($query_values,array(':month' => $month));
941
+				$query_values = array_merge($query_values, array(':month' => $month));
942 942
 			}
943 943
 		}
944 944
 		if ($day != '') {
945 945
 			if ($globalDBdriver == 'mysql') {
946 946
 				$query .= " AND DAY(marine_output.date) = :day";
947
-				$query_values = array_merge($query_values,array(':day' => $day));
947
+				$query_values = array_merge($query_values, array(':day' => $day));
948 948
 			} else {
949 949
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
950
-				$query_values = array_merge($query_values,array(':day' => $day));
950
+				$query_values = array_merge($query_values, array(':day' => $day));
951 951
 			}
952 952
 		}
953 953
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 		$callsign_array = array();
960 960
 		$temp_array = array();
961 961
         
962
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
962
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
963 963
 		{
964 964
 			$temp_array['callsign_icao'] = $row['ident'];
965 965
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 		$date_array = array();
1012 1012
 		$temp_array = array();
1013 1013
         
1014
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1014
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1015 1015
 		{
1016 1016
 			$temp_array['date_name'] = $row['date_name'];
1017 1017
 			$temp_array['date_count'] = $row['date_count'];
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			$datetime = new DateTime();
1038 1038
 			$offset = $datetime->format('P');
1039 1039
 		} else $offset = '+00:00';
1040
-		$filter_query = $this->getFilter($filters,true,true);
1040
+		$filter_query = $this->getFilter($filters, true, true);
1041 1041
 		if ($globalDBdriver == 'mysql') {
1042 1042
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1043 1043
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 		$date_array = array();
1059 1059
 		$temp_array = array();
1060 1060
         
1061
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1061
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1062 1062
 		{
1063 1063
 			$temp_array['date_name'] = $row['date_name'];
1064 1064
 			$temp_array['date_count'] = $row['date_count'];
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 			$datetime = new DateTime();
1084 1084
 			$offset = $datetime->format('P');
1085 1085
 		} else $offset = '+00:00';
1086
-		$filter_query = $this->getFilter($filters,true,true);
1086
+		$filter_query = $this->getFilter($filters, true, true);
1087 1087
 		if ($globalDBdriver == 'mysql') {
1088 1088
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1089 1089
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 		$date_array = array();
1105 1105
 		$temp_array = array();
1106 1106
         
1107
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1107
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1108 1108
 		{
1109 1109
 			$temp_array['date_name'] = $row['date_name'];
1110 1110
 			$temp_array['date_count'] = $row['date_count'];
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 		$date_array = array();
1152 1152
 		$temp_array = array();
1153 1153
         
1154
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1154
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1155 1155
 		{
1156 1156
 			$temp_array['month_name'] = $row['month_name'];
1157 1157
 			$temp_array['year_name'] = $row['year_name'];
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 			$datetime = new DateTime();
1181 1181
 			$offset = $datetime->format('P');
1182 1182
 		} else $offset = '+00:00';
1183
-		$filter_query = $this->getFilter($filters,true,true);
1183
+		$filter_query = $this->getFilter($filters, true, true);
1184 1184
 		if ($globalDBdriver == 'mysql') {
1185 1185
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1186 1186
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 		$date_array = array();
1202 1202
 		$temp_array = array();
1203 1203
         
1204
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1204
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1205 1205
 		{
1206 1206
 			$temp_array['year_name'] = $row['year_name'];
1207 1207
 			$temp_array['month_name'] = $row['month_name'];
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
 	* @return Array the hour list
1222 1222
 	*
1223 1223
 	*/
1224
-	public function countAllHours($orderby,$filters = array())
1224
+	public function countAllHours($orderby, $filters = array())
1225 1225
 	{
1226 1226
 		global $globalTimezone, $globalDBdriver;
1227 1227
 		if ($globalTimezone != '') {
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
 		$hour_array = array();
1270 1270
 		$temp_array = array();
1271 1271
         
1272
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1272
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1273 1273
 		{
1274 1274
 			$temp_array['hour_name'] = $row['hour_name'];
1275 1275
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1291,8 +1291,8 @@  discard block
 block discarded – undo
1291 1291
 	public function countAllHoursByDate($date, $filters = array())
1292 1292
 	{
1293 1293
 		global $globalTimezone, $globalDBdriver;
1294
-		$filter_query = $this->getFilter($filters,true,true);
1295
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1294
+		$filter_query = $this->getFilter($filters, true, true);
1295
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1296 1296
 		if ($globalTimezone != '') {
1297 1297
 			date_default_timezone_set($globalTimezone);
1298 1298
 			$datetime = new DateTime($date);
@@ -1300,12 +1300,12 @@  discard block
 block discarded – undo
1300 1300
 		} else $offset = '+00:00';
1301 1301
 
1302 1302
 		if ($globalDBdriver == 'mysql') {
1303
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1303
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1304 1304
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1305 1305
 								GROUP BY hour_name 
1306 1306
 								ORDER BY hour_name ASC";
1307 1307
 		} else {
1308
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1308
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1309 1309
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1310 1310
 								GROUP BY hour_name 
1311 1311
 								ORDER BY hour_name ASC";
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
 		$hour_array = array();
1318 1318
 		$temp_array = array();
1319 1319
         
1320
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1320
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1321 1321
 		{
1322 1322
 			$temp_array['hour_name'] = $row['hour_name'];
1323 1323
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1339,8 +1339,8 @@  discard block
 block discarded – undo
1339 1339
 	public function countAllHoursByIdent($ident, $filters = array())
1340 1340
 	{
1341 1341
 		global $globalTimezone, $globalDBdriver;
1342
-		$filter_query = $this->getFilter($filters,true,true);
1343
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1342
+		$filter_query = $this->getFilter($filters, true, true);
1343
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1344 1344
 		if ($globalTimezone != '') {
1345 1345
 			date_default_timezone_set($globalTimezone);
1346 1346
 			$datetime = new DateTime();
@@ -1348,12 +1348,12 @@  discard block
 block discarded – undo
1348 1348
 		} else $offset = '+00:00';
1349 1349
 
1350 1350
 		if ($globalDBdriver == 'mysql') {
1351
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1351
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1352 1352
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1353 1353
 								GROUP BY hour_name 
1354 1354
 								ORDER BY hour_name ASC";
1355 1355
 		} else {
1356
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1356
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1357 1357
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1358 1358
 								GROUP BY hour_name 
1359 1359
 								ORDER BY hour_name ASC";
@@ -1361,12 +1361,12 @@  discard block
 block discarded – undo
1361 1361
       
1362 1362
 		
1363 1363
 		$sth = $this->db->prepare($query);
1364
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1364
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1365 1365
       
1366 1366
 		$hour_array = array();
1367 1367
 		$temp_array = array();
1368 1368
         
1369
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1369
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1370 1370
 		{
1371 1371
 			$temp_array['hour_name'] = $row['hour_name'];
1372 1372
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1385,33 +1385,33 @@  discard block
 block discarded – undo
1385 1385
 	* @return Integer the number of vessels
1386 1386
 	*
1387 1387
 	*/
1388
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1388
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1389 1389
 	{
1390 1390
 		global $globalDBdriver;
1391 1391
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1392
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1392
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1393 1393
 		$query_values = array();
1394 1394
 		$query = '';
1395 1395
 		if ($year != '') {
1396 1396
 			if ($globalDBdriver == 'mysql') {
1397 1397
 				$query .= " AND YEAR(marine_output.date) = :year";
1398
-				$query_values = array_merge($query_values,array(':year' => $year));
1398
+				$query_values = array_merge($query_values, array(':year' => $year));
1399 1399
 			} else {
1400 1400
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1401
-				$query_values = array_merge($query_values,array(':year' => $year));
1401
+				$query_values = array_merge($query_values, array(':year' => $year));
1402 1402
 			}
1403 1403
 		}
1404 1404
 		if ($month != '') {
1405 1405
 			if ($globalDBdriver == 'mysql') {
1406 1406
 				$query .= " AND MONTH(marine_output.date) = :month";
1407
-				$query_values = array_merge($query_values,array(':month' => $month));
1407
+				$query_values = array_merge($query_values, array(':month' => $month));
1408 1408
 			} else {
1409 1409
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1410
-				$query_values = array_merge($query_values,array(':month' => $month));
1410
+				$query_values = array_merge($query_values, array(':month' => $month));
1411 1411
 			}
1412 1412
 		}
1413 1413
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1414
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1414
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1415 1415
 		
1416 1416
 		$sth = $this->db->prepare($queryi);
1417 1417
 		$sth->execute($query_values);
@@ -1424,32 +1424,32 @@  discard block
 block discarded – undo
1424 1424
 	* @return Integer the number of vessels
1425 1425
 	*
1426 1426
 	*/
1427
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1427
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
1428 1428
 	{
1429 1429
 		global $globalDBdriver;
1430
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1430
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1431 1431
 		$query_values = array();
1432 1432
 		$query = '';
1433 1433
 		if ($year != '') {
1434 1434
 			if ($globalDBdriver == 'mysql') {
1435 1435
 				$query .= " AND YEAR(marine_output.date) = :year";
1436
-				$query_values = array_merge($query_values,array(':year' => $year));
1436
+				$query_values = array_merge($query_values, array(':year' => $year));
1437 1437
 			} else {
1438 1438
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1439
-				$query_values = array_merge($query_values,array(':year' => $year));
1439
+				$query_values = array_merge($query_values, array(':year' => $year));
1440 1440
 			}
1441 1441
 		}
1442 1442
 		if ($month != '') {
1443 1443
 			if ($globalDBdriver == 'mysql') {
1444 1444
 				$query .= " AND MONTH(marine_output.date) = :month";
1445
-				$query_values = array_merge($query_values,array(':month' => $month));
1445
+				$query_values = array_merge($query_values, array(':month' => $month));
1446 1446
 			} else {
1447 1447
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1448
-				$query_values = array_merge($query_values,array(':month' => $month));
1448
+				$query_values = array_merge($query_values, array(':month' => $month));
1449 1449
 			}
1450 1450
 		}
1451 1451
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1452
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1452
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1453 1453
 		
1454 1454
 		$sth = $this->db->prepare($queryi);
1455 1455
 		$sth->execute($query_values);
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
 	public function countAllHoursFromToday($filters = array())
1467 1467
 	{
1468 1468
 		global $globalTimezone, $globalDBdriver;
1469
-		$filter_query = $this->getFilter($filters,true,true);
1469
+		$filter_query = $this->getFilter($filters, true, true);
1470 1470
 		if ($globalTimezone != '') {
1471 1471
 			date_default_timezone_set($globalTimezone);
1472 1472
 			$datetime = new DateTime();
@@ -1474,12 +1474,12 @@  discard block
 block discarded – undo
1474 1474
 		} else $offset = '+00:00';
1475 1475
 
1476 1476
 		if ($globalDBdriver == 'mysql') {
1477
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1477
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1478 1478
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1479 1479
 								GROUP BY hour_name 
1480 1480
 								ORDER BY hour_name ASC";
1481 1481
 		} else {
1482
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1482
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1483 1483
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1484 1484
 								GROUP BY hour_name 
1485 1485
 								ORDER BY hour_name ASC";
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
 		$hour_array = array();
1492 1492
 		$temp_array = array();
1493 1493
         
1494
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1494
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1495 1495
 		{
1496 1496
 			$temp_array['hour_name'] = $row['hour_name'];
1497 1497
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1510,9 +1510,9 @@  discard block
 block discarded – undo
1510 1510
 	*/
1511 1511
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1512 1512
 	{
1513
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1513
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1514 1514
 
1515
-		$query  = "SELECT marine_output.marine_id
1515
+		$query = "SELECT marine_output.marine_id
1516 1516
 				FROM marine_output 
1517 1517
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1518 1518
         
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
 		$sth = $this->db->prepare($query);
1521 1521
 		$sth->execute();
1522 1522
 
1523
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1523
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1524 1524
 		{
1525 1525
 			return $row['marine_id'];
1526 1526
 		}
@@ -1545,23 +1545,23 @@  discard block
 block discarded – undo
1545 1545
 		}
1546 1546
 		
1547 1547
 		$current_date = date("Y-m-d H:i:s");
1548
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1548
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1549 1549
 		
1550 1550
 		$diff = abs(strtotime($current_date) - strtotime($date));
1551 1551
 
1552
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1552
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1553 1553
 		$years = $time_array['years'];
1554 1554
 		
1555
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1555
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1556 1556
 		$months = $time_array['months'];
1557 1557
 		
1558
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1558
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1559 1559
 		$days = $time_array['days'];
1560
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1560
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1561 1561
 		$hours = $time_array['hours'];
1562
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1562
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1563 1563
 		$minutes = $time_array['minutes'];
1564
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1564
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1565 1565
 		
1566 1566
 		return $time_array;
1567 1567
 	}
@@ -1584,63 +1584,63 @@  discard block
 block discarded – undo
1584 1584
 			$temp_array['direction_degree'] = $direction;
1585 1585
 			$temp_array['direction_shortname'] = "N";
1586 1586
 			$temp_array['direction_fullname'] = "North";
1587
-		} elseif ($direction >= 22.5 && $direction < 45){
1587
+		} elseif ($direction >= 22.5 && $direction < 45) {
1588 1588
 			$temp_array['direction_degree'] = $direction;
1589 1589
 			$temp_array['direction_shortname'] = "NNE";
1590 1590
 			$temp_array['direction_fullname'] = "North-Northeast";
1591
-		} elseif ($direction >= 45 && $direction < 67.5){
1591
+		} elseif ($direction >= 45 && $direction < 67.5) {
1592 1592
 			$temp_array['direction_degree'] = $direction;
1593 1593
 			$temp_array['direction_shortname'] = "NE";
1594 1594
 			$temp_array['direction_fullname'] = "Northeast";
1595
-		} elseif ($direction >= 67.5 && $direction < 90){
1595
+		} elseif ($direction >= 67.5 && $direction < 90) {
1596 1596
 			$temp_array['direction_degree'] = $direction;
1597 1597
 			$temp_array['direction_shortname'] = "ENE";
1598 1598
 			$temp_array['direction_fullname'] = "East-Northeast";
1599
-		} elseif ($direction >= 90 && $direction < 112.5){
1599
+		} elseif ($direction >= 90 && $direction < 112.5) {
1600 1600
 			$temp_array['direction_degree'] = $direction;
1601 1601
 			$temp_array['direction_shortname'] = "E";
1602 1602
 			$temp_array['direction_fullname'] = "East";
1603
-		} elseif ($direction >= 112.5 && $direction < 135){
1603
+		} elseif ($direction >= 112.5 && $direction < 135) {
1604 1604
 			$temp_array['direction_degree'] = $direction;
1605 1605
 			$temp_array['direction_shortname'] = "ESE";
1606 1606
 			$temp_array['direction_fullname'] = "East-Southeast";
1607
-		} elseif ($direction >= 135 && $direction < 157.5){
1607
+		} elseif ($direction >= 135 && $direction < 157.5) {
1608 1608
 			$temp_array['direction_degree'] = $direction;
1609 1609
 			$temp_array['direction_shortname'] = "SE";
1610 1610
 			$temp_array['direction_fullname'] = "Southeast";
1611
-		} elseif ($direction >= 157.5 && $direction < 180){
1611
+		} elseif ($direction >= 157.5 && $direction < 180) {
1612 1612
 			$temp_array['direction_degree'] = $direction;
1613 1613
 			$temp_array['direction_shortname'] = "SSE";
1614 1614
 			$temp_array['direction_fullname'] = "South-Southeast";
1615
-		} elseif ($direction >= 180 && $direction < 202.5){
1615
+		} elseif ($direction >= 180 && $direction < 202.5) {
1616 1616
 			$temp_array['direction_degree'] = $direction;
1617 1617
 			$temp_array['direction_shortname'] = "S";
1618 1618
 			$temp_array['direction_fullname'] = "South";
1619
-		} elseif ($direction >= 202.5 && $direction < 225){
1619
+		} elseif ($direction >= 202.5 && $direction < 225) {
1620 1620
 			$temp_array['direction_degree'] = $direction;
1621 1621
 			$temp_array['direction_shortname'] = "SSW";
1622 1622
 			$temp_array['direction_fullname'] = "South-Southwest";
1623
-		} elseif ($direction >= 225 && $direction < 247.5){
1623
+		} elseif ($direction >= 225 && $direction < 247.5) {
1624 1624
 			$temp_array['direction_degree'] = $direction;
1625 1625
 			$temp_array['direction_shortname'] = "SW";
1626 1626
 			$temp_array['direction_fullname'] = "Southwest";
1627
-		} elseif ($direction >= 247.5 && $direction < 270){
1627
+		} elseif ($direction >= 247.5 && $direction < 270) {
1628 1628
 			$temp_array['direction_degree'] = $direction;
1629 1629
 			$temp_array['direction_shortname'] = "WSW";
1630 1630
 			$temp_array['direction_fullname'] = "West-Southwest";
1631
-		} elseif ($direction >= 270 && $direction < 292.5){
1631
+		} elseif ($direction >= 270 && $direction < 292.5) {
1632 1632
 			$temp_array['direction_degree'] = $direction;
1633 1633
 			$temp_array['direction_shortname'] = "W";
1634 1634
 			$temp_array['direction_fullname'] = "West";
1635
-		} elseif ($direction >= 292.5 && $direction < 315){
1635
+		} elseif ($direction >= 292.5 && $direction < 315) {
1636 1636
 			$temp_array['direction_degree'] = $direction;
1637 1637
 			$temp_array['direction_shortname'] = "WNW";
1638 1638
 			$temp_array['direction_fullname'] = "West-Northwest";
1639
-		} elseif ($direction >= 315 && $direction < 337.5){
1639
+		} elseif ($direction >= 315 && $direction < 337.5) {
1640 1640
 			$temp_array['direction_degree'] = $direction;
1641 1641
 			$temp_array['direction_shortname'] = "NW";
1642 1642
 			$temp_array['direction_fullname'] = "Northwest";
1643
-		} elseif ($direction >= 337.5 && $direction < 360){
1643
+		} elseif ($direction >= 337.5 && $direction < 360) {
1644 1644
 			$temp_array['direction_degree'] = $direction;
1645 1645
 			$temp_array['direction_shortname'] = "NNW";
1646 1646
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1657,11 +1657,11 @@  discard block
 block discarded – undo
1657 1657
 	* @param Float $longitude longitute of the flight
1658 1658
 	* @return String the countrie
1659 1659
 	*/
1660
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1660
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1661 1661
 	{
1662 1662
 		global $globalDBdriver, $globalDebug;
1663
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1664
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1663
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1664
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1665 1665
 	
1666 1666
 		$Connection = new Connection($this->db);
1667 1667
 		if (!$Connection->tableExists('countries')) return '';
@@ -1701,7 +1701,7 @@  discard block
 block discarded – undo
1701 1701
 	public function getCountryFromISO2($iso2)
1702 1702
 	{
1703 1703
 		global $globalDBdriver, $globalDebug;
1704
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1704
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1705 1705
 	
1706 1706
 		$Connection = new Connection($this->db);
1707 1707
 		if (!$Connection->tableExists('countries')) return '';
@@ -1749,7 +1749,7 @@  discard block
 block discarded – undo
1749 1749
 		
1750 1750
 		$bitly_data = json_decode($bitly_data);
1751 1751
 		$bitly_url = '';
1752
-		if ($bitly_data->status_txt = "OK"){
1752
+		if ($bitly_data->status_txt = "OK") {
1753 1753
 			$bitly_url = $bitly_data->data->url;
1754 1754
 		}
1755 1755
 
@@ -1763,11 +1763,11 @@  discard block
 block discarded – undo
1763 1763
 	* @return Array the vessel type list
1764 1764
 	*
1765 1765
 	*/
1766
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1766
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1767 1767
 	{
1768 1768
 		global $globalDBdriver;
1769
-		$filter_query = $this->getFilter($filters,true,true);
1770
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count 
1769
+		$filter_query = $this->getFilter($filters, true, true);
1770
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count 
1771 1771
 		    FROM marine_output ".$filter_query." marine_output.type  <> ''";
1772 1772
 		if ($olderthanmonths > 0) {
1773 1773
 			if ($globalDBdriver == 'mysql') {
@@ -1787,28 +1787,28 @@  discard block
 block discarded – undo
1787 1787
 		if ($year != '') {
1788 1788
 			if ($globalDBdriver == 'mysql') {
1789 1789
 				$query .= " AND YEAR(marine_output.date) = :year";
1790
-				$query_values = array_merge($query_values,array(':year' => $year));
1790
+				$query_values = array_merge($query_values, array(':year' => $year));
1791 1791
 			} else {
1792 1792
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1793
-				$query_values = array_merge($query_values,array(':year' => $year));
1793
+				$query_values = array_merge($query_values, array(':year' => $year));
1794 1794
 			}
1795 1795
 		}
1796 1796
 		if ($month != '') {
1797 1797
 			if ($globalDBdriver == 'mysql') {
1798 1798
 				$query .= " AND MONTH(marine_output.date) = :month";
1799
-				$query_values = array_merge($query_values,array(':month' => $month));
1799
+				$query_values = array_merge($query_values, array(':month' => $month));
1800 1800
 			} else {
1801 1801
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1802
-				$query_values = array_merge($query_values,array(':month' => $month));
1802
+				$query_values = array_merge($query_values, array(':month' => $month));
1803 1803
 			}
1804 1804
 		}
1805 1805
 		if ($day != '') {
1806 1806
 			if ($globalDBdriver == 'mysql') {
1807 1807
 				$query .= " AND DAY(marine_output.date) = :day";
1808
-				$query_values = array_merge($query_values,array(':day' => $day));
1808
+				$query_values = array_merge($query_values, array(':day' => $day));
1809 1809
 			} else {
1810 1810
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1811
-				$query_values = array_merge($query_values,array(':day' => $day));
1811
+				$query_values = array_merge($query_values, array(':day' => $day));
1812 1812
 			}
1813 1813
 		}
1814 1814
 		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC";
@@ -1817,7 +1817,7 @@  discard block
 block discarded – undo
1817 1817
 		$sth->execute($query_values);
1818 1818
 		$marine_array = array();
1819 1819
 		$temp_array = array();
1820
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1820
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1821 1821
 		{
1822 1822
 			$temp_array['marine_type'] = $row['marine_type'];
1823 1823
 			$temp_array['marine_type_count'] = $row['marine_type_count'];
@@ -1832,13 +1832,13 @@  discard block
 block discarded – undo
1832 1832
 	* @return Array the tracker information
1833 1833
 	*
1834 1834
 	*/
1835
-	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1835
+	public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
1836 1836
 	{
1837 1837
 		global $globalTimezone, $globalDBdriver;
1838 1838
 		date_default_timezone_set('UTC');
1839 1839
 		$query_values = array();
1840 1840
 		$additional_query = '';
1841
-		$filter_query = $this->getFilter($filters,true,true);
1841
+		$filter_query = $this->getFilter($filters, true, true);
1842 1842
 		if ($q != "")
1843 1843
 		{
1844 1844
 			if (!is_string($q))
@@ -1846,8 +1846,8 @@  discard block
 block discarded – undo
1846 1846
 				return false;
1847 1847
 			} else {
1848 1848
 				$q_array = explode(" ", $q);
1849
-				foreach ($q_array as $q_item){
1850
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1849
+				foreach ($q_array as $q_item) {
1850
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1851 1851
 					$additional_query .= " AND (";
1852 1852
 					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1853 1853
 					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
@@ -1859,42 +1859,42 @@  discard block
 block discarded – undo
1859 1859
 		}
1860 1860
 		if ($callsign != "")
1861 1861
 		{
1862
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1862
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1863 1863
 			if (!is_string($callsign))
1864 1864
 			{
1865 1865
 				return false;
1866 1866
 			} else {
1867 1867
 				$additional_query .= " AND marine_output.ident = :callsign";
1868
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
1868
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
1869 1869
 			}
1870 1870
 		}
1871 1871
 		if ($mmsi != "")
1872 1872
 		{
1873
-			$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
1873
+			$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
1874 1874
 			if (!is_numeric($mmsi))
1875 1875
 			{
1876 1876
 				return false;
1877 1877
 			} else {
1878 1878
 				$additional_query .= " AND marine_output.mmsi = :mmsi";
1879
-				$query_values = array_merge($query_values,array(':mmsi' => $mmsi));
1879
+				$query_values = array_merge($query_values, array(':mmsi' => $mmsi));
1880 1880
 			}
1881 1881
 		}
1882 1882
 		if ($imo != "")
1883 1883
 		{
1884
-			$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1884
+			$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1885 1885
 			if (!is_numeric($imo))
1886 1886
 			{
1887 1887
 				return false;
1888 1888
 			} else {
1889 1889
 				$additional_query .= " AND marine_output.imo = :imo";
1890
-				$query_values = array_merge($query_values,array(':imo' => $imo));
1890
+				$query_values = array_merge($query_values, array(':imo' => $imo));
1891 1891
 			}
1892 1892
 		}
1893 1893
 		if ($date_posted != "")
1894 1894
 		{
1895 1895
 			$date_array = explode(",", $date_posted);
1896
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
1897
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
1896
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
1897
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
1898 1898
 			if ($globalTimezone != '') {
1899 1899
 				date_default_timezone_set($globalTimezone);
1900 1900
 				$datetime = new DateTime();
@@ -1921,8 +1921,8 @@  discard block
 block discarded – undo
1921 1921
 		if ($limit != "")
1922 1922
 		{
1923 1923
 			$limit_array = explode(",", $limit);
1924
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1925
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1924
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1925
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1926 1926
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1927 1927
 			{
1928 1928
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1940,28 +1940,28 @@  discard block
 block discarded – undo
1940 1940
 			}
1941 1941
 		}
1942 1942
 		if ($origLat != "" && $origLon != "" && $dist != "") {
1943
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
1943
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
1944 1944
 			if ($globalDBdriver == 'mysql') {
1945
-				$query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance 
1945
+				$query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance 
1946 1946
 				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
1947 1947
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
1948 1948
 			} else {
1949
-				$query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
1949
+				$query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
1950 1950
 				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
1951 1951
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query;
1952 1952
 			}
1953 1953
 		} else {
1954
-			$query  = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
1954
+			$query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
1955 1955
 			    ".$additional_query."
1956 1956
 			    ".$orderby_query;
1957 1957
 		}
1958
-		$marine_array = $this->getDataFromDB($query, $query_values,$limit_query);
1958
+		$marine_array = $this->getDataFromDB($query, $query_values, $limit_query);
1959 1959
 		return $marine_array;
1960 1960
 	}
1961 1961
 
1962 1962
 	public function getOrderBy()
1963 1963
 	{
1964
-		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1964
+		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1965 1965
 		
1966 1966
 		return $orderby;
1967 1967
 		
Please login to merge, or discard this patch.
live-czml.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
     $s3 = sin($bank/2);
49 49
     $c1c2 = $c1*$c2;
50 50
     $s1s2 = $s1*$s2;
51
-    $w =$c1c2*$c3 - $s1s2*$s3;
52
-    $x =$c1c2*$s3 + $s1s2*$c3;
53
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
54
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
55
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
51
+    $w = $c1c2*$c3 - $s1s2*$s3;
52
+    $x = $c1c2*$s3 + $s1s2*$c3;
53
+    $y = $s1*$c2*$c3 + $c1*$s2*$s3;
54
+    $z = $c1*$s2*$c3 - $s1*$c2*$s3;
55
+    return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w);
56 56
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
57 57
 
58 58
 }
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 $min = false;
74 74
 $allhistory = false;
75 75
 $filter['source'] = array();
76
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
77
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
78
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
79
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
80
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
81
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
82
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
83
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
84
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
85
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
86
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
76
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
77
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
79
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
80
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
81
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
82
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING);
83
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
84
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
85
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
86
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
87 87
 /*
88 88
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
89 89
 	$min = true;
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
 	$from_archive = true;
131 131
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
132 132
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
133
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
134
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
135
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
136
-	$begindate = date('Y-m-d H:i:s',$begindate);
137
-	$enddate = date('Y-m-d H:i:s',$enddate);
138
-	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
133
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
134
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
135
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
136
+	$begindate = date('Y-m-d H:i:s', $begindate);
137
+	$enddate = date('Y-m-d H:i:s', $enddate);
138
+	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter);
139 139
 } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) {
140 140
 	$from_archive = true;
141 141
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
@@ -145,46 +145,46 @@  discard block
 block discarded – undo
145 145
 	$begindate = $_COOKIE['archive_begin'];
146 146
 	$enddate = $_COOKIE['archive_end'];
147 147
 
148
-	$archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT);
149
-	$begindate = date('Y-m-d H:i:s',$begindate);
150
-	$enddate = date('Y-m-d H:i:s',$enddate);
148
+	$archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT);
149
+	$begindate = date('Y-m-d H:i:s', $begindate);
150
+	$enddate = date('Y-m-d H:i:s', $enddate);
151 151
 //	echo 'Begin : '.$begindate.' - End : '.$enddate."\n";
152
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
152
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
153 153
 } elseif ($tracker) {
154 154
 	$coord = array();
155 155
 	if (isset($_GET['coord']) && $_GET['coord'] != '') {
156
-		$coord = explode(',',$_GET['coord']);
157
-		if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
156
+		$coord = explode(',', $_GET['coord']);
157
+		if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
158 158
 		    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
159 159
 			$coord = array();
160 160
 		}
161 161
 	}
162
-	$spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,true);
162
+	$spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord, $filter, true);
163 163
 } elseif ($marine) {
164 164
 	$coord = array();
165 165
 	if (isset($_GET['coord']) && $_GET['coord'] != '') {
166
-		$coord = explode(',',$_GET['coord']);
167
-		if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
166
+		$coord = explode(',', $_GET['coord']);
167
+		if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
168 168
 		    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
169 169
 			$coord = array();
170 170
 		}
171 171
 	}
172
-	$spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,true);
172
+	$spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, true);
173 173
 } else {
174 174
 	$coord = array();
175 175
 	if (isset($_GET['coord']) && $_GET['coord'] != '') {
176
-		$coord = explode(',',$_GET['coord']);
177
-		if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
176
+		$coord = explode(',', $_GET['coord']);
177
+		if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
178 178
 		    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
179 179
 			$coord = array();
180 180
 		}
181 181
 	}
182
-	$spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,true);
182
+	$spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, true);
183 183
 }
184 184
 //print_r($spotter_array);
185 185
 if (!empty($spotter_array) && isset($coord)) {
186 186
 	if (isset($_GET['archive'])) {
187
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
187
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
188 188
 	} elseif ($tracker) {
189 189
 		$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
190 190
 	} elseif ($marine) {
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 	if ($flightcnt == '') $flightcnt = 0;
196 196
 } else $flightcnt = 0;
197 197
 
198
-$sqltime = round(microtime(true)-$begintime,2);
198
+$sqltime = round(microtime(true) - $begintime, 2);
199 199
 $minitime = time();
200 200
 $maxitime = 0;
201
-$lastupdate = filter_input(INPUT_GET,'update',FILTER_SANITIZE_NUMBER_INT);
201
+$lastupdate = filter_input(INPUT_GET, 'update', FILTER_SANITIZE_NUMBER_INT);
202 202
 $modelsdb = array();
203 203
 if (file_exists(dirname(__FILE__).'/models/modelsdb')) {
204
-	if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) {
205
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
206
-			if (isset($row[1]) ){
204
+	if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) {
205
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
206
+			if (isset($row[1])) {
207 207
 				$model = $row[0];
208 208
 				$modelsdb[$model] = $row[1];
209 209
 			}
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 }
214 214
 $modelsdb2 = array();
215 215
 if (file_exists(dirname(__FILE__).'/models/gltf2/modelsdb')) {
216
-	if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb','r')) !== FALSE) {
217
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
218
-			if (isset($row[1]) ){
216
+	if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb', 'r')) !== FALSE) {
217
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
218
+			if (isset($row[1])) {
219 219
 				$model = $row[0];
220 220
 				$modelsdb2[$model] = $row[1];
221 221
 			}
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 if (!empty($spotter_array) && is_array($spotter_array))
254 254
 {
255 255
 	$nblatlong = 0;
256
-	foreach($spotter_array as $spotter_item)
256
+	foreach ($spotter_array as $spotter_item)
257 257
 	{
258 258
 		$j++;
259 259
 		//if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND';
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 			$output .= '"lastupdate": "'.$lastupdate.'",';
296 296
 			$output .= '"format": "'.$spotter_item['format_source'].'",';
297 297
 			if ($tracker) {
298
-				$output.= '"type": "tracker"';
298
+				$output .= '"type": "tracker"';
299 299
 			} elseif ($marine) {
300
-				$output.= '"type": "marine"';
300
+				$output .= '"type": "marine"';
301 301
 			} else {
302 302
 				if (isset($globalMap3DLiveries) && $globalMap3DLiveries) {
303 303
 					$aircraft_icao = $spotter_item['aircraft_icao'];
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
 						if (isset($airline_icao)) {
312 312
 							$imagefile = $aircraft_icao.'-'.$airline_icao.'.png';
313 313
 							if (file_exists(dirname(__FILE__).'/models/gltf2/liveries/'.$imagefile)) {
314
-								$output.= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",';
314
+								$output .= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",';
315 315
 							}
316 316
 						}
317 317
 					}
318
-					if ($ident != '') $output.= '"ident": "'.$ident.'",';
318
+					if ($ident != '') $output .= '"ident": "'.$ident.'",';
319 319
 				}
320
-				$output.= '"gltf2": %gltf2%,';
321
-				$output.= '"type": "flight"';
320
+				$output .= '"gltf2": %gltf2%,';
321
+				$output .= '"type": "flight"';
322 322
 			}
323 323
 			$output .= '},';
324 324
 
@@ -671,8 +671,8 @@  discard block
 block discarded – undo
671 671
 					$output .= '},';
672 672
 				}
673 673
 			}
674
-			if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output);
675
-			else $output = str_replace('%onground%','false',$output);
674
+			if (isset($onground) && $onground) $output = str_replace('%onground%', 'true', $output);
675
+			else $output = str_replace('%onground%', 'false', $output);
676 676
 
677 677
 	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
678 678
 			//$output .= '"heightReference": "'.$heightrelative.'",';
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 			$output .= '"cartographicDegrees": [';
688 688
 			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
689 689
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
690
-			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
690
+			$output .= '"'.date("c", strtotime($spotter_item['date'])).'", ';
691 691
 			$output .= $spotter_item['longitude'].', ';
692 692
 			$output .= $spotter_item['latitude'];
693 693
 			$prevlong = $spotter_item['longitude'];
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
716 716
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
717 717
 		} else {
718
-			$nblatlong = $nblatlong+1;
719
-			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
718
+			$nblatlong = $nblatlong + 1;
719
+			$output .= ',"'.date("c", strtotime($spotter_item['date'])).'", ';
720 720
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
721 721
 			if ($spotter_item['ground_speed'] == 0) {
722 722
 				$output .= $prevlong.', ';
@@ -756,17 +756,17 @@  discard block
 block discarded – undo
756 756
 }
757 757
 $output .= ']';
758 758
 if (isset($globalArchive) && $globalArchive === TRUE) {
759
-	if ((time()-$globalLiveInterval) > $minitime) {
760
-		if (time()-$globalLiveInterval > $maxitime) {
761
-			$output = str_replace('%minitime%',date("c",$maxitime),$output);
759
+	if ((time() - $globalLiveInterval) > $minitime) {
760
+		if (time() - $globalLiveInterval > $maxitime) {
761
+			$output = str_replace('%minitime%', date("c", $maxitime), $output);
762 762
 		} else {
763
-			$output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
763
+			$output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output);
764 764
 		}
765 765
 	}
766
-	else $output = str_replace('%minitime%',date("c",$minitime),$output);
767
-} else $output = str_replace('%minitime%',date("c",$minitime),$output);
768
-$output = str_replace('%maxitime%',date("c",$maxitime),$output);
769
-if ($gltf2) $output = str_replace('%gltf2%','true',$output);
770
-else $output = str_replace('%gltf2%','false',$output);
766
+	else $output = str_replace('%minitime%', date("c", $minitime), $output);
767
+} else $output = str_replace('%minitime%', date("c", $minitime), $output);
768
+$output = str_replace('%maxitime%', date("c", $maxitime), $output);
769
+if ($gltf2) $output = str_replace('%gltf2%', 'true', $output);
770
+else $output = str_replace('%gltf2%', 'false', $output);
771 771
 print $output;
772 772
 ?>
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
 $min = true;
56 56
 $allhistory = false;
57 57
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
68
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
58
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
59
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
60
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
61
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
62
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
63
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
64
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING);
65
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
66
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
67
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
68
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
69 69
 
70 70
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
71 71
 	$min = true;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 $spotter_array = array();
75 75
 
76 76
 if (isset($_GET['ident'])) {
77
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
77
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
78 78
 	if ($tracker) {
79 79
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
80 80
 	} elseif ($marine) {
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 	$allhistory = true;
90 90
 } elseif (isset($_GET['flightaware_id'])) {
91
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
91
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
92 92
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
93 93
 	if (empty($spotter_array)) {
94 94
 		$from_archive = true;
@@ -96,50 +96,50 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 	$allhistory = true;
98 98
 } elseif (isset($_GET['famtrack_id'])) {
99
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
99
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
100 100
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
101 101
 	$allhistory = true;
102 102
 } elseif (isset($_GET['fammarine_id'])) {
103
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
103
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
104 104
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
105 105
 	$allhistory = true;
106 106
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) {
107 107
 //} elseif (isset($_GET['coord'])) {
108 108
 	$usecoord = true;
109
-	$coord = explode(',',$_GET['coord']);
110
-	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
109
+	$coord = explode(',', $_GET['coord']);
110
+	if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
111 111
 	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
112 112
 		if ($tracker) {
113
-			$spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter);
113
+			$spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter);
114 114
 		} elseif ($marine) {
115
-			$spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter);
115
+			$spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter);
116 116
 		} else {
117
-			$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter);
117
+			$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter);
118 118
 		}
119 119
 	}
120 120
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) {
121 121
 	$usecoord = true;
122
-	$coord = explode(',',$_GET['coord']);
123
-	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
122
+	$coord = explode(',', $_GET['coord']);
123
+	if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
124 124
 	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
125 125
 		if ($tracker) {
126
-			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
126
+			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
127 127
 		} elseif ($marine) {
128
-			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
128
+			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
129 129
 		} else {
130
-			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
130
+			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
131 131
 		}
132 132
 	}
133 133
 } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) {
134 134
 	$from_archive = true;
135 135
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
136 136
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
137
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
138
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
139
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
140
-	$begindate = date('Y-m-d H:i:s',$begindate);
141
-	$enddate = date('Y-m-d H:i:s',$enddate);
142
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
137
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
138
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
139
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
140
+	$begindate = date('Y-m-d H:i:s', $begindate);
141
+	$enddate = date('Y-m-d H:i:s', $enddate);
142
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
143 143
 } elseif ($min) {
144 144
 	if ($tracker) {
145 145
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
 #	$min = true;
152 152
 } else {
153 153
 	if ($tracker) {
154
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
154
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
155 155
 	} elseif ($marine) {
156
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
156
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
157 157
 	} else {
158
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
158
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
159 159
 	}
160 160
 }
161 161
 
162 162
 if ($usecoord) {
163 163
 	if (isset($_GET['archive'])) {
164
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
164
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
165 165
 	} else {
166 166
 		if ($tracker) {
167 167
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 	if ($flightcnt == '') $flightcnt = 0;
175 175
 } else $flightcnt = 0;
176 176
 
177
-$sqltime = round(microtime(true)-$begintime,2);
177
+$sqltime = round(microtime(true) - $begintime, 2);
178 178
 
179
-$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
179
+$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
180 180
 if ($currenttime != '') $currenttime = round($currenttime/1000);
181 181
 
182 182
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		if (!empty($spotter_array) && is_array($spotter_array))
196 196
 		{
197 197
 			$output .= '"features": [';
198
-			foreach($spotter_array as $spotter_item)
198
+			foreach ($spotter_array as $spotter_item)
199 199
 			{
200 200
 				$j++;
201 201
 				date_default_timezone_set('UTC');
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 */
252 252
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
253 253
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
254
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
255
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
254
+							if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",';
255
+							else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",';
256 256
 							//"
257 257
 						} else {
258 258
 							if ($compress) $output .= '"c": "NA",';
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
262 262
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
263 263
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
264
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
264
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
265 265
 						} elseif (isset($spotter_item['aircraft_type'])) {
266 266
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
267 267
 						} elseif (!$min) {
@@ -404,26 +404,26 @@  discard block
 block discarded – undo
404 404
 						if ($currenttime != '') {
405 405
 							if (strtotime($spotter_item['date']) < $currenttime) {
406 406
 								if (isset($archivespeed)) {
407
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
407
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
408 408
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
409 409
 								} elseif ($usenextlatlon) {
410
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
410
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
411 411
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
412 412
 								}
413 413
 							}
414 414
 						} else {
415 415
 							if (isset($archivespeed)) {
416
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
416
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed);
417 417
 								$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
418 418
 							} elseif ($usenextlatlon) {
419
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
419
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']);
420 420
 								$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
421 421
 							}
422 422
 						}
423 423
 
424 424
 						if (!$min) $output .= '"image": "'.$image.'",';
425 425
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
426
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
426
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
427 427
 						}
428 428
 						if (isset($spotter_item['image_source_website'])) {
429 429
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
446 446
 						}
447 447
 						if (isset($spotter_item['acars'])) {
448
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
448
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
449 449
 						}
450 450
 						// type when not aircraft ?
451 451
 						if (isset($spotter_item['type'])) {
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 								if ($currenttime != '') {
466 466
 									if (strtotime($spotter_item['date']) < $currenttime) {
467 467
 										if (!isset($archivespeed)) $archivespeed = 1;
468
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed,$currenttime-strtotime($spotter_item['date']));
468
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed, $currenttime - strtotime($spotter_item['date']));
469 469
 										$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
470 470
 									} else {
471 471
 										$output .= $spotter_item['longitude'].', ';
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
                 
535 535
 			}
536 536
 */
537
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
537
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
538 538
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
539 539
 				
540 540
 				if (
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
543 543
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
544 544
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
545
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
545
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
546 546
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
547
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
547
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
548 548
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
549
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
549
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
550 550
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
551 551
 				    ) {
552 552
 					if ($tracker) {
@@ -583,9 +583,9 @@  discard block
 block discarded – undo
583 583
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
584 584
 							}
585 585
 							$output_history .= '[';
586
-							$output_history .=  $spotter_history['longitude'].', ';
587
-							$output_history .=  $spotter_history['latitude'].', ';
588
-							$output_history .=  $spotter_history['altitude']*30.48;
586
+							$output_history .= $spotter_history['longitude'].', ';
587
+							$output_history .= $spotter_history['latitude'].', ';
588
+							$output_history .= $spotter_history['altitude']*30.48;
589 589
 							$output_history .= '],';
590 590
 							/*
591 591
 							if ($from_archive === false) {
@@ -603,8 +603,8 @@  discard block
 block discarded – undo
603 603
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
604 604
 							} else $d = true;
605 605
 							$output_history .= '[';
606
-							$output_history .=  $spotter_history['longitude'].', ';
607
-							$output_history .=  $spotter_history['latitude'];
606
+							$output_history .= $spotter_history['longitude'].', ';
607
+							$output_history .= $spotter_history['latitude'];
608 608
 							$output_history .= '],';
609 609
 							/*
610 610
 							if ($from_archive === false) {
@@ -620,9 +620,9 @@  discard block
 block discarded – undo
620 620
 					
621 621
 						if ($from_archive === false) {
622 622
 							$output_historyd = '[';
623
-							$output_historyd .=  $spotter_item['longitude'].', ';
624
-							$output_historyd .=  $spotter_item['latitude'];
625
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
623
+							$output_historyd .= $spotter_item['longitude'].', ';
624
+							$output_historyd .= $spotter_item['latitude'];
625
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
626 626
 							$output_historyd .= '],';
627 627
 							//$output_history = $output_historyd.$output_history;
628 628
 							$output_history = $output_history.$output_historyd;
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 					}
637 637
 				}
638 638
 				
639
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
639
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
640 640
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
641 641
 				     && (isset($spotter_item['departure_airport']) 
642 642
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 
671 671
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
672 672
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
673
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
673
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
674 674
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
675 675
 				     && (isset($spotter_item['arrival_airport']) 
676 676
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 			$output  = substr($output, 0, -1);
702 702
 			$output .= ']';
703 703
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
704
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
704
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
705 705
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
706 706
 			$output .= '"fc": "'.$j.'"';
707 707
 		} else {
Please login to merge, or discard this patch.