@@ -5,23 +5,23 @@ discard block  | 
                                                    ||
| 5 | 5 | $marine = false;  | 
                                                        
| 6 | 6 | $usecoord = false;  | 
                                                        
| 7 | 7 |  if (isset($_GET['tracker'])) { | 
                                                        
| 8 | - $tracker = true;  | 
                                                        |
| 8 | + $tracker = true;  | 
                                                        |
| 9 | 9 | }  | 
                                                        
| 10 | 10 |  if (isset($_GET['marine'])) { | 
                                                        
| 11 | - $marine = true;  | 
                                                        |
| 11 | + $marine = true;  | 
                                                        |
| 12 | 12 | }  | 
                                                        
| 13 | 13 |  if ($tracker) { | 
                                                        
| 14 | -    require_once('require/class.Tracker.php'); | 
                                                        |
| 15 | -    require_once('require/class.TrackerLive.php'); | 
                                                        |
| 16 | -    //require_once('require/class.TrackerArchive.php'); | 
                                                        |
| 14 | +	require_once('require/class.Tracker.php'); | 
                                                        |
| 15 | +	require_once('require/class.TrackerLive.php'); | 
                                                        |
| 16 | +	//require_once('require/class.TrackerArchive.php'); | 
                                                        |
| 17 | 17 |  } elseif ($marine) { | 
                                                        
| 18 | -    require_once('require/class.Marine.php'); | 
                                                        |
| 19 | -    require_once('require/class.MarineLive.php'); | 
                                                        |
| 20 | -    //require_once('require/class.MarineArchive.php'); | 
                                                        |
| 18 | +	require_once('require/class.Marine.php'); | 
                                                        |
| 19 | +	require_once('require/class.MarineLive.php'); | 
                                                        |
| 20 | +	//require_once('require/class.MarineArchive.php'); | 
                                                        |
| 21 | 21 |  } else { | 
                                                        
| 22 | -    require_once('require/class.Spotter.php'); | 
                                                        |
| 23 | -    require_once('require/class.SpotterLive.php'); | 
                                                        |
| 24 | -    require_once('require/class.SpotterArchive.php'); | 
                                                        |
| 22 | +	require_once('require/class.Spotter.php'); | 
                                                        |
| 23 | +	require_once('require/class.SpotterLive.php'); | 
                                                        |
| 24 | +	require_once('require/class.SpotterArchive.php'); | 
                                                        |
| 25 | 25 | }  | 
                                                        
| 26 | 26 | |
| 27 | 27 | $begintime = microtime(true);  | 
                                                        
@@ -41,10 +41,10 @@ discard block  | 
                                                    ||
| 41 | 41 | $Common = new Common();  | 
                                                        
| 42 | 42 | |
| 43 | 43 |  if (isset($_GET['download'])) { | 
                                                        
| 44 | - if ($_GET['download'] == "true")  | 
                                                        |
| 45 | -    { | 
                                                        |
| 44 | + if ($_GET['download'] == "true")  | 
                                                        |
| 45 | +	{ | 
                                                        |
| 46 | 46 |  	header('Content-disposition: attachment; filename="flightairmap.json"'); | 
                                                        
| 47 | - }  | 
                                                        |
| 47 | + }  | 
                                                        |
| 48 | 48 | }  | 
                                                        
| 49 | 49 |  header('Content-Type: text/javascript'); | 
                                                        
| 50 | 50 | |
@@ -497,17 +497,17 @@ discard block  | 
                                                    ||
| 497 | 497 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];  | 
                                                        
| 498 | 498 | |
| 499 | 499 | if (  | 
                                                        
| 500 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')  | 
                                                        |
| 501 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)  | 
                                                        |
| 500 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')  | 
                                                        |
| 501 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)  | 
                                                        |
| 502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))  | 
                                                        
| 503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])  | 
                                                        
| 504 | -				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) | 
                                                        |
| 505 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])  | 
                                                        |
| 506 | -				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) | 
                                                        |
| 507 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])  | 
                                                        |
| 508 | -				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) | 
                                                        |
| 509 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])  | 
                                                        |
| 510 | -				    ) { | 
                                                        |
| 504 | +					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) | 
                                                        |
| 505 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])  | 
                                                        |
| 506 | +					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) | 
                                                        |
| 507 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])  | 
                                                        |
| 508 | +					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) | 
                                                        |
| 509 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])  | 
                                                        |
| 510 | +					) { | 
                                                        |
| 511 | 511 |  					if ($tracker) { | 
                                                        
| 512 | 512 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']);  | 
                                                        
| 513 | 513 |  					} elseif ($marine) { | 
                                                        
@@ -592,26 +592,26 @@ discard block  | 
                                                    ||
| 592 | 592 | }  | 
                                                        
| 593 | 593 | |
| 594 | 594 |  				if (isset($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))))) { | 
                                                        
| 595 | -				    $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        |
| 596 | -				    if (isset($spotter_item['departure_airport_latitude'])) { | 
                                                        |
| 595 | +					$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        |
| 596 | +					if (isset($spotter_item['departure_airport_latitude'])) { | 
                                                        |
| 597 | 597 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';  | 
                                                        
| 598 | -				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { | 
                                                        |
| 598 | +					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { | 
                                                        |
| 599 | 599 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);  | 
                                                        
| 600 | 600 |  					if (isset($dairport[0]['latitude'])) { | 
                                                        
| 601 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';  | 
                                                        |
| 601 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';  | 
                                                        |
| 602 | 602 | }  | 
                                                        
| 603 | - }  | 
                                                        |
| 604 | -				    if (isset($spotter_item['arrival_airport_latitude'])) { | 
                                                        |
| 603 | + }  | 
                                                        |
| 604 | +					if (isset($spotter_item['arrival_airport_latitude'])) { | 
                                                        |
| 605 | 605 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';  | 
                                                        
| 606 | -				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { | 
                                                        |
| 606 | +					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { | 
                                                        |
| 607 | 607 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);  | 
                                                        
| 608 | 608 |  					if (isset($aairport[0]['latitude'])) { | 
                                                        
| 609 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';  | 
                                                        |
| 609 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';  | 
                                                        |
| 610 | 610 | }  | 
                                                        
| 611 | - }  | 
                                                        |
| 612 | - $output_air .= ']}},';  | 
                                                        |
| 613 | - $output .= $output_air;  | 
                                                        |
| 614 | - unset($output_air);  | 
                                                        |
| 611 | + }  | 
                                                        |
| 612 | + $output_air .= ']}},';  | 
                                                        |
| 613 | + $output .= $output_air;  | 
                                                        |
| 614 | + unset($output_air);  | 
                                                        |
| 615 | 615 | }  | 
                                                        
| 616 | 616 | }  | 
                                                        
| 617 | 617 | $output = substr($output, 0, -1);  | 
                                                        
@@ -55,23 +55,23 @@ discard block  | 
                                                    ||
| 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_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); | 
                                                        |
| 65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); | 
                                                        |
| 66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);  | 
                                                        |
| 67 | -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_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); | 
                                                        |
| 65 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); | 
                                                        |
| 66 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);  | 
                                                        |
| 67 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);  | 
                                                        |
| 68 | 68 | |
| 69 | 69 |  if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { | 
                                                        
| 70 | 70 | $min = true;  | 
                                                        
| 71 | 71 | } else $min = false;  | 
                                                        
| 72 | 72 | |
| 73 | 73 |  if (isset($_GET['ident'])) { | 
                                                        
| 74 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);  | 
                                                        |
| 74 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);  | 
                                                        |
| 75 | 75 |  	if ($tracker) { | 
                                                        
| 76 | 76 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);  | 
                                                        
| 77 | 77 |  	} elseif ($marine) { | 
                                                        
@@ -85,7 +85,7 @@ discard block  | 
                                                    ||
| 85 | 85 | }  | 
                                                        
| 86 | 86 | $allhistory = true;  | 
                                                        
| 87 | 87 |  } elseif (isset($_GET['flightaware_id'])) { | 
                                                        
| 88 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);  | 
                                                        |
| 88 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);  | 
                                                        |
| 89 | 89 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);  | 
                                                        
| 90 | 90 |  	if (empty($spotter_array)) { | 
                                                        
| 91 | 91 | $from_archive = true;  | 
                                                        
@@ -93,44 +93,44 @@ discard block  | 
                                                    ||
| 93 | 93 | }  | 
                                                        
| 94 | 94 | $allhistory = true;  | 
                                                        
| 95 | 95 |  } elseif (isset($_GET['famtrack_id'])) { | 
                                                        
| 96 | - $famtrack_id = filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING);  | 
                                                        |
| 96 | + $famtrack_id = filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING);  | 
                                                        |
| 97 | 97 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);  | 
                                                        
| 98 | 98 | $allhistory = true;  | 
                                                        
| 99 | 99 |  } elseif (isset($_GET['fammarine_id'])) { | 
                                                        
| 100 | - $fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING);  | 
                                                        |
| 100 | + $fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING);  | 
                                                        |
| 101 | 101 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);  | 
                                                        
| 102 | 102 | $allhistory = true;  | 
                                                        
| 103 | 103 |  } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { | 
                                                        
| 104 | 104 |  //} elseif (isset($_GET['coord'])) { | 
                                                        
| 105 | 105 | $usecoord = true;  | 
                                                        
| 106 | -	$coord = explode(',',$_GET['coord']); | 
                                                        |
| 106 | +	$coord = explode(',', $_GET['coord']); | 
                                                        |
| 107 | 107 |  	if ($tracker) { | 
                                                        
| 108 | - $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter);  | 
                                                        |
| 108 | + $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter);  | 
                                                        |
| 109 | 109 |  	} elseif ($marine) { | 
                                                        
| 110 | - $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter);  | 
                                                        |
| 110 | + $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter);  | 
                                                        |
| 111 | 111 |  	} else { | 
                                                        
| 112 | - $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter);  | 
                                                        |
| 112 | + $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter);  | 
                                                        |
| 113 | 113 | }  | 
                                                        
| 114 | 114 |  } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) { | 
                                                        
| 115 | 115 | $usecoord = true;  | 
                                                        
| 116 | -	$coord = explode(',',$_GET['coord']); | 
                                                        |
| 116 | +	$coord = explode(',', $_GET['coord']); | 
                                                        |
| 117 | 117 |  	if ($tracker) { | 
                                                        
| 118 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);  | 
                                                        |
| 118 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);  | 
                                                        |
| 119 | 119 |  	} elseif ($marine) { | 
                                                        
| 120 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);  | 
                                                        |
| 120 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);  | 
                                                        |
| 121 | 121 |  	} else { | 
                                                        
| 122 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);  | 
                                                        |
| 122 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);  | 
                                                        |
| 123 | 123 | }  | 
                                                        
| 124 | 124 |  } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { | 
                                                        
| 125 | 125 | $from_archive = true;  | 
                                                        
| 126 | 126 |  //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); | 
                                                        
| 127 | 127 |  //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); | 
                                                        
| 128 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 129 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 130 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 131 | -	$begindate = date('Y-m-d H:i:s',$begindate); | 
                                                        |
| 132 | -	$enddate = date('Y-m-d H:i:s',$enddate); | 
                                                        |
| 133 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);  | 
                                                        |
| 128 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 129 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 130 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 131 | +	$begindate = date('Y-m-d H:i:s', $begindate); | 
                                                        |
| 132 | +	$enddate = date('Y-m-d H:i:s', $enddate); | 
                                                        |
| 133 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);  | 
                                                        |
| 134 | 134 |  } elseif ($min) { | 
                                                        
| 135 | 135 |  	if ($tracker) { | 
                                                        
| 136 | 136 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter);  | 
                                                        
@@ -142,18 +142,18 @@ discard block  | 
                                                    ||
| 142 | 142 | # $min = true;  | 
                                                        
| 143 | 143 |  } else { | 
                                                        
| 144 | 144 |  	if ($tracker) { | 
                                                        
| 145 | -		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); | 
                                                        |
| 145 | +		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); | 
                                                        |
| 146 | 146 |  	} elseif ($marine) { | 
                                                        
| 147 | -		$spotter_array = $marineLive->getLiveMarineData('','',$filter); | 
                                                        |
| 147 | +		$spotter_array = $marineLive->getLiveMarineData('', '', $filter); | 
                                                        |
| 148 | 148 |  	} else { | 
                                                        
| 149 | -		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); | 
                                                        |
| 149 | +		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); | 
                                                        |
| 150 | 150 | }  | 
                                                        
| 151 | 151 | }  | 
                                                        
| 152 | 152 | |
| 153 | 153 |  if (!empty($spotter_array) || $usecoord) { | 
                                                        
| 154 | 154 |  	if ($usecoord) { | 
                                                        
| 155 | 155 |  		if (isset($_GET['archive'])) { | 
                                                        
| 156 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);  | 
                                                        |
| 156 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);  | 
                                                        |
| 157 | 157 |  		} else { | 
                                                        
| 158 | 158 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter);  | 
                                                        
| 159 | 159 | }  | 
                                                        
@@ -161,7 +161,7 @@ discard block  | 
                                                    ||
| 161 | 161 | if ($flightcnt == '') $flightcnt = 0;  | 
                                                        
| 162 | 162 | } else $flightcnt = 0;  | 
                                                        
| 163 | 163 | |
| 164 | -$sqltime = round(microtime(true)-$begintime,2);  | 
                                                        |
| 164 | +$sqltime = round(microtime(true) - $begintime, 2);  | 
                                                        |
| 165 | 165 | |
| 166 | 166 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;  | 
                                                        
| 167 | 167 | else $usenextlatlon = true;  | 
                                                        
@@ -178,7 +178,7 @@ discard block  | 
                                                    ||
| 178 | 178 | if (!empty($spotter_array) && is_array($spotter_array))  | 
                                                        
| 179 | 179 |  		{ | 
                                                        
| 180 | 180 | $output .= '"features": [';  | 
                                                        
| 181 | - foreach($spotter_array as $spotter_item)  | 
                                                        |
| 181 | + foreach ($spotter_array as $spotter_item)  | 
                                                        |
| 182 | 182 |  			{ | 
                                                        
| 183 | 183 | $j++;  | 
                                                        
| 184 | 184 |  				date_default_timezone_set('UTC'); | 
                                                        
@@ -234,8 +234,8 @@ discard block  | 
                                                    ||
| 234 | 234 | */  | 
                                                        
| 235 | 235 | //$output .= '"fc": "'.$spotter_item['nb'].'",';  | 
                                                        
| 236 | 236 |  						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { | 
                                                        
| 237 | -							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; | 
                                                        |
| 238 | -							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; | 
                                                        |
| 237 | +							if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",'; | 
                                                        |
| 238 | +							else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",'; | 
                                                        |
| 239 | 239 | //"  | 
                                                        
| 240 | 240 |  						} else { | 
                                                        
| 241 | 241 | if ($compress) $output .= '"c": "NA",';  | 
                                                        
@@ -244,7 +244,7 @@ discard block  | 
                                                    ||
| 244 | 244 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';  | 
                                                        
| 245 | 245 |  						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { | 
                                                        
| 246 | 246 |  							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; | 
                                                        
| 247 | -							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; | 
                                                        |
| 247 | +							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; | 
                                                        |
| 248 | 248 |  						} elseif (isset($spotter_item['aircraft_type'])) { | 
                                                        
| 249 | 249 |  							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; | 
                                                        
| 250 | 250 |  						} elseif (!$min) { | 
                                                        
@@ -384,16 +384,16 @@ discard block  | 
                                                    ||
| 384 | 384 | else $output .= '"heading": "'.$spotter_item['heading'].'",';  | 
                                                        
| 385 | 385 | |
| 386 | 386 |  						if (isset($archivespeed)) { | 
                                                        
| 387 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);  | 
                                                        |
| 387 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed);  | 
                                                        |
| 388 | 388 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';  | 
                                                        
| 389 | 389 |  						} elseif ($usenextlatlon) { | 
                                                        
| 390 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);  | 
                                                        |
| 390 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']);  | 
                                                        |
| 391 | 391 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';  | 
                                                        
| 392 | 392 | }  | 
                                                        
| 393 | 393 | |
| 394 | 394 | if (!$min) $output .= '"image": "'.$image.'",';  | 
                                                        
| 395 | 395 |  						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { | 
                                                        
| 396 | -							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; | 
                                                        |
| 396 | +							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; | 
                                                        |
| 397 | 397 | }  | 
                                                        
| 398 | 398 |  						if (isset($spotter_item['image_source_website'])) { | 
                                                        
| 399 | 399 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';  | 
                                                        
@@ -415,7 +415,7 @@ discard block  | 
                                                    ||
| 415 | 415 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",';  | 
                                                        
| 416 | 416 | }  | 
                                                        
| 417 | 417 |  						if (isset($spotter_item['acars'])) { | 
                                                        
| 418 | -							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; | 
                                                        |
| 418 | +							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; | 
                                                        |
| 419 | 419 | }  | 
                                                        
| 420 | 420 | // type when not aircraft ?  | 
                                                        
| 421 | 421 |  						if (isset($spotter_item['type'])) { | 
                                                        
@@ -493,7 +493,7 @@ discard block  | 
                                                    ||
| 493 | 493 | |
| 494 | 494 | }  | 
                                                        
| 495 | 495 | */  | 
                                                        
| 496 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);  | 
                                                        |
| 496 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);  | 
                                                        |
| 497 | 497 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];  | 
                                                        
| 498 | 498 | |
| 499 | 499 | if (  | 
                                                        
@@ -501,11 +501,11 @@ discard block  | 
                                                    ||
| 501 | 501 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)  | 
                                                        
| 502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))  | 
                                                        
| 503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])  | 
                                                        
| 504 | -				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) | 
                                                        |
| 504 | +				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) | 
                                                        |
| 505 | 505 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])  | 
                                                        
| 506 | -				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) | 
                                                        |
| 506 | +				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) | 
                                                        |
| 507 | 507 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])  | 
                                                        
| 508 | -				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) | 
                                                        |
| 508 | +				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) | 
                                                        |
| 509 | 509 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])  | 
                                                        
| 510 | 510 |  				    ) { | 
                                                        
| 511 | 511 |  					if ($tracker) { | 
                                                        
@@ -538,9 +538,9 @@ discard block  | 
                                                    ||
| 538 | 538 |  								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        
| 539 | 539 | }  | 
                                                        
| 540 | 540 | $output_history .= '[';  | 
                                                        
| 541 | - $output_history .= $spotter_history['longitude'].', ';  | 
                                                        |
| 542 | - $output_history .= $spotter_history['latitude'].', ';  | 
                                                        |
| 543 | - $output_history .= $spotter_history['altitude']*30.48;  | 
                                                        |
| 541 | + $output_history .= $spotter_history['longitude'].', ';  | 
                                                        |
| 542 | + $output_history .= $spotter_history['latitude'].', ';  | 
                                                        |
| 543 | + $output_history .= $spotter_history['altitude']*30.48;  | 
                                                        |
| 544 | 544 | $output_history .= '],';  | 
                                                        
| 545 | 545 | /*  | 
                                                        
| 546 | 546 |  							if ($from_archive === false) { | 
                                                        
@@ -558,8 +558,8 @@ discard block  | 
                                                    ||
| 558 | 558 |  								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        
| 559 | 559 | } else $d = true;  | 
                                                        
| 560 | 560 | $output_history .= '[';  | 
                                                        
| 561 | - $output_history .= $spotter_history['longitude'].', ';  | 
                                                        |
| 562 | - $output_history .= $spotter_history['latitude'];  | 
                                                        |
| 561 | + $output_history .= $spotter_history['longitude'].', ';  | 
                                                        |
| 562 | + $output_history .= $spotter_history['latitude'];  | 
                                                        |
| 563 | 563 | $output_history .= '],';  | 
                                                        
| 564 | 564 | /*  | 
                                                        
| 565 | 565 |  							if ($from_archive === false) { | 
                                                        
@@ -575,9 +575,9 @@ discard block  | 
                                                    ||
| 575 | 575 | |
| 576 | 576 |  						if ($from_archive === false) { | 
                                                        
| 577 | 577 | $output_historyd = '[';  | 
                                                        
| 578 | - $output_historyd .= $spotter_item['longitude'].', ';  | 
                                                        |
| 579 | - $output_historyd .= $spotter_item['latitude'];  | 
                                                        |
| 580 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;  | 
                                                        |
| 578 | + $output_historyd .= $spotter_item['longitude'].', ';  | 
                                                        |
| 579 | + $output_historyd .= $spotter_item['latitude'];  | 
                                                        |
| 580 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;  | 
                                                        |
| 581 | 581 | $output_historyd .= '],';  | 
                                                        
| 582 | 582 | //$output_history = $output_historyd.$output_history;  | 
                                                        
| 583 | 583 | $output_history = $output_history.$output_historyd;  | 
                                                        
@@ -617,7 +617,7 @@ discard block  | 
                                                    ||
| 617 | 617 | $output = substr($output, 0, -1);  | 
                                                        
| 618 | 618 | $output .= ']';  | 
                                                        
| 619 | 619 | $output .= ',"initial_sqltime": "'.$sqltime.'",';  | 
                                                        
| 620 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';  | 
                                                        |
| 620 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';  | 
                                                        |
| 621 | 621 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';  | 
                                                        
| 622 | 622 | $output .= '"fc": "'.$j.'"';  | 
                                                        
| 623 | 623 |  		} else { | 
                                                        
@@ -48,27 +48,52 @@ discard block  | 
                                                    ||
| 48 | 48 | }  | 
                                                        
| 49 | 49 |  header('Content-Type: text/javascript'); | 
                                                        
| 50 | 50 | |
| 51 | -if (!isset($globalJsonCompress)) $compress = true;  | 
                                                        |
| 52 | -else $compress = $globalJsonCompress;  | 
                                                        |
| 51 | +if (!isset($globalJsonCompress)) { | 
                                                        |
| 52 | + $compress = true;  | 
                                                        |
| 53 | +} else { | 
                                                        |
| 54 | + $compress = $globalJsonCompress;  | 
                                                        |
| 55 | +}  | 
                                                        |
| 53 | 56 | |
| 54 | 57 | $from_archive = false;  | 
                                                        
| 55 | 58 | $min = true;  | 
                                                        
| 56 | 59 | $allhistory = false;  | 
                                                        
| 57 | 60 | $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_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); | 
                                                        |
| 65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); | 
                                                        |
| 66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);  | 
                                                        |
| 67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);  | 
                                                        |
| 61 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { | 
                                                        |
| 62 | +	$filter['source'] = array_merge($filter['source'],array('vatsimtxt')); | 
                                                        |
| 63 | +}  | 
                                                        |
| 64 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { | 
                                                        |
| 65 | +	$filter['source'] = array_merge($filter['source'],array('whazzup')); | 
                                                        |
| 66 | +}  | 
                                                        |
| 67 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { | 
                                                        |
| 68 | +	$filter['source'] = array_merge($filter['source'],array('phpvmacars')); | 
                                                        |
| 69 | +}  | 
                                                        |
| 70 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { | 
                                                        |
| 71 | +	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); | 
                                                        |
| 72 | +}  | 
                                                        |
| 73 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { | 
                                                        |
| 74 | +	$filter['source'] = array_merge($filter['source'],array('aprs')); | 
                                                        |
| 75 | +}  | 
                                                        |
| 76 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { | 
                                                        |
| 77 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);  | 
                                                        |
| 78 | +}  | 
                                                        |
| 79 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { | 
                                                        |
| 80 | +	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); | 
                                                        |
| 81 | +}  | 
                                                        |
| 82 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { | 
                                                        |
| 83 | +	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); | 
                                                        |
| 84 | +}  | 
                                                        |
| 85 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { | 
                                                        |
| 86 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);  | 
                                                        |
| 87 | +}  | 
                                                        |
| 88 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { | 
                                                        |
| 89 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);  | 
                                                        |
| 90 | +}  | 
                                                        |
| 68 | 91 | |
| 69 | 92 |  if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { | 
                                                        
| 70 | 93 | $min = true;  | 
                                                        
| 71 | -} else $min = false;  | 
                                                        |
| 94 | +} else { | 
                                                        |
| 95 | + $min = false;  | 
                                                        |
| 96 | +}  | 
                                                        |
| 72 | 97 | |
| 73 | 98 |  if (isset($_GET['ident'])) { | 
                                                        
| 74 | 99 | $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);  | 
                                                        
@@ -157,21 +182,33 @@ discard block  | 
                                                    ||
| 157 | 182 |  		} else { | 
                                                        
| 158 | 183 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter);  | 
                                                        
| 159 | 184 | }  | 
                                                        
| 160 | - } else $flightcnt = count($spotter_array);  | 
                                                        |
| 161 | - if ($flightcnt == '') $flightcnt = 0;  | 
                                                        |
| 162 | -} else $flightcnt = 0;  | 
                                                        |
| 185 | +	} else { | 
                                                        |
| 186 | + $flightcnt = count($spotter_array);  | 
                                                        |
| 187 | + }  | 
                                                        |
| 188 | +	if ($flightcnt == '') { | 
                                                        |
| 189 | + $flightcnt = 0;  | 
                                                        |
| 190 | + }  | 
                                                        |
| 191 | +	} else { | 
                                                        |
| 192 | + $flightcnt = 0;  | 
                                                        |
| 193 | +}  | 
                                                        |
| 163 | 194 | |
| 164 | 195 | $sqltime = round(microtime(true)-$begintime,2);  | 
                                                        
| 165 | 196 | |
| 166 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;  | 
                                                        |
| 167 | -else $usenextlatlon = true;  | 
                                                        |
| 197 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { | 
                                                        |
| 198 | + $usenextlatlon = false;  | 
                                                        |
| 199 | +} else { | 
                                                        |
| 200 | + $usenextlatlon = true;  | 
                                                        |
| 201 | +}  | 
                                                        |
| 168 | 202 | $j = 0;  | 
                                                        
| 169 | 203 | $prev_flightaware_id = '';  | 
                                                        
| 170 | 204 | $aircrafts_shadow = array();  | 
                                                        
| 171 | 205 |  $output = '{'; | 
                                                        
| 172 | 206 | $output .= '"type": "FeatureCollection",';  | 
                                                        
| 173 | - if ($min) $output .= '"minimal": "true",';  | 
                                                        |
| 174 | - else $output .= '"minimal": "false",';  | 
                                                        |
| 207 | +		if ($min) { | 
                                                        |
| 208 | + $output .= '"minimal": "true",';  | 
                                                        |
| 209 | +		} else { | 
                                                        |
| 210 | + $output .= '"minimal": "false",';  | 
                                                        |
| 211 | + }  | 
                                                        |
| 175 | 212 | $output .= '"fc": "'.$flightcnt.'",';  | 
                                                        
| 176 | 213 | $output .= '"sqt": "'.$sqltime.'",';  | 
                                                        
| 177 | 214 | |
@@ -215,18 +252,29 @@ discard block  | 
                                                    ||
| 215 | 252 | }  | 
                                                        
| 216 | 253 |  						$output .= '"properties": {'; | 
                                                        
| 217 | 254 |  						if (isset($spotter_item['flightaware_id'])) { | 
                                                        
| 218 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';  | 
                                                        |
| 219 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';  | 
                                                        |
| 255 | +							if ($compress) { | 
                                                        |
| 256 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';  | 
                                                        |
| 257 | +							} else { | 
                                                        |
| 258 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';  | 
                                                        |
| 259 | + }  | 
                                                        |
| 220 | 260 |  						} elseif (isset($spotter_item['famtrackid'])) { | 
                                                        
| 221 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';  | 
                                                        |
| 222 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';  | 
                                                        |
| 261 | +							if ($compress) { | 
                                                        |
| 262 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",';  | 
                                                        |
| 263 | +							} else { | 
                                                        |
| 264 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';  | 
                                                        |
| 265 | + }  | 
                                                        |
| 223 | 266 |  						} elseif (isset($spotter_item['fammarine_id'])) { | 
                                                        
| 224 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';  | 
                                                        |
| 225 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';  | 
                                                        |
| 267 | +							if ($compress) { | 
                                                        |
| 268 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';  | 
                                                        |
| 269 | +							} else { | 
                                                        |
| 270 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';  | 
                                                        |
| 271 | + }  | 
                                                        |
| 226 | 272 | }  | 
                                                        
| 227 | 273 | $output .= '"fc": "'.$flightcnt.'",';  | 
                                                        
| 228 | 274 | $output .= '"sqt": "'.$sqltime.'",';  | 
                                                        
| 229 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';  | 
                                                        |
| 275 | +							if (isset($begindate)) { | 
                                                        |
| 276 | + $output .= '"archive_date": "'.$begindate.'",';  | 
                                                        |
| 277 | + }  | 
                                                        |
| 230 | 278 | |
| 231 | 279 | /*  | 
                                                        
| 232 | 280 | if ($min) $output .= '"minimal": "true",';  | 
                                                        
@@ -234,14 +282,22 @@ discard block  | 
                                                    ||
| 234 | 282 | */  | 
                                                        
| 235 | 283 | //$output .= '"fc": "'.$spotter_item['nb'].'",';  | 
                                                        
| 236 | 284 |  						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { | 
                                                        
| 237 | -							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; | 
                                                        |
| 238 | -							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; | 
                                                        |
| 285 | +							if ($compress) { | 
                                                        |
| 286 | +								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; | 
                                                        |
| 287 | +							} else { | 
                                                        |
| 288 | +								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; | 
                                                        |
| 289 | + }  | 
                                                        |
| 239 | 290 | //"  | 
                                                        
| 240 | 291 |  						} else { | 
                                                        
| 241 | - if ($compress) $output .= '"c": "NA",';  | 
                                                        |
| 242 | - else $output .= '"callsign": "NA",';  | 
                                                        |
| 292 | +							if ($compress) { | 
                                                        |
| 293 | + $output .= '"c": "NA",';  | 
                                                        |
| 294 | +							} else { | 
                                                        |
| 295 | + $output .= '"callsign": "NA",';  | 
                                                        |
| 296 | + }  | 
                                                        |
| 297 | + }  | 
                                                        |
| 298 | +						if (isset($spotter_item['registration'])) { | 
                                                        |
| 299 | + $output .= '"registration": "'.$spotter_item['registration'].'",';  | 
                                                        |
| 243 | 300 | }  | 
                                                        
| 244 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';  | 
                                                        |
| 245 | 301 |  						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { | 
                                                        
| 246 | 302 |  							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; | 
                                                        
| 247 | 303 |  							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; | 
                                                        
@@ -254,15 +310,21 @@ discard block  | 
                                                    ||
| 254 | 310 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';  | 
                                                        
| 255 | 311 | }  | 
                                                        
| 256 | 312 |  						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) { | 
                                                        
| 257 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';  | 
                                                        |
| 258 | -							else { | 
                                                        |
| 313 | +							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { | 
                                                        |
| 314 | + $spotter_item['aircraft_shadow'] = '';  | 
                                                        |
| 315 | +							} else { | 
                                                        |
| 259 | 316 | $aircraft_icao = $spotter_item['aircraft_icao'];  | 
                                                        
| 260 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];  | 
                                                        |
| 261 | -								else { | 
                                                        |
| 317 | +								if (isset($aircrafts_shadow[$aircraft_icao])) { | 
                                                        |
| 318 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];  | 
                                                        |
| 319 | +								} else { | 
                                                        |
| 262 | 320 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);  | 
                                                        
| 263 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];  | 
                                                        |
| 264 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';  | 
                                                        |
| 265 | - else $spotter_item['aircraft_shadow'] = '';  | 
                                                        |
| 321 | +									if (count($aircraft_info) > 0) { | 
                                                        |
| 322 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];  | 
                                                        |
| 323 | +									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { | 
                                                        |
| 324 | + $spotter_item['aircraft_shadow'] = 'PA18.png';  | 
                                                        |
| 325 | +									} else { | 
                                                        |
| 326 | + $spotter_item['aircraft_shadow'] = '';  | 
                                                        |
| 327 | + }  | 
                                                        |
| 266 | 328 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];  | 
                                                        
| 267 | 329 | }  | 
                                                        
| 268 | 330 | }  | 
                                                        
@@ -270,73 +332,139 @@ discard block  | 
                                                    ||
| 270 | 332 |  						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { | 
                                                        
| 271 | 333 |  							if ($tracker) { | 
                                                        
| 272 | 334 |  								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { | 
                                                        
| 273 | - if ($compress) $output .= '"as": "ambulance.png",';  | 
                                                        |
| 274 | - else $output .= '"aircraft_shadow": "ambulance.png",';  | 
                                                        |
| 335 | +									if ($compress) { | 
                                                        |
| 336 | + $output .= '"as": "ambulance.png",';  | 
                                                        |
| 337 | +									} else { | 
                                                        |
| 338 | + $output .= '"aircraft_shadow": "ambulance.png",';  | 
                                                        |
| 339 | + }  | 
                                                        |
| 275 | 340 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { | 
                                                        
| 276 | - if ($compress) $output .= '"as": "police.png",';  | 
                                                        |
| 277 | - else $output .= '"aircraft_shadow": "police.png",';  | 
                                                        |
| 341 | +									if ($compress) { | 
                                                        |
| 342 | + $output .= '"as": "police.png",';  | 
                                                        |
| 343 | +									} else { | 
                                                        |
| 344 | + $output .= '"aircraft_shadow": "police.png",';  | 
                                                        |
| 345 | + }  | 
                                                        |
| 278 | 346 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { | 
                                                        
| 279 | - if ($compress) $output .= '"as": "ship.png",';  | 
                                                        |
| 280 | - else $output .= '"aircraft_shadow": "ship.png",';  | 
                                                        |
| 347 | +									if ($compress) { | 
                                                        |
| 348 | + $output .= '"as": "ship.png",';  | 
                                                        |
| 349 | +									} else { | 
                                                        |
| 350 | + $output .= '"aircraft_shadow": "ship.png",';  | 
                                                        |
| 351 | + }  | 
                                                        |
| 281 | 352 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { | 
                                                        
| 282 | - if ($compress) $output .= '"as": "ship.png",';  | 
                                                        |
| 283 | - else $output .= '"aircraft_shadow": "ship.png",';  | 
                                                        |
| 353 | +									if ($compress) { | 
                                                        |
| 354 | + $output .= '"as": "ship.png",';  | 
                                                        |
| 355 | +									} else { | 
                                                        |
| 356 | + $output .= '"aircraft_shadow": "ship.png",';  | 
                                                        |
| 357 | + }  | 
                                                        |
| 284 | 358 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { | 
                                                        
| 285 | - if ($compress) $output .= '"as": "ship.png",';  | 
                                                        |
| 286 | - else $output .= '"aircraft_shadow": "ship.png",';  | 
                                                        |
| 359 | +									if ($compress) { | 
                                                        |
| 360 | + $output .= '"as": "ship.png",';  | 
                                                        |
| 361 | +									} else { | 
                                                        |
| 362 | + $output .= '"aircraft_shadow": "ship.png",';  | 
                                                        |
| 363 | + }  | 
                                                        |
| 287 | 364 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { | 
                                                        
| 288 | - if ($compress) $output .= '"as": "truck.png",';  | 
                                                        |
| 289 | - else $output .= '"aircraft_shadow": "truck.png",';  | 
                                                        |
| 365 | +									if ($compress) { | 
                                                        |
| 366 | + $output .= '"as": "truck.png",';  | 
                                                        |
| 367 | +									} else { | 
                                                        |
| 368 | + $output .= '"aircraft_shadow": "truck.png",';  | 
                                                        |
| 369 | + }  | 
                                                        |
| 290 | 370 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { | 
                                                        
| 291 | - if ($compress) $output .= '"as": "truck.png",';  | 
                                                        |
| 292 | - else $output .= '"aircraft_shadow": "truck.png",';  | 
                                                        |
| 371 | +									if ($compress) { | 
                                                        |
| 372 | + $output .= '"as": "truck.png",';  | 
                                                        |
| 373 | +									} else { | 
                                                        |
| 374 | + $output .= '"aircraft_shadow": "truck.png",';  | 
                                                        |
| 375 | + }  | 
                                                        |
| 293 | 376 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { | 
                                                        
| 294 | - if ($compress) $output .= '"as": "aircraft.png",';  | 
                                                        |
| 295 | - else $output .= '"aircraft_shadow": "aircraft.png",';  | 
                                                        |
| 377 | +									if ($compress) { | 
                                                        |
| 378 | + $output .= '"as": "aircraft.png",';  | 
                                                        |
| 379 | +									} else { | 
                                                        |
| 380 | + $output .= '"aircraft_shadow": "aircraft.png",';  | 
                                                        |
| 381 | + }  | 
                                                        |
| 296 | 382 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { | 
                                                        
| 297 | - if ($compress) $output .= '"as": "aircraft.png",';  | 
                                                        |
| 298 | - else $output .= '"aircraft_shadow": "aircraft.png",';  | 
                                                        |
| 383 | +									if ($compress) { | 
                                                        |
| 384 | + $output .= '"as": "aircraft.png",';  | 
                                                        |
| 385 | +									} else { | 
                                                        |
| 386 | + $output .= '"aircraft_shadow": "aircraft.png",';  | 
                                                        |
| 387 | + }  | 
                                                        |
| 299 | 388 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { | 
                                                        
| 300 | - if ($compress) $output .= '"as": "helico.png",';  | 
                                                        |
| 301 | - else $output .= '"aircraft_shadow": "helico.png",';  | 
                                                        |
| 389 | +									if ($compress) { | 
                                                        |
| 390 | + $output .= '"as": "helico.png",';  | 
                                                        |
| 391 | +									} else { | 
                                                        |
| 392 | + $output .= '"aircraft_shadow": "helico.png",';  | 
                                                        |
| 393 | + }  | 
                                                        |
| 302 | 394 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { | 
                                                        
| 303 | - if ($compress) $output .= '"as": "rail.png",';  | 
                                                        |
| 304 | - else $output .= '"aircraft_shadow": "rail.png",';  | 
                                                        |
| 395 | +									if ($compress) { | 
                                                        |
| 396 | + $output .= '"as": "rail.png",';  | 
                                                        |
| 397 | +									} else { | 
                                                        |
| 398 | + $output .= '"aircraft_shadow": "rail.png",';  | 
                                                        |
| 399 | + }  | 
                                                        |
| 305 | 400 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { | 
                                                        
| 306 | - if ($compress) $output .= '"as": "firetruck.png",';  | 
                                                        |
| 307 | - else $output .= '"aircraft_shadow": "firetruck.png",';  | 
                                                        |
| 401 | +									if ($compress) { | 
                                                        |
| 402 | + $output .= '"as": "firetruck.png",';  | 
                                                        |
| 403 | +									} else { | 
                                                        |
| 404 | + $output .= '"aircraft_shadow": "firetruck.png",';  | 
                                                        |
| 405 | + }  | 
                                                        |
| 308 | 406 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { | 
                                                        
| 309 | - if ($compress) $output .= '"as": "bus.png",';  | 
                                                        |
| 310 | - else $output .= '"aircraft_shadow": "bus.png",';  | 
                                                        |
| 407 | +									if ($compress) { | 
                                                        |
| 408 | + $output .= '"as": "bus.png",';  | 
                                                        |
| 409 | +									} else { | 
                                                        |
| 410 | + $output .= '"aircraft_shadow": "bus.png",';  | 
                                                        |
| 411 | + }  | 
                                                        |
| 311 | 412 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { | 
                                                        
| 312 | - if ($compress) $output .= '"as": "phone.png",';  | 
                                                        |
| 313 | - else $output .= '"aircraft_shadow": "phone.png",';  | 
                                                        |
| 413 | +									if ($compress) { | 
                                                        |
| 414 | + $output .= '"as": "phone.png",';  | 
                                                        |
| 415 | +									} else { | 
                                                        |
| 416 | + $output .= '"aircraft_shadow": "phone.png",';  | 
                                                        |
| 417 | + }  | 
                                                        |
| 314 | 418 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { | 
                                                        
| 315 | - if ($compress) $output .= '"as": "jogger.png",';  | 
                                                        |
| 316 | - else $output .= '"aircraft_shadow": "jogger.png",';  | 
                                                        |
| 419 | +									if ($compress) { | 
                                                        |
| 420 | + $output .= '"as": "jogger.png",';  | 
                                                        |
| 421 | +									} else { | 
                                                        |
| 422 | + $output .= '"aircraft_shadow": "jogger.png",';  | 
                                                        |
| 423 | + }  | 
                                                        |
| 317 | 424 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { | 
                                                        
| 318 | - if ($compress) $output .= '"as": "bike.png",';  | 
                                                        |
| 319 | - else $output .= '"aircraft_shadow": "bike.png",';  | 
                                                        |
| 425 | +									if ($compress) { | 
                                                        |
| 426 | + $output .= '"as": "bike.png",';  | 
                                                        |
| 427 | +									} else { | 
                                                        |
| 428 | + $output .= '"aircraft_shadow": "bike.png",';  | 
                                                        |
| 429 | + }  | 
                                                        |
| 320 | 430 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { | 
                                                        
| 321 | - if ($compress) $output .= '"as": "motorcycle.png",';  | 
                                                        |
| 322 | - else $output .= '"aircraft_shadow": "motorcycle.png",';  | 
                                                        |
| 431 | +									if ($compress) { | 
                                                        |
| 432 | + $output .= '"as": "motorcycle.png",';  | 
                                                        |
| 433 | +									} else { | 
                                                        |
| 434 | + $output .= '"aircraft_shadow": "motorcycle.png",';  | 
                                                        |
| 435 | + }  | 
                                                        |
| 323 | 436 |  								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { | 
                                                        
| 324 | - if ($compress) $output .= '"as": "balloon.png",';  | 
                                                        |
| 325 | - else $output .= '"aircraft_shadow": "balloon.png",';  | 
                                                        |
| 437 | +									if ($compress) { | 
                                                        |
| 438 | + $output .= '"as": "balloon.png",';  | 
                                                        |
| 439 | +									} else { | 
                                                        |
| 440 | + $output .= '"aircraft_shadow": "balloon.png",';  | 
                                                        |
| 441 | + }  | 
                                                        |
| 326 | 442 |  								} else { | 
                                                        
| 327 | - if ($compress) $output .= '"as": "car.png",';  | 
                                                        |
| 328 | - else $output .= '"aircraft_shadow": "car.png",';  | 
                                                        |
| 443 | +									if ($compress) { | 
                                                        |
| 444 | + $output .= '"as": "car.png",';  | 
                                                        |
| 445 | +									} else { | 
                                                        |
| 446 | + $output .= '"aircraft_shadow": "car.png",';  | 
                                                        |
| 447 | + }  | 
                                                        |
| 329 | 448 | }  | 
                                                        
| 330 | 449 |  							} elseif ($marine) { | 
                                                        
| 331 | - if ($compress) $output .= '"as": "ship.png",';  | 
                                                        |
| 332 | - else $output .= '"aircraft_shadow": "ship.png",';  | 
                                                        |
| 450 | +								if ($compress) { | 
                                                        |
| 451 | + $output .= '"as": "ship.png",';  | 
                                                        |
| 452 | +								} else { | 
                                                        |
| 453 | + $output .= '"aircraft_shadow": "ship.png",';  | 
                                                        |
| 454 | + }  | 
                                                        |
| 333 | 455 |  							} else { | 
                                                        
| 334 | - if ($compress) $output .= '"as": "default.png",';  | 
                                                        |
| 335 | - else $output .= '"aircraft_shadow": "default.png",';  | 
                                                        |
| 456 | +								if ($compress) { | 
                                                        |
| 457 | + $output .= '"as": "default.png",';  | 
                                                        |
| 458 | +								} else { | 
                                                        |
| 459 | + $output .= '"aircraft_shadow": "default.png",';  | 
                                                        |
| 460 | + }  | 
                                                        |
| 336 | 461 | }  | 
                                                        
| 337 | 462 |  						} else { | 
                                                        
| 338 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';  | 
                                                        |
| 339 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';  | 
                                                        |
| 463 | +							if ($compress) { | 
                                                        |
| 464 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';  | 
                                                        |
| 465 | +							} else { | 
                                                        |
| 466 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';  | 
                                                        |
| 467 | + }  | 
                                                        |
| 340 | 468 | }  | 
                                                        
| 341 | 469 |  						if (isset($spotter_item['airline_name'])) { | 
                                                        
| 342 | 470 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",';  | 
                                                        
@@ -344,8 +472,11 @@ discard block  | 
                                                    ||
| 344 | 472 | $output .= '"airline_name": "NA",';  | 
                                                        
| 345 | 473 | }  | 
                                                        
| 346 | 474 |  						if (isset($spotter_item['departure_airport'])) { | 
                                                        
| 347 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';  | 
                                                        |
| 348 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';  | 
                                                        |
| 475 | +							if ($compress) { | 
                                                        |
| 476 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",';  | 
                                                        |
| 477 | +							} else { | 
                                                        |
| 478 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';  | 
                                                        |
| 479 | + }  | 
                                                        |
| 349 | 480 | }  | 
                                                        
| 350 | 481 |  						if (isset($spotter_item['departure_airport_city'])) { | 
                                                        
| 351 | 482 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';  | 
                                                        
@@ -357,8 +488,11 @@ discard block  | 
                                                    ||
| 357 | 488 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';  | 
                                                        
| 358 | 489 | }  | 
                                                        
| 359 | 490 |  						if (isset($spotter_item['arrival_airport'])) { | 
                                                        
| 360 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';  | 
                                                        |
| 361 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';  | 
                                                        |
| 491 | +							if ($compress) { | 
                                                        |
| 492 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';  | 
                                                        |
| 493 | +							} else { | 
                                                        |
| 494 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';  | 
                                                        |
| 495 | + }  | 
                                                        |
| 362 | 496 | }  | 
                                                        
| 363 | 497 |  						if (isset($spotter_item['arrival_airport_city'])) { | 
                                                        
| 364 | 498 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';  | 
                                                        
@@ -377,11 +511,17 @@ discard block  | 
                                                    ||
| 377 | 511 | }  | 
                                                        
| 378 | 512 | |
| 379 | 513 |  						if (isset($spotter_item['altitude'])) { | 
                                                        
| 380 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';  | 
                                                        |
| 381 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",';  | 
                                                        |
| 514 | +							if ($compress) { | 
                                                        |
| 515 | + $output .= '"a": "'.$spotter_item['altitude'].'",';  | 
                                                        |
| 516 | +							} else { | 
                                                        |
| 517 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",';  | 
                                                        |
| 518 | + }  | 
                                                        |
| 519 | + }  | 
                                                        |
| 520 | +						if ($compress) { | 
                                                        |
| 521 | + $output .= '"h": "'.$spotter_item['heading'].'",';  | 
                                                        |
| 522 | +						} else { | 
                                                        |
| 523 | + $output .= '"heading": "'.$spotter_item['heading'].'",';  | 
                                                        |
| 382 | 524 | }  | 
                                                        
| 383 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';  | 
                                                        |
| 384 | - else $output .= '"heading": "'.$spotter_item['heading'].'",';  | 
                                                        |
| 385 | 525 | |
| 386 | 526 |  						if (isset($archivespeed)) { | 
                                                        
| 387 | 527 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);  | 
                                                        
@@ -391,7 +531,9 @@ discard block  | 
                                                    ||
| 391 | 531 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';  | 
                                                        
| 392 | 532 | }  | 
                                                        
| 393 | 533 | |
| 394 | - if (!$min) $output .= '"image": "'.$image.'",';  | 
                                                        |
| 534 | +						if (!$min) { | 
                                                        |
| 535 | + $output .= '"image": "'.$image.'",';  | 
                                                        |
| 536 | + }  | 
                                                        |
| 395 | 537 |  						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { | 
                                                        
| 396 | 538 |  							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; | 
                                                        
| 397 | 539 | }  | 
                                                        
@@ -399,8 +541,11 @@ discard block  | 
                                                    ||
| 399 | 541 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';  | 
                                                        
| 400 | 542 | }  | 
                                                        
| 401 | 543 |  						if (isset($spotter_item['squawk'])) { | 
                                                        
| 402 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';  | 
                                                        |
| 403 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",';  | 
                                                        |
| 544 | +							if ($compress) { | 
                                                        |
| 545 | + $output .= '"sq": "'.$spotter_item['squawk'].'",';  | 
                                                        |
| 546 | +							} else { | 
                                                        |
| 547 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",';  | 
                                                        |
| 548 | + }  | 
                                                        |
| 404 | 549 | }  | 
                                                        
| 405 | 550 |  						if (isset($spotter_item['squawk_usage'])) { | 
                                                        
| 406 | 551 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';  | 
                                                        
@@ -419,14 +564,23 @@ discard block  | 
                                                    ||
| 419 | 564 | }  | 
                                                        
| 420 | 565 | // type when not aircraft ?  | 
                                                        
| 421 | 566 |  						if (isset($spotter_item['type'])) { | 
                                                        
| 422 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';  | 
                                                        |
| 423 | - else $output .= '"type": "'.$spotter_item['type'].'"';  | 
                                                        |
| 567 | +							if ($compress) { | 
                                                        |
| 568 | + $output .= '"t": "'.$spotter_item['type'].'"';  | 
                                                        |
| 569 | +							} else { | 
                                                        |
| 570 | + $output .= '"type": "'.$spotter_item['type'].'"';  | 
                                                        |
| 571 | + }  | 
                                                        |
| 424 | 572 |  						} elseif ($marine) { | 
                                                        
| 425 | - if ($compress) $output .= '"t": "ship"';  | 
                                                        |
| 426 | - else $output .= '"type": "ship"';  | 
                                                        |
| 573 | +							if ($compress) { | 
                                                        |
| 574 | + $output .= '"t": "ship"';  | 
                                                        |
| 575 | +							} else { | 
                                                        |
| 576 | + $output .= '"type": "ship"';  | 
                                                        |
| 577 | + }  | 
                                                        |
| 427 | 578 |  						} else { | 
                                                        
| 428 | - if ($compress) $output .= '"t": "aircraft"';  | 
                                                        |
| 429 | - else $output .= '"type": "aircraft"';  | 
                                                        |
| 579 | +							if ($compress) { | 
                                                        |
| 580 | + $output .= '"t": "aircraft"';  | 
                                                        |
| 581 | +							} else { | 
                                                        |
| 582 | + $output .= '"type": "aircraft"';  | 
                                                        |
| 583 | + }  | 
                                                        |
| 430 | 584 | }  | 
                                                        
| 431 | 585 | $output .= '},';  | 
                                                        
| 432 | 586 |  						$output .= '"geometry": {'; | 
                                                        
@@ -494,7 +648,9 @@ discard block  | 
                                                    ||
| 494 | 648 | }  | 
                                                        
| 495 | 649 | */  | 
                                                        
| 496 | 650 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);  | 
                                                        
| 497 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];  | 
                                                        |
| 651 | +				if ($history == '' && isset($_COOKIE['history'])) { | 
                                                        |
| 652 | + $history = $_COOKIE['history'];  | 
                                                        |
| 653 | + }  | 
                                                        |
| 498 | 654 | |
| 499 | 655 | if (  | 
                                                        
| 500 | 656 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')  | 
                                                        
@@ -534,8 +690,11 @@ discard block  | 
                                                    ||
| 534 | 690 | $output_history .= ']}},';  | 
                                                        
| 535 | 691 | $output .= $output_history;  | 
                                                        
| 536 | 692 | }  | 
                                                        
| 537 | -								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        |
| 538 | -								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        |
| 693 | +								if ($compress) { | 
                                                        |
| 694 | +									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        |
| 695 | +								} else { | 
                                                        |
| 696 | +									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        |
| 697 | + }  | 
                                                        |
| 539 | 698 | }  | 
                                                        
| 540 | 699 | $output_history .= '[';  | 
                                                        
| 541 | 700 | $output_history .= $spotter_history['longitude'].', ';  | 
                                                        
@@ -554,9 +713,14 @@ discard block  | 
                                                    ||
| 554 | 713 | $prev_alt = $alt;  | 
                                                        
| 555 | 714 |  						} else { | 
                                                        
| 556 | 715 |  							if ($d == false) { | 
                                                        
| 557 | -								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        |
| 558 | -								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        |
| 559 | - } else $d = true;  | 
                                                        |
| 716 | +								if ($compress) { | 
                                                        |
| 717 | +									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        |
| 718 | +								} else { | 
                                                        |
| 719 | +									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; | 
                                                        |
| 720 | + }  | 
                                                        |
| 721 | +							} else { | 
                                                        |
| 722 | + $d = true;  | 
                                                        |
| 723 | + }  | 
                                                        |
| 560 | 724 | $output_history .= '[';  | 
                                                        
| 561 | 725 | $output_history .= $spotter_history['longitude'].', ';  | 
                                                        
| 562 | 726 | $output_history .= $spotter_history['latitude'];  | 
                                                        
@@ -577,7 +741,9 @@ discard block  | 
                                                    ||
| 577 | 741 | $output_historyd = '[';  | 
                                                        
| 578 | 742 | $output_historyd .= $spotter_item['longitude'].', ';  | 
                                                        
| 579 | 743 | $output_historyd .= $spotter_item['latitude'];  | 
                                                        
| 580 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;  | 
                                                        |
| 744 | +							if (isset($spotter_history['altitude'])) { | 
                                                        |
| 745 | + $output_historyd .= ','.$spotter_item['altitude']*30.48;  | 
                                                        |
| 746 | + }  | 
                                                        |
| 581 | 747 | $output_historyd .= '],';  | 
                                                        
| 582 | 748 | //$output_history = $output_historyd.$output_history;  | 
                                                        
| 583 | 749 | $output_history = $output_history.$output_historyd;  | 
                                                        
@@ -618,7 +784,9 @@ discard block  | 
                                                    ||
| 618 | 784 | $output .= ']';  | 
                                                        
| 619 | 785 | $output .= ',"initial_sqltime": "'.$sqltime.'",';  | 
                                                        
| 620 | 786 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';  | 
                                                        
| 621 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';  | 
                                                        |
| 787 | +			if (isset($begindate)) { | 
                                                        |
| 788 | + $output .= '"archive_date": "'.$begindate.'",';  | 
                                                        |
| 789 | + }  | 
                                                        |
| 622 | 790 | $output .= '"fc": "'.$j.'"';  | 
                                                        
| 623 | 791 |  		} else { | 
                                                        
| 624 | 792 | $output .= '"features": ';  | 
                                                        
@@ -12,10 +12,10 @@ discard block  | 
                                                    ||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | /**  | 
                                                        
| 15 | - * Get SQL query part for filter used  | 
                                                        |
| 16 | - * @param Array $filter the filter  | 
                                                        |
| 17 | - * @return Array the SQL part  | 
                                                        |
| 18 | - */  | 
                                                        |
| 15 | + * Get SQL query part for filter used  | 
                                                        |
| 16 | + * @param Array $filter the filter  | 
                                                        |
| 17 | + * @return Array the SQL part  | 
                                                        |
| 18 | + */  | 
                                                        |
| 19 | 19 |  	public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                        
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;  | 
                                                        
| 21 | 21 | $filters = array();  | 
                                                        
@@ -86,11 +86,11 @@ discard block  | 
                                                    ||
| 86 | 86 | }  | 
                                                        
| 87 | 87 | |
| 88 | 88 | /**  | 
                                                        
| 89 | - * Gets all the spotter information based on the latest data entry  | 
                                                        |
| 90 | - *  | 
                                                        |
| 91 | - * @return Array the spotter information  | 
                                                        |
| 92 | - *  | 
                                                        |
| 93 | - */  | 
                                                        |
| 89 | + * Gets all the spotter information based on the latest data entry  | 
                                                        |
| 90 | + *  | 
                                                        |
| 91 | + * @return Array the spotter information  | 
                                                        |
| 92 | + *  | 
                                                        |
| 93 | + */  | 
                                                        |
| 94 | 94 | public function getLiveMarineData($limit = '', $sort = '', $filter = array())  | 
                                                        
| 95 | 95 |  	{ | 
                                                        
| 96 | 96 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -132,11 +132,11 @@ discard block  | 
                                                    ||
| 132 | 132 | }  | 
                                                        
| 133 | 133 | |
| 134 | 134 | /**  | 
                                                        
| 135 | - * Gets Minimal Live Spotter data  | 
                                                        |
| 136 | - *  | 
                                                        |
| 137 | - * @return Array the spotter information  | 
                                                        |
| 138 | - *  | 
                                                        |
| 139 | - */  | 
                                                        |
| 135 | + * Gets Minimal Live Spotter data  | 
                                                        |
| 136 | + *  | 
                                                        |
| 137 | + * @return Array the spotter information  | 
                                                        |
| 138 | + *  | 
                                                        |
| 139 | + */  | 
                                                        |
| 140 | 140 | public function getMinLiveMarineData($filter = array())  | 
                                                        
| 141 | 141 |  	{ | 
                                                        
| 142 | 142 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -166,11 +166,11 @@ discard block  | 
                                                    ||
| 166 | 166 | }  | 
                                                        
| 167 | 167 | |
| 168 | 168 | /**  | 
                                                        
| 169 | - * Gets Minimal Live Spotter data since xx seconds  | 
                                                        |
| 170 | - *  | 
                                                        |
| 171 | - * @return Array the spotter information  | 
                                                        |
| 172 | - *  | 
                                                        |
| 173 | - */  | 
                                                        |
| 169 | + * Gets Minimal Live Spotter data since xx seconds  | 
                                                        |
| 170 | + *  | 
                                                        |
| 171 | + * @return Array the spotter information  | 
                                                        |
| 172 | + *  | 
                                                        |
| 173 | + */  | 
                                                        |
| 174 | 174 | public function getMinLastLiveMarineData($filter = array())  | 
                                                        
| 175 | 175 |  	{ | 
                                                        
| 176 | 176 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -183,13 +183,13 @@ discard block  | 
                                                    ||
| 183 | 183 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        
| 184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'  | 
                                                        
| 185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date";  | 
                                                        
| 186 | -                } else { | 
                                                        |
| 186 | +				} else { | 
                                                        |
| 187 | 187 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        
| 188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'  | 
                                                        
| 189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date";  | 
                                                        
| 190 | 190 | }  | 
                                                        
| 191 | 191 | |
| 192 | -    		try { | 
                                                        |
| 192 | +			try { | 
                                                        |
| 193 | 193 | $sth = $this->db->prepare($query);  | 
                                                        
| 194 | 194 | $sth->execute();  | 
                                                        
| 195 | 195 |  		} catch(PDOException $e) { | 
                                                        
@@ -201,11 +201,11 @@ discard block  | 
                                                    ||
| 201 | 201 | }  | 
                                                        
| 202 | 202 | |
| 203 | 203 | /**  | 
                                                        
| 204 | - * Gets number of latest data entry  | 
                                                        |
| 205 | - *  | 
                                                        |
| 206 | - * @return String number of entry  | 
                                                        |
| 207 | - *  | 
                                                        |
| 208 | - */  | 
                                                        |
| 204 | + * Gets number of latest data entry  | 
                                                        |
| 205 | + *  | 
                                                        |
| 206 | + * @return String number of entry  | 
                                                        |
| 207 | + *  | 
                                                        |
| 208 | + */  | 
                                                        |
| 209 | 209 | public function getLiveMarineCount($filter = array())  | 
                                                        
| 210 | 210 |  	{ | 
                                                        
| 211 | 211 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -230,11 +230,11 @@ discard block  | 
                                                    ||
| 230 | 230 | }  | 
                                                        
| 231 | 231 | |
| 232 | 232 | /**  | 
                                                        
| 233 | - * Gets all the spotter information based on the latest data entry and coord  | 
                                                        |
| 234 | - *  | 
                                                        |
| 235 | - * @return Array the spotter information  | 
                                                        |
| 236 | - *  | 
                                                        |
| 237 | - */  | 
                                                        |
| 233 | + * Gets all the spotter information based on the latest data entry and coord  | 
                                                        |
| 234 | + *  | 
                                                        |
| 235 | + * @return Array the spotter information  | 
                                                        |
| 236 | + *  | 
                                                        |
| 237 | + */  | 
                                                        |
| 238 | 238 | public function getLiveMarineDatabyCoord($coord, $filter = array())  | 
                                                        
| 239 | 239 |  	{ | 
                                                        
| 240 | 240 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -258,11 +258,11 @@ discard block  | 
                                                    ||
| 258 | 258 | }  | 
                                                        
| 259 | 259 | |
| 260 | 260 | /**  | 
                                                        
| 261 | - * Gets all the spotter information based on the latest data entry and coord  | 
                                                        |
| 262 | - *  | 
                                                        |
| 263 | - * @return Array the spotter information  | 
                                                        |
| 264 | - *  | 
                                                        |
| 265 | - */  | 
                                                        |
| 261 | + * Gets all the spotter information based on the latest data entry and coord  | 
                                                        |
| 262 | + *  | 
                                                        |
| 263 | + * @return Array the spotter information  | 
                                                        |
| 264 | + *  | 
                                                        |
| 265 | + */  | 
                                                        |
| 266 | 266 | public function getMinLiveMarineDatabyCoord($coord, $filter = array())  | 
                                                        
| 267 | 267 |  	{ | 
                                                        
| 268 | 268 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -290,11 +290,11 @@ discard block  | 
                                                    ||
| 290 | 290 | }  | 
                                                        
| 291 | 291 | |
| 292 | 292 | /**  | 
                                                        
| 293 | - * Gets all the spotter information based on a user's latitude and longitude  | 
                                                        |
| 294 | - *  | 
                                                        |
| 295 | - * @return Array the spotter information  | 
                                                        |
| 296 | - *  | 
                                                        |
| 297 | - */  | 
                                                        |
| 293 | + * Gets all the spotter information based on a user's latitude and longitude  | 
                                                        |
| 294 | + *  | 
                                                        |
| 295 | + * @return Array the spotter information  | 
                                                        |
| 296 | + *  | 
                                                        |
| 297 | + */  | 
                                                        |
| 298 | 298 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval)  | 
                                                        
| 299 | 299 |  	{ | 
                                                        
| 300 | 300 | $Marine = new Marine($this->db);  | 
                                                        
@@ -307,134 +307,134 @@ discard block  | 
                                                    ||
| 307 | 307 | if ($lng != '')  | 
                                                        
| 308 | 308 |  		{ | 
                                                        
| 309 | 309 | if (!is_numeric($lng))  | 
                                                        
| 310 | -                        { | 
                                                        |
| 311 | - return false;  | 
                                                        |
| 312 | - }  | 
                                                        |
| 313 | - }  | 
                                                        |
| 314 | -  | 
                                                        |
| 315 | - if ($radius != '')  | 
                                                        |
| 316 | -                { | 
                                                        |
| 317 | - if (!is_numeric($radius))  | 
                                                        |
| 318 | -                        { | 
                                                        |
| 319 | - return false;  | 
                                                        |
| 320 | - }  | 
                                                        |
| 321 | - }  | 
                                                        |
| 310 | +						{ | 
                                                        |
| 311 | + return false;  | 
                                                        |
| 312 | + }  | 
                                                        |
| 313 | + }  | 
                                                        |
| 314 | +  | 
                                                        |
| 315 | + if ($radius != '')  | 
                                                        |
| 316 | +				{ | 
                                                        |
| 317 | + if (!is_numeric($radius))  | 
                                                        |
| 318 | +						{ | 
                                                        |
| 319 | + return false;  | 
                                                        |
| 320 | + }  | 
                                                        |
| 321 | + }  | 
                                                        |
| 322 | 322 | $additional_query = '';  | 
                                                        
| 323 | 323 | if ($interval != '')  | 
                                                        
| 324 | -                { | 
                                                        |
| 325 | - if (!is_string($interval))  | 
                                                        |
| 326 | -                        { | 
                                                        |
| 327 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 328 | - return false;  | 
                                                        |
| 329 | -                        } else { | 
                                                        |
| 330 | - if ($interval == '1m')  | 
                                                        |
| 331 | -                { | 
                                                        |
| 332 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 333 | -                } else if ($interval == '15m'){ | 
                                                        |
| 334 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';  | 
                                                        |
| 335 | - }  | 
                                                        |
| 336 | - }  | 
                                                        |
| 337 | -                } else { | 
                                                        |
| 338 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 339 | - }  | 
                                                        |
| 340 | -  | 
                                                        |
| 341 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live  | 
                                                        |
| 324 | +				{ | 
                                                        |
| 325 | + if (!is_string($interval))  | 
                                                        |
| 326 | +						{ | 
                                                        |
| 327 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 328 | + return false;  | 
                                                        |
| 329 | +						} else { | 
                                                        |
| 330 | + if ($interval == '1m')  | 
                                                        |
| 331 | +				{ | 
                                                        |
| 332 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 333 | +				} else if ($interval == '15m'){ | 
                                                        |
| 334 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';  | 
                                                        |
| 335 | + }  | 
                                                        |
| 336 | + }  | 
                                                        |
| 337 | +				} else { | 
                                                        |
| 338 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        |
| 339 | + }  | 
                                                        |
| 340 | +  | 
                                                        |
| 341 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live  | 
                                                        |
| 342 | 342 | WHERE marine_live.latitude <> ''  | 
                                                        
| 343 | 343 | AND marine_live.longitude <> ''  | 
                                                        
| 344 | 344 | ".$additional_query."  | 
                                                        
| 345 | 345 | HAVING distance < :radius  | 
                                                        
| 346 | 346 | ORDER BY distance";  | 
                                                        
| 347 | 347 | |
| 348 | -                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); | 
                                                        |
| 348 | +				$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); | 
                                                        |
| 349 | 349 | |
| 350 | - return $spotter_array;  | 
                                                        |
| 351 | - }  | 
                                                        |
| 350 | + return $spotter_array;  | 
                                                        |
| 351 | + }  | 
                                                        |
| 352 | 352 | |
| 353 | 353 | |
| 354 | - /**  | 
                                                        |
| 355 | - * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 356 | - *  | 
                                                        |
| 357 | - * @return Array the spotter information  | 
                                                        |
| 358 | - *  | 
                                                        |
| 359 | - */  | 
                                                        |
| 354 | + /**  | 
                                                        |
| 355 | + * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 356 | + *  | 
                                                        |
| 357 | + * @return Array the spotter information  | 
                                                        |
| 358 | + *  | 
                                                        |
| 359 | + */  | 
                                                        |
| 360 | 360 | public function getLastLiveMarineDataByIdent($ident)  | 
                                                        
| 361 | 361 |  	{ | 
                                                        
| 362 | 362 | $Marine = new Marine($this->db);  | 
                                                        
| 363 | 363 |  		date_default_timezone_set('UTC'); | 
                                                        
| 364 | 364 | |
| 365 | 365 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 366 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 366 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 367 | 367 | |
| 368 | 368 |  		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); | 
                                                        
| 369 | 369 | |
| 370 | 370 | return $spotter_array;  | 
                                                        
| 371 | 371 | }  | 
                                                        
| 372 | 372 | |
| 373 | - /**  | 
                                                        |
| 374 | - * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 375 | - *  | 
                                                        |
| 376 | - * @return Array the spotter information  | 
                                                        |
| 377 | - *  | 
                                                        |
| 378 | - */  | 
                                                        |
| 373 | + /**  | 
                                                        |
| 374 | + * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 375 | + *  | 
                                                        |
| 376 | + * @return Array the spotter information  | 
                                                        |
| 377 | + *  | 
                                                        |
| 378 | + */  | 
                                                        |
| 379 | 379 | public function getDateLiveMarineDataByIdent($ident,$date)  | 
                                                        
| 380 | 380 |  	{ | 
                                                        
| 381 | 381 | $Marine = new Marine($this->db);  | 
                                                        
| 382 | 382 |  		date_default_timezone_set('UTC'); | 
                                                        
| 383 | 383 | |
| 384 | 384 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 385 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 385 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 386 | 386 | |
| 387 | -                $date = date('c',$date); | 
                                                        |
| 387 | +				$date = date('c',$date); | 
                                                        |
| 388 | 388 |  		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); | 
                                                        
| 389 | 389 | |
| 390 | 390 | return $spotter_array;  | 
                                                        
| 391 | 391 | }  | 
                                                        
| 392 | 392 | |
| 393 | - /**  | 
                                                        |
| 394 | - * Gets last spotter information based on a particular callsign  | 
                                                        |
| 395 | - *  | 
                                                        |
| 396 | - * @return Array the spotter information  | 
                                                        |
| 397 | - *  | 
                                                        |
| 398 | - */  | 
                                                        |
| 393 | + /**  | 
                                                        |
| 394 | + * Gets last spotter information based on a particular callsign  | 
                                                        |
| 395 | + *  | 
                                                        |
| 396 | + * @return Array the spotter information  | 
                                                        |
| 397 | + *  | 
                                                        |
| 398 | + */  | 
                                                        |
| 399 | 399 | public function getLastLiveMarineDataById($id)  | 
                                                        
| 400 | 400 |  	{ | 
                                                        
| 401 | 401 | $Marine = new Marine($this->db);  | 
                                                        
| 402 | 402 |  		date_default_timezone_set('UTC'); | 
                                                        
| 403 | 403 | |
| 404 | 404 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 405 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 405 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 406 | 406 | |
| 407 | 407 |  		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); | 
                                                        
| 408 | 408 | |
| 409 | 409 | return $spotter_array;  | 
                                                        
| 410 | 410 | }  | 
                                                        
| 411 | 411 | |
| 412 | - /**  | 
                                                        |
| 413 | - * Gets last spotter information based on a particular callsign  | 
                                                        |
| 414 | - *  | 
                                                        |
| 415 | - * @return Array the spotter information  | 
                                                        |
| 416 | - *  | 
                                                        |
| 417 | - */  | 
                                                        |
| 412 | + /**  | 
                                                        |
| 413 | + * Gets last spotter information based on a particular callsign  | 
                                                        |
| 414 | + *  | 
                                                        |
| 415 | + * @return Array the spotter information  | 
                                                        |
| 416 | + *  | 
                                                        |
| 417 | + */  | 
                                                        |
| 418 | 418 | public function getDateLiveMarineDataById($id,$date)  | 
                                                        
| 419 | 419 |  	{ | 
                                                        
| 420 | 420 | $Marine = new Marine($this->db);  | 
                                                        
| 421 | 421 |  		date_default_timezone_set('UTC'); | 
                                                        
| 422 | 422 | |
| 423 | 423 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 424 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 425 | -                $date = date('c',$date); | 
                                                        |
| 424 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 425 | +				$date = date('c',$date); | 
                                                        |
| 426 | 426 |  		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); | 
                                                        
| 427 | 427 | |
| 428 | 428 | return $spotter_array;  | 
                                                        
| 429 | 429 | }  | 
                                                        
| 430 | 430 | |
| 431 | 431 | |
| 432 | - /**  | 
                                                        |
| 433 | - * Gets all the spotter information based on a particular id  | 
                                                        |
| 434 | - *  | 
                                                        |
| 435 | - * @return Array the spotter information  | 
                                                        |
| 436 | - *  | 
                                                        |
| 437 | - */  | 
                                                        |
| 432 | + /**  | 
                                                        |
| 433 | + * Gets all the spotter information based on a particular id  | 
                                                        |
| 434 | + *  | 
                                                        |
| 435 | + * @return Array the spotter information  | 
                                                        |
| 436 | + *  | 
                                                        |
| 437 | + */  | 
                                                        |
| 438 | 438 | public function getAllLiveMarineDataById($id,$liveinterval = false)  | 
                                                        
| 439 | 439 |  	{ | 
                                                        
| 440 | 440 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
@@ -462,18 +462,18 @@ discard block  | 
                                                    ||
| 462 | 462 | return $spotter_array;  | 
                                                        
| 463 | 463 | }  | 
                                                        
| 464 | 464 | |
| 465 | - /**  | 
                                                        |
| 466 | - * Gets all the spotter information based on a particular ident  | 
                                                        |
| 467 | - *  | 
                                                        |
| 468 | - * @return Array the spotter information  | 
                                                        |
| 469 | - *  | 
                                                        |
| 470 | - */  | 
                                                        |
| 465 | + /**  | 
                                                        |
| 466 | + * Gets all the spotter information based on a particular ident  | 
                                                        |
| 467 | + *  | 
                                                        |
| 468 | + * @return Array the spotter information  | 
                                                        |
| 469 | + *  | 
                                                        |
| 470 | + */  | 
                                                        |
| 471 | 471 | public function getAllLiveMarineDataByIdent($ident)  | 
                                                        
| 472 | 472 |  	{ | 
                                                        
| 473 | 473 |  		date_default_timezone_set('UTC'); | 
                                                        
| 474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 475 | 475 | $query = self::$global_query.' WHERE marine_live.ident = :ident';  | 
                                                        
| 476 | -    		try { | 
                                                        |
| 476 | +			try { | 
                                                        |
| 477 | 477 | |
| 478 | 478 | $sth = $this->db->prepare($query);  | 
                                                        
| 479 | 479 |  			$sth->execute(array(':ident' => $ident)); | 
                                                        
@@ -487,23 +487,23 @@ discard block  | 
                                                    ||
| 487 | 487 | |
| 488 | 488 | |
| 489 | 489 | /**  | 
                                                        
| 490 | - * Deletes all info in the table  | 
                                                        |
| 491 | - *  | 
                                                        |
| 492 | - * @return String success or false  | 
                                                        |
| 493 | - *  | 
                                                        |
| 494 | - */  | 
                                                        |
| 490 | + * Deletes all info in the table  | 
                                                        |
| 491 | + *  | 
                                                        |
| 492 | + * @return String success or false  | 
                                                        |
| 493 | + *  | 
                                                        |
| 494 | + */  | 
                                                        |
| 495 | 495 | public function deleteLiveMarineData()  | 
                                                        
| 496 | 496 |  	{ | 
                                                        
| 497 | 497 | global $globalDBdriver;  | 
                                                        
| 498 | 498 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 499 | 499 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";  | 
                                                        
| 500 | 500 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';  | 
                                                        
| 501 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";  | 
                                                        |
| 501 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";  | 
                                                        |
| 502 | 502 |  		} else { | 
                                                        
| 503 | 503 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";  | 
                                                        
| 504 | 504 | }  | 
                                                        
| 505 | 505 | |
| 506 | -    		try { | 
                                                        |
| 506 | +			try { | 
                                                        |
| 507 | 507 | |
| 508 | 508 | $sth = $this->db->prepare($query);  | 
                                                        
| 509 | 509 | $sth->execute();  | 
                                                        
@@ -515,18 +515,18 @@ discard block  | 
                                                    ||
| 515 | 515 | }  | 
                                                        
| 516 | 516 | |
| 517 | 517 | /**  | 
                                                        
| 518 | - * Deletes all info in the table for aircraft not seen since 2 HOUR  | 
                                                        |
| 519 | - *  | 
                                                        |
| 520 | - * @return String success or false  | 
                                                        |
| 521 | - *  | 
                                                        |
| 522 | - */  | 
                                                        |
| 518 | + * Deletes all info in the table for aircraft not seen since 2 HOUR  | 
                                                        |
| 519 | + *  | 
                                                        |
| 520 | + * @return String success or false  | 
                                                        |
| 521 | + *  | 
                                                        |
| 522 | + */  | 
                                                        |
| 523 | 523 | public function deleteLiveMarineDataNotUpdated()  | 
                                                        
| 524 | 524 |  	{ | 
                                                        
| 525 | 525 | global $globalDBdriver, $globalDebug;  | 
                                                        
| 526 | 526 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 527 | 527 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';  | 
                                                        
| 528 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";  | 
                                                        |
| 529 | -    			try { | 
                                                        |
| 528 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";  | 
                                                        |
| 529 | +				try { | 
                                                        |
| 530 | 530 | |
| 531 | 531 | $sth = $this->db->prepare($query);  | 
                                                        
| 532 | 532 | $sth->execute();  | 
                                                        
@@ -534,8 +534,8 @@ discard block  | 
                                                    ||
| 534 | 534 | return "error";  | 
                                                        
| 535 | 535 | }  | 
                                                        
| 536 | 536 |  			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; | 
                                                        
| 537 | - $i = 0;  | 
                                                        |
| 538 | - $j =0;  | 
                                                        |
| 537 | + $i = 0;  | 
                                                        |
| 538 | + $j =0;  | 
                                                        |
| 539 | 539 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 540 | 540 | foreach($all as $row)  | 
                                                        
| 541 | 541 |  			{ | 
                                                        
@@ -543,20 +543,20 @@ discard block  | 
                                                    ||
| 543 | 543 | $j++;  | 
                                                        
| 544 | 544 |  				if ($j == 30) { | 
                                                        
| 545 | 545 | if ($globalDebug) echo ".";  | 
                                                        
| 546 | -				    	try { | 
                                                        |
| 546 | +						try { | 
                                                        |
| 547 | 547 | |
| 548 | 548 | $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        
| 549 | 549 | $sth->execute();  | 
                                                        
| 550 | 550 |  					} catch(PDOException $e) { | 
                                                        
| 551 | 551 | return "error";  | 
                                                        
| 552 | 552 | }  | 
                                                        
| 553 | -                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; | 
                                                        |
| 554 | - $j = 0;  | 
                                                        |
| 553 | +									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; | 
                                                        |
| 554 | + $j = 0;  | 
                                                        |
| 555 | 555 | }  | 
                                                        
| 556 | 556 | $query_delete .= "'".$row['fammarine_id']."',";  | 
                                                        
| 557 | 557 | }  | 
                                                        
| 558 | 558 |  			if ($i > 0) { | 
                                                        
| 559 | -    				try { | 
                                                        |
| 559 | +					try { | 
                                                        |
| 560 | 560 | |
| 561 | 561 | $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        
| 562 | 562 | $sth->execute();  | 
                                                        
@@ -567,9 +567,9 @@ discard block  | 
                                                    ||
| 567 | 567 | return "success";  | 
                                                        
| 568 | 568 |  		} elseif ($globalDBdriver == 'pgsql') { | 
                                                        
| 569 | 569 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";  | 
                                                        
| 570 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";  | 
                                                        |
| 571 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";  | 
                                                        |
| 572 | -    			try { | 
                                                        |
| 570 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";  | 
                                                        |
| 571 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";  | 
                                                        |
| 572 | +				try { | 
                                                        |
| 573 | 573 | |
| 574 | 574 | $sth = $this->db->prepare($query);  | 
                                                        
| 575 | 575 | $sth->execute();  | 
                                                        
@@ -613,17 +613,17 @@ discard block  | 
                                                    ||
| 613 | 613 | }  | 
                                                        
| 614 | 614 | |
| 615 | 615 | /**  | 
                                                        
| 616 | - * Deletes all info in the table for an ident  | 
                                                        |
| 617 | - *  | 
                                                        |
| 618 | - * @return String success or false  | 
                                                        |
| 619 | - *  | 
                                                        |
| 620 | - */  | 
                                                        |
| 616 | + * Deletes all info in the table for an ident  | 
                                                        |
| 617 | + *  | 
                                                        |
| 618 | + * @return String success or false  | 
                                                        |
| 619 | + *  | 
                                                        |
| 620 | + */  | 
                                                        |
| 621 | 621 | public function deleteLiveMarineDataByIdent($ident)  | 
                                                        
| 622 | 622 |  	{ | 
                                                        
| 623 | 623 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 624 | 624 | $query = 'DELETE FROM marine_live WHERE ident = :ident';  | 
                                                        
| 625 | 625 | |
| 626 | -    		try { | 
                                                        |
| 626 | +			try { | 
                                                        |
| 627 | 627 | |
| 628 | 628 | $sth = $this->db->prepare($query);  | 
                                                        
| 629 | 629 |  			$sth->execute(array(':ident' => $ident)); | 
                                                        
@@ -635,17 +635,17 @@ discard block  | 
                                                    ||
| 635 | 635 | }  | 
                                                        
| 636 | 636 | |
| 637 | 637 | /**  | 
                                                        
| 638 | - * Deletes all info in the table for an id  | 
                                                        |
| 639 | - *  | 
                                                        |
| 640 | - * @return String success or false  | 
                                                        |
| 641 | - *  | 
                                                        |
| 642 | - */  | 
                                                        |
| 638 | + * Deletes all info in the table for an id  | 
                                                        |
| 639 | + *  | 
                                                        |
| 640 | + * @return String success or false  | 
                                                        |
| 641 | + *  | 
                                                        |
| 642 | + */  | 
                                                        |
| 643 | 643 | public function deleteLiveMarineDataById($id)  | 
                                                        
| 644 | 644 |  	{ | 
                                                        
| 645 | 645 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 646 | 646 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id';  | 
                                                        
| 647 | 647 | |
| 648 | -    		try { | 
                                                        |
| 648 | +			try { | 
                                                        |
| 649 | 649 | |
| 650 | 650 | $sth = $this->db->prepare($query);  | 
                                                        
| 651 | 651 |  			$sth->execute(array(':id' => $id)); | 
                                                        
@@ -658,11 +658,11 @@ discard block  | 
                                                    ||
| 658 | 658 | |
| 659 | 659 | |
| 660 | 660 | /**  | 
                                                        
| 661 | - * Gets the aircraft ident within the last hour  | 
                                                        |
| 662 | - *  | 
                                                        |
| 663 | - * @return String the ident  | 
                                                        |
| 664 | - *  | 
                                                        |
| 665 | - */  | 
                                                        |
| 661 | + * Gets the aircraft ident within the last hour  | 
                                                        |
| 662 | + *  | 
                                                        |
| 663 | + * @return String the ident  | 
                                                        |
| 664 | + *  | 
                                                        |
| 665 | + */  | 
                                                        |
| 666 | 666 | public function getIdentFromLastHour($ident)  | 
                                                        
| 667 | 667 |  	{ | 
                                                        
| 668 | 668 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -688,14 +688,14 @@ discard block  | 
                                                    ||
| 688 | 688 | $ident_result = $row['ident'];  | 
                                                        
| 689 | 689 | }  | 
                                                        
| 690 | 690 | return $ident_result;  | 
                                                        
| 691 | - }  | 
                                                        |
| 691 | + }  | 
                                                        |
| 692 | 692 | |
| 693 | 693 | /**  | 
                                                        
| 694 | - * Check recent aircraft  | 
                                                        |
| 695 | - *  | 
                                                        |
| 696 | - * @return String the ident  | 
                                                        |
| 697 | - *  | 
                                                        |
| 698 | - */  | 
                                                        |
| 694 | + * Check recent aircraft  | 
                                                        |
| 695 | + *  | 
                                                        |
| 696 | + * @return String the ident  | 
                                                        |
| 697 | + *  | 
                                                        |
| 698 | + */  | 
                                                        |
| 699 | 699 | public function checkIdentRecent($ident)  | 
                                                        
| 700 | 700 |  	{ | 
                                                        
| 701 | 701 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -721,14 +721,14 @@ discard block  | 
                                                    ||
| 721 | 721 | $ident_result = $row['fammarine_id'];  | 
                                                        
| 722 | 722 | }  | 
                                                        
| 723 | 723 | return $ident_result;  | 
                                                        
| 724 | - }  | 
                                                        |
| 724 | + }  | 
                                                        |
| 725 | 725 | |
| 726 | 726 | /**  | 
                                                        
| 727 | - * Check recent aircraft by id  | 
                                                        |
| 728 | - *  | 
                                                        |
| 729 | - * @return String the ident  | 
                                                        |
| 730 | - *  | 
                                                        |
| 731 | - */  | 
                                                        |
| 727 | + * Check recent aircraft by id  | 
                                                        |
| 728 | + *  | 
                                                        |
| 729 | + * @return String the ident  | 
                                                        |
| 730 | + *  | 
                                                        |
| 731 | + */  | 
                                                        |
| 732 | 732 | public function checkIdRecent($id)  | 
                                                        
| 733 | 733 |  	{ | 
                                                        
| 734 | 734 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -754,14 +754,14 @@ discard block  | 
                                                    ||
| 754 | 754 | $ident_result = $row['fammarine_id'];  | 
                                                        
| 755 | 755 | }  | 
                                                        
| 756 | 756 | return $ident_result;  | 
                                                        
| 757 | - }  | 
                                                        |
| 757 | + }  | 
                                                        |
| 758 | 758 | |
| 759 | 759 | /**  | 
                                                        
| 760 | - * Check recent aircraft by mmsi  | 
                                                        |
| 761 | - *  | 
                                                        |
| 762 | - * @return String the ident  | 
                                                        |
| 763 | - *  | 
                                                        |
| 764 | - */  | 
                                                        |
| 760 | + * Check recent aircraft by mmsi  | 
                                                        |
| 761 | + *  | 
                                                        |
| 762 | + * @return String the ident  | 
                                                        |
| 763 | + *  | 
                                                        |
| 764 | + */  | 
                                                        |
| 765 | 765 | public function checkMMSIRecent($mmsi)  | 
                                                        
| 766 | 766 |  	{ | 
                                                        
| 767 | 767 | global $globalDBdriver, $globalTimezone;  | 
                                                        
@@ -787,19 +787,19 @@ discard block  | 
                                                    ||
| 787 | 787 | $ident_result = $row['fammarine_id'];  | 
                                                        
| 788 | 788 | }  | 
                                                        
| 789 | 789 | return $ident_result;  | 
                                                        
| 790 | - }  | 
                                                        |
| 790 | + }  | 
                                                        |
| 791 | 791 | |
| 792 | 792 | /**  | 
                                                        
| 793 | - * Adds a new spotter data  | 
                                                        |
| 794 | - *  | 
                                                        |
| 795 | - * @param String $fammarine_id the ID from flightaware  | 
                                                        |
| 796 | - * @param String $ident the flight ident  | 
                                                        |
| 797 | - * @param String $aircraft_icao the aircraft type  | 
                                                        |
| 798 | - * @param String $departure_airport_icao the departure airport  | 
                                                        |
| 799 | - * @param String $arrival_airport_icao the arrival airport  | 
                                                        |
| 800 | - * @return String success or false  | 
                                                        |
| 801 | - *  | 
                                                        |
| 802 | - */  | 
                                                        |
| 793 | + * Adds a new spotter data  | 
                                                        |
| 794 | + *  | 
                                                        |
| 795 | + * @param String $fammarine_id the ID from flightaware  | 
                                                        |
| 796 | + * @param String $ident the flight ident  | 
                                                        |
| 797 | + * @param String $aircraft_icao the aircraft type  | 
                                                        |
| 798 | + * @param String $departure_airport_icao the departure airport  | 
                                                        |
| 799 | + * @param String $arrival_airport_icao the arrival airport  | 
                                                        |
| 800 | + * @return String success or false  | 
                                                        |
| 801 | + *  | 
                                                        |
| 802 | + */  | 
                                                        |
| 803 | 803 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')  | 
                                                        
| 804 | 804 |  	{ | 
                                                        
| 805 | 805 | global $globalURL, $globalArchive, $globalDebug;  | 
                                                        
@@ -870,10 +870,10 @@ discard block  | 
                                                    ||
| 870 | 870 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);  | 
                                                        
| 871 | 871 | |
| 872 | 872 | |
| 873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;  | 
                                                        |
| 874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;  | 
                                                        |
| 875 | - if ($arrival_date == '') $arrival_date = NULL;  | 
                                                        |
| 876 | - $query = '';  | 
                                                        |
| 873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;  | 
                                                        |
| 874 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;  | 
                                                        |
| 875 | + if ($arrival_date == '') $arrival_date = NULL;  | 
                                                        |
| 876 | + $query = '';  | 
                                                        |
| 877 | 877 |  		if ($globalArchive) { | 
                                                        
| 878 | 878 | if ($globalDebug) echo '-- Delete previous data -- ';  | 
                                                        
| 879 | 879 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';  | 
                                                        
@@ -16,33 +16,33 @@ discard block  | 
                                                    ||
| 16 | 16 | * @param Array $filter the filter  | 
                                                        
| 17 | 17 | * @return Array the SQL part  | 
                                                        
| 18 | 18 | */  | 
                                                        
| 19 | -	public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                        |
| 19 | +	public function getFilter($filter = array(), $where = false, $and = false) { | 
                                                        |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;  | 
                                                        
| 21 | 21 | $filters = array();  | 
                                                        
| 22 | 22 |  		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { | 
                                                        
| 23 | 23 |  			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { | 
                                                        
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName];  | 
                                                        
| 25 | 25 |  			} else { | 
                                                        
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);  | 
                                                        |
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);  | 
                                                        |
| 27 | 27 | }  | 
                                                        
| 28 | 28 | }  | 
                                                        
| 29 | 29 |  		if (isset($filter[0]['source'])) { | 
                                                        
| 30 | - $filters = array_merge($filters,$filter);  | 
                                                        |
| 30 | + $filters = array_merge($filters, $filter);  | 
                                                        |
| 31 | 31 | }  | 
                                                        
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);  | 
                                                        |
| 33 | 33 | $filter_query_join = '';  | 
                                                        
| 34 | 34 | $filter_query_where = '';  | 
                                                        
| 35 | -		foreach($filters as $flt) { | 
                                                        |
| 35 | +		foreach ($filters as $flt) { | 
                                                        |
| 36 | 36 |  			if (isset($flt['idents']) && !empty($flt['idents'])) { | 
                                                        
| 37 | 37 |  				if (isset($flt['source'])) { | 
                                                        
| 38 | -					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; | 
                                                        |
| 38 | +					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; | 
                                                        |
| 39 | 39 |  				} else { | 
                                                        
| 40 | -					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; | 
                                                        |
| 40 | +					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; | 
                                                        |
| 41 | 41 | }  | 
                                                        
| 42 | 42 | }  | 
                                                        
| 43 | 43 | }  | 
                                                        
| 44 | 44 |  		if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        
| 45 | -			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; | 
                                                        |
| 45 | +			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; | 
                                                        |
| 46 | 46 | }  | 
                                                        
| 47 | 47 |  		if (isset($filter['ident']) && !empty($filter['ident'])) { | 
                                                        
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'";  | 
                                                        
@@ -71,15 +71,15 @@ discard block  | 
                                                    ||
| 71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";  | 
                                                        
| 72 | 72 | }  | 
                                                        
| 73 | 73 | }  | 
                                                        
| 74 | -			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; | 
                                                        |
| 74 | +			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; | 
                                                        |
| 75 | 75 | }  | 
                                                        
| 76 | 76 |  		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 77 | -			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 77 | +			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; | 
                                                        |
| 78 | 78 | }  | 
                                                        
| 79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';  | 
                                                        
| 80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';  | 
                                                        
| 81 | 81 |  		if ($filter_query_where != '') { | 
                                                        
| 82 | -			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); | 
                                                        |
| 82 | +			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); | 
                                                        |
| 83 | 83 | }  | 
                                                        
| 84 | 84 | $filter_query = $filter_query_join.$filter_query_where;  | 
                                                        
| 85 | 85 | return $filter_query;  | 
                                                        
@@ -102,8 +102,8 @@ discard block  | 
                                                    ||
| 102 | 102 | if ($limit != '')  | 
                                                        
| 103 | 103 |  		{ | 
                                                        
| 104 | 104 |  			$limit_array = explode(',', $limit); | 
                                                        
| 105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 108 | 108 |  			{ | 
                                                        
| 109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];  | 
                                                        
@@ -126,7 +126,7 @@ discard block  | 
                                                    ||
| 126 | 126 |  		} else { | 
                                                        
| 127 | 127 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;  | 
                                                        
| 128 | 128 | }  | 
                                                        
| 129 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);  | 
                                                        |
| 129 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);  | 
                                                        |
| 130 | 130 | |
| 131 | 131 | return $spotter_array;  | 
                                                        
| 132 | 132 | }  | 
                                                        
@@ -142,7 +142,7 @@ discard block  | 
                                                    ||
| 142 | 142 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 143 | 143 |  		date_default_timezone_set('UTC'); | 
                                                        
| 144 | 144 | |
| 145 | - $filter_query = $this->getFilter($filter,true,true);  | 
                                                        |
| 145 | + $filter_query = $this->getFilter($filter, true, true);  | 
                                                        |
| 146 | 146 | |
| 147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        
| 148 | 148 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -156,7 +156,7 @@ discard block  | 
                                                    ||
| 156 | 156 |  		try { | 
                                                        
| 157 | 157 | $sth = $this->db->prepare($query);  | 
                                                        
| 158 | 158 | $sth->execute();  | 
                                                        
| 159 | -		} catch(PDOException $e) { | 
                                                        |
| 159 | +		} catch (PDOException $e) { | 
                                                        |
| 160 | 160 | echo $e->getMessage();  | 
                                                        
| 161 | 161 | die;  | 
                                                        
| 162 | 162 | }  | 
                                                        
@@ -176,15 +176,15 @@ discard block  | 
                                                    ||
| 176 | 176 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 177 | 177 |  		date_default_timezone_set('UTC'); | 
                                                        
| 178 | 178 | |
| 179 | - $filter_query = $this->getFilter($filter,true,true);  | 
                                                        |
| 179 | + $filter_query = $this->getFilter($filter, true, true);  | 
                                                        |
| 180 | 180 | |
| 181 | 181 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        
| 182 | 182 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 183 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        |
| 183 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        |
| 184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'  | 
                                                        
| 185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date";  | 
                                                        
| 186 | 186 |                  } else { | 
                                                        
| 187 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        |
| 187 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        |
| 188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'  | 
                                                        
| 189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date";  | 
                                                        
| 190 | 190 | }  | 
                                                        
@@ -192,7 +192,7 @@ discard block  | 
                                                    ||
| 192 | 192 |      		try { | 
                                                        
| 193 | 193 | $sth = $this->db->prepare($query);  | 
                                                        
| 194 | 194 | $sth->execute();  | 
                                                        
| 195 | -		} catch(PDOException $e) { | 
                                                        |
| 195 | +		} catch (PDOException $e) { | 
                                                        |
| 196 | 196 | echo $e->getMessage();  | 
                                                        
| 197 | 197 | die;  | 
                                                        
| 198 | 198 | }  | 
                                                        
@@ -209,7 +209,7 @@ discard block  | 
                                                    ||
| 209 | 209 | public function getLiveMarineCount($filter = array())  | 
                                                        
| 210 | 210 |  	{ | 
                                                        
| 211 | 211 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 212 | - $filter_query = $this->getFilter($filter,true,true);  | 
                                                        |
| 212 | + $filter_query = $this->getFilter($filter, true, true);  | 
                                                        |
| 213 | 213 | |
| 214 | 214 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        
| 215 | 215 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -220,7 +220,7 @@ discard block  | 
                                                    ||
| 220 | 220 |  		try { | 
                                                        
| 221 | 221 | $sth = $this->db->prepare($query);  | 
                                                        
| 222 | 222 | $sth->execute();  | 
                                                        
| 223 | -		} catch(PDOException $e) { | 
                                                        |
| 223 | +		} catch (PDOException $e) { | 
                                                        |
| 224 | 224 | echo $e->getMessage();  | 
                                                        
| 225 | 225 | die;  | 
                                                        
| 226 | 226 | }  | 
                                                        
@@ -243,10 +243,10 @@ discard block  | 
                                                    ||
| 243 | 243 | $filter_query = $this->getFilter($filter);  | 
                                                        
| 244 | 244 | |
| 245 | 245 |  		if (is_array($coord)) { | 
                                                        
| 246 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 247 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 248 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 249 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 246 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 247 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 248 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 249 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 250 | 250 | } else return array();  | 
                                                        
| 251 | 251 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 252 | 252 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;  | 
                                                        
@@ -271,17 +271,17 @@ discard block  | 
                                                    ||
| 271 | 271 | $filter_query = $this->getFilter($filter);  | 
                                                        
| 272 | 272 | |
| 273 | 273 |  		if (is_array($coord)) { | 
                                                        
| 274 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 275 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 276 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 277 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 274 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 275 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 276 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 277 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 278 | 278 | } else return array();  | 
                                                        
| 279 | 279 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 280 | 280 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        
| 281 | 281 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."  | 
                                                        
| 282 | 282 | ORDER BY marine_live.fammarine_id, marine_live.date";  | 
                                                        
| 283 | 283 |  		} else { | 
                                                        
| 284 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        |
| 284 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        |
| 285 | 285 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong."  | 
                                                        
| 286 | 286 | ORDER BY marine_live.fammarine_id, marine_live.date";  | 
                                                        
| 287 | 287 | }  | 
                                                        
@@ -330,7 +330,7 @@ discard block  | 
                                                    ||
| 330 | 330 | if ($interval == '1m')  | 
                                                        
| 331 | 331 |                  { | 
                                                        
| 332 | 332 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        
| 333 | -                } else if ($interval == '15m'){ | 
                                                        |
| 333 | +                } else if ($interval == '15m') { | 
                                                        |
| 334 | 334 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';  | 
                                                        
| 335 | 335 | }  | 
                                                        
| 336 | 336 | }  | 
                                                        
@@ -338,14 +338,14 @@ discard block  | 
                                                    ||
| 338 | 338 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';  | 
                                                        
| 339 | 339 | }  | 
                                                        
| 340 | 340 | |
| 341 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live  | 
                                                        |
| 341 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live  | 
                                                        |
| 342 | 342 | WHERE marine_live.latitude <> ''  | 
                                                        
| 343 | 343 | AND marine_live.longitude <> ''  | 
                                                        
| 344 | 344 | ".$additional_query."  | 
                                                        
| 345 | 345 | HAVING distance < :radius  | 
                                                        
| 346 | 346 | ORDER BY distance";  | 
                                                        
| 347 | 347 | |
| 348 | -                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); | 
                                                        |
| 348 | +                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); | 
                                                        |
| 349 | 349 | |
| 350 | 350 | return $spotter_array;  | 
                                                        
| 351 | 351 | }  | 
                                                        
@@ -363,9 +363,9 @@ discard block  | 
                                                    ||
| 363 | 363 |  		date_default_timezone_set('UTC'); | 
                                                        
| 364 | 364 | |
| 365 | 365 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 366 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 366 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 367 | 367 | |
| 368 | -		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); | 
                                                        |
| 368 | +		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); | 
                                                        |
| 369 | 369 | |
| 370 | 370 | return $spotter_array;  | 
                                                        
| 371 | 371 | }  | 
                                                        
@@ -376,16 +376,16 @@ discard block  | 
                                                    ||
| 376 | 376 | * @return Array the spotter information  | 
                                                        
| 377 | 377 | *  | 
                                                        
| 378 | 378 | */  | 
                                                        
| 379 | - public function getDateLiveMarineDataByIdent($ident,$date)  | 
                                                        |
| 379 | + public function getDateLiveMarineDataByIdent($ident, $date)  | 
                                                        |
| 380 | 380 |  	{ | 
                                                        
| 381 | 381 | $Marine = new Marine($this->db);  | 
                                                        
| 382 | 382 |  		date_default_timezone_set('UTC'); | 
                                                        
| 383 | 383 | |
| 384 | 384 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 385 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 385 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 386 | 386 | |
| 387 | -                $date = date('c',$date); | 
                                                        |
| 388 | -		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); | 
                                                        |
| 387 | +                $date = date('c', $date); | 
                                                        |
| 388 | +		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); | 
                                                        |
| 389 | 389 | |
| 390 | 390 | return $spotter_array;  | 
                                                        
| 391 | 391 | }  | 
                                                        
@@ -402,9 +402,9 @@ discard block  | 
                                                    ||
| 402 | 402 |  		date_default_timezone_set('UTC'); | 
                                                        
| 403 | 403 | |
| 404 | 404 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 405 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 405 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 406 | 406 | |
| 407 | -		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); | 
                                                        |
| 407 | +		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); | 
                                                        |
| 408 | 408 | |
| 409 | 409 | return $spotter_array;  | 
                                                        
| 410 | 410 | }  | 
                                                        
@@ -415,15 +415,15 @@ discard block  | 
                                                    ||
| 415 | 415 | * @return Array the spotter information  | 
                                                        
| 416 | 416 | *  | 
                                                        
| 417 | 417 | */  | 
                                                        
| 418 | - public function getDateLiveMarineDataById($id,$date)  | 
                                                        |
| 418 | + public function getDateLiveMarineDataById($id, $date)  | 
                                                        |
| 419 | 419 |  	{ | 
                                                        
| 420 | 420 | $Marine = new Marine($this->db);  | 
                                                        
| 421 | 421 |  		date_default_timezone_set('UTC'); | 
                                                        
| 422 | 422 | |
| 423 | 423 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 424 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 425 | -                $date = date('c',$date); | 
                                                        |
| 426 | -		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); | 
                                                        |
| 424 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';  | 
                                                        |
| 425 | +                $date = date('c', $date); | 
                                                        |
| 426 | +		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); | 
                                                        |
| 427 | 427 | |
| 428 | 428 | return $spotter_array;  | 
                                                        
| 429 | 429 | }  | 
                                                        
@@ -435,7 +435,7 @@ discard block  | 
                                                    ||
| 435 | 435 | * @return Array the spotter information  | 
                                                        
| 436 | 436 | *  | 
                                                        
| 437 | 437 | */  | 
                                                        
| 438 | - public function getAllLiveMarineDataById($id,$liveinterval = false)  | 
                                                        |
| 438 | + public function getAllLiveMarineDataById($id, $liveinterval = false)  | 
                                                        |
| 439 | 439 |  	{ | 
                                                        
| 440 | 440 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 441 | 441 |  		date_default_timezone_set('UTC'); | 
                                                        
@@ -454,7 +454,7 @@ discard block  | 
                                                    ||
| 454 | 454 |  		try { | 
                                                        
| 455 | 455 | $sth = $this->db->prepare($query);  | 
                                                        
| 456 | 456 |  			$sth->execute(array(':id' => $id)); | 
                                                        
| 457 | -		} catch(PDOException $e) { | 
                                                        |
| 457 | +		} catch (PDOException $e) { | 
                                                        |
| 458 | 458 | echo $e->getMessage();  | 
                                                        
| 459 | 459 | die;  | 
                                                        
| 460 | 460 | }  | 
                                                        
@@ -472,12 +472,12 @@ discard block  | 
                                                    ||
| 472 | 472 |  	{ | 
                                                        
| 473 | 473 |  		date_default_timezone_set('UTC'); | 
                                                        
| 474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 475 | - $query = self::$global_query.' WHERE marine_live.ident = :ident';  | 
                                                        |
| 475 | + $query = self::$global_query.' WHERE marine_live.ident = :ident';  | 
                                                        |
| 476 | 476 |      		try { | 
                                                        
| 477 | 477 | |
| 478 | 478 | $sth = $this->db->prepare($query);  | 
                                                        
| 479 | 479 |  			$sth->execute(array(':ident' => $ident)); | 
                                                        
| 480 | -		} catch(PDOException $e) { | 
                                                        |
| 480 | +		} catch (PDOException $e) { | 
                                                        |
| 481 | 481 | echo $e->getMessage();  | 
                                                        
| 482 | 482 | die;  | 
                                                        
| 483 | 483 | }  | 
                                                        
@@ -507,7 +507,7 @@ discard block  | 
                                                    ||
| 507 | 507 | |
| 508 | 508 | $sth = $this->db->prepare($query);  | 
                                                        
| 509 | 509 | $sth->execute();  | 
                                                        
| 510 | -		} catch(PDOException $e) { | 
                                                        |
| 510 | +		} catch (PDOException $e) { | 
                                                        |
| 511 | 511 | return "error";  | 
                                                        
| 512 | 512 | }  | 
                                                        
| 513 | 513 | |
@@ -530,14 +530,14 @@ discard block  | 
                                                    ||
| 530 | 530 | |
| 531 | 531 | $sth = $this->db->prepare($query);  | 
                                                        
| 532 | 532 | $sth->execute();  | 
                                                        
| 533 | -			} catch(PDOException $e) { | 
                                                        |
| 533 | +			} catch (PDOException $e) { | 
                                                        |
| 534 | 534 | return "error";  | 
                                                        
| 535 | 535 | }  | 
                                                        
| 536 | 536 |  			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; | 
                                                        
| 537 | 537 | $i = 0;  | 
                                                        
| 538 | - $j =0;  | 
                                                        |
| 538 | + $j = 0;  | 
                                                        |
| 539 | 539 | $all = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        
| 540 | - foreach($all as $row)  | 
                                                        |
| 540 | + foreach ($all as $row)  | 
                                                        |
| 541 | 541 |  			{ | 
                                                        
| 542 | 542 | $i++;  | 
                                                        
| 543 | 543 | $j++;  | 
                                                        
@@ -545,9 +545,9 @@ discard block  | 
                                                    ||
| 545 | 545 | if ($globalDebug) echo ".";  | 
                                                        
| 546 | 546 |  				    	try { | 
                                                        
| 547 | 547 | |
| 548 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        |
| 548 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")");  | 
                                                        |
| 549 | 549 | $sth->execute();  | 
                                                        
| 550 | -					} catch(PDOException $e) { | 
                                                        |
| 550 | +					} catch (PDOException $e) { | 
                                                        |
| 551 | 551 | return "error";  | 
                                                        
| 552 | 552 | }  | 
                                                        
| 553 | 553 |                                  	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; | 
                                                        
@@ -558,9 +558,9 @@ discard block  | 
                                                    ||
| 558 | 558 |  			if ($i > 0) { | 
                                                        
| 559 | 559 |      				try { | 
                                                        
| 560 | 560 | |
| 561 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        |
| 561 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")");  | 
                                                        |
| 562 | 562 | $sth->execute();  | 
                                                        
| 563 | -				} catch(PDOException $e) { | 
                                                        |
| 563 | +				} catch (PDOException $e) { | 
                                                        |
| 564 | 564 | return "error";  | 
                                                        
| 565 | 565 | }  | 
                                                        
| 566 | 566 | }  | 
                                                        
@@ -573,7 +573,7 @@ discard block  | 
                                                    ||
| 573 | 573 | |
| 574 | 574 | $sth = $this->db->prepare($query);  | 
                                                        
| 575 | 575 | $sth->execute();  | 
                                                        
| 576 | -			} catch(PDOException $e) { | 
                                                        |
| 576 | +			} catch (PDOException $e) { | 
                                                        |
| 577 | 577 | return "error";  | 
                                                        
| 578 | 578 | }  | 
                                                        
| 579 | 579 |  /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; | 
                                                        
@@ -621,13 +621,13 @@ discard block  | 
                                                    ||
| 621 | 621 | public function deleteLiveMarineDataByIdent($ident)  | 
                                                        
| 622 | 622 |  	{ | 
                                                        
| 623 | 623 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 624 | - $query = 'DELETE FROM marine_live WHERE ident = :ident';  | 
                                                        |
| 624 | + $query = 'DELETE FROM marine_live WHERE ident = :ident';  | 
                                                        |
| 625 | 625 | |
| 626 | 626 |      		try { | 
                                                        
| 627 | 627 | |
| 628 | 628 | $sth = $this->db->prepare($query);  | 
                                                        
| 629 | 629 |  			$sth->execute(array(':ident' => $ident)); | 
                                                        
| 630 | -		} catch(PDOException $e) { | 
                                                        |
| 630 | +		} catch (PDOException $e) { | 
                                                        |
| 631 | 631 | return "error";  | 
                                                        
| 632 | 632 | }  | 
                                                        
| 633 | 633 | |
@@ -643,13 +643,13 @@ discard block  | 
                                                    ||
| 643 | 643 | public function deleteLiveMarineDataById($id)  | 
                                                        
| 644 | 644 |  	{ | 
                                                        
| 645 | 645 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 646 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id';  | 
                                                        |
| 646 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id';  | 
                                                        |
| 647 | 647 | |
| 648 | 648 |      		try { | 
                                                        
| 649 | 649 | |
| 650 | 650 | $sth = $this->db->prepare($query);  | 
                                                        
| 651 | 651 |  			$sth->execute(array(':id' => $id)); | 
                                                        
| 652 | -		} catch(PDOException $e) { | 
                                                        |
| 652 | +		} catch (PDOException $e) { | 
                                                        |
| 653 | 653 | return "error";  | 
                                                        
| 654 | 654 | }  | 
                                                        
| 655 | 655 | |
@@ -667,13 +667,13 @@ discard block  | 
                                                    ||
| 667 | 667 |  	{ | 
                                                        
| 668 | 668 | global $globalDBdriver, $globalTimezone;  | 
                                                        
| 669 | 669 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 670 | - $query = 'SELECT marine_live.ident FROM marine_live  | 
                                                        |
| 670 | + $query = 'SELECT marine_live.ident FROM marine_live  | 
                                                        |
| 671 | 671 | WHERE marine_live.ident = :ident  | 
                                                        
| 672 | 672 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR)  | 
                                                        
| 673 | 673 | AND marine_live.date < UTC_TIMESTAMP()';  | 
                                                        
| 674 | 674 |  			$query_data = array(':ident' => $ident); | 
                                                        
| 675 | 675 |  		} else { | 
                                                        
| 676 | - $query = "SELECT marine_live.ident FROM marine_live  | 
                                                        |
| 676 | + $query = "SELECT marine_live.ident FROM marine_live  | 
                                                        |
| 677 | 677 | WHERE marine_live.ident = :ident  | 
                                                        
| 678 | 678 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'  | 
                                                        
| 679 | 679 | AND marine_live.date < now() AT TIME ZONE 'UTC'";  | 
                                                        
@@ -682,8 +682,8 @@ discard block  | 
                                                    ||
| 682 | 682 | |
| 683 | 683 | $sth = $this->db->prepare($query);  | 
                                                        
| 684 | 684 | $sth->execute($query_data);  | 
                                                        
| 685 | - $ident_result='';  | 
                                                        |
| 686 | - while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 685 | + $ident_result = '';  | 
                                                        |
| 686 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 687 | 687 |  		{ | 
                                                        
| 688 | 688 | $ident_result = $row['ident'];  | 
                                                        
| 689 | 689 | }  | 
                                                        
@@ -700,13 +700,13 @@ discard block  | 
                                                    ||
| 700 | 700 |  	{ | 
                                                        
| 701 | 701 | global $globalDBdriver, $globalTimezone;  | 
                                                        
| 702 | 702 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 703 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 703 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 704 | 704 | WHERE marine_live.ident = :ident  | 
                                                        
| 705 | 705 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)';  | 
                                                        
| 706 | 706 | // AND marine_live.date < UTC_TIMESTAMP()";  | 
                                                        
| 707 | 707 |  			$query_data = array(':ident' => $ident); | 
                                                        
| 708 | 708 |  		} else { | 
                                                        
| 709 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 709 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 710 | 710 | WHERE marine_live.ident = :ident  | 
                                                        
| 711 | 711 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";  | 
                                                        
| 712 | 712 | // AND marine_live.date < now() AT TIME ZONE 'UTC'";  | 
                                                        
@@ -715,8 +715,8 @@ discard block  | 
                                                    ||
| 715 | 715 | |
| 716 | 716 | $sth = $this->db->prepare($query);  | 
                                                        
| 717 | 717 | $sth->execute($query_data);  | 
                                                        
| 718 | - $ident_result='';  | 
                                                        |
| 719 | - while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 718 | + $ident_result = '';  | 
                                                        |
| 719 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 720 | 720 |  		{ | 
                                                        
| 721 | 721 | $ident_result = $row['fammarine_id'];  | 
                                                        
| 722 | 722 | }  | 
                                                        
@@ -733,13 +733,13 @@ discard block  | 
                                                    ||
| 733 | 733 |  	{ | 
                                                        
| 734 | 734 | global $globalDBdriver, $globalTimezone;  | 
                                                        
| 735 | 735 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 736 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 736 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 737 | 737 | WHERE marine_live.fammarine_id = :id  | 
                                                        
| 738 | 738 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)';  | 
                                                        
| 739 | 739 | // AND marine_live.date < UTC_TIMESTAMP()";  | 
                                                        
| 740 | 740 |  			$query_data = array(':id' => $id); | 
                                                        
| 741 | 741 |  		} else { | 
                                                        
| 742 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 742 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 743 | 743 | WHERE marine_live.fammarine_id = :id  | 
                                                        
| 744 | 744 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";  | 
                                                        
| 745 | 745 | // AND marine_live.date < now() AT TIME ZONE 'UTC'";  | 
                                                        
@@ -748,8 +748,8 @@ discard block  | 
                                                    ||
| 748 | 748 | |
| 749 | 749 | $sth = $this->db->prepare($query);  | 
                                                        
| 750 | 750 | $sth->execute($query_data);  | 
                                                        
| 751 | - $ident_result='';  | 
                                                        |
| 752 | - while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 751 | + $ident_result = '';  | 
                                                        |
| 752 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 753 | 753 |  		{ | 
                                                        
| 754 | 754 | $ident_result = $row['fammarine_id'];  | 
                                                        
| 755 | 755 | }  | 
                                                        
@@ -766,13 +766,13 @@ discard block  | 
                                                    ||
| 766 | 766 |  	{ | 
                                                        
| 767 | 767 | global $globalDBdriver, $globalTimezone;  | 
                                                        
| 768 | 768 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 769 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 769 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 770 | 770 | WHERE marine_live.mmsi = :mmsi  | 
                                                        
| 771 | 771 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)';  | 
                                                        
| 772 | 772 | // AND marine_live.date < UTC_TIMESTAMP()";  | 
                                                        
| 773 | 773 |  			$query_data = array(':mmsi' => $mmsi); | 
                                                        
| 774 | 774 |  		} else { | 
                                                        
| 775 | - $query = "SELECT marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 775 | + $query = "SELECT marine_live.fammarine_id FROM marine_live  | 
                                                        |
| 776 | 776 | WHERE marine_live.mmsi = :mmsi  | 
                                                        
| 777 | 777 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";  | 
                                                        
| 778 | 778 | // AND marine_live.date < now() AT TIME ZONE 'UTC'";  | 
                                                        
@@ -781,8 +781,8 @@ discard block  | 
                                                    ||
| 781 | 781 | |
| 782 | 782 | $sth = $this->db->prepare($query);  | 
                                                        
| 783 | 783 | $sth->execute($query_data);  | 
                                                        
| 784 | - $ident_result='';  | 
                                                        |
| 785 | - while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 784 | + $ident_result = '';  | 
                                                        |
| 785 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 786 | 786 |  		{ | 
                                                        
| 787 | 787 | $ident_result = $row['fammarine_id'];  | 
                                                        
| 788 | 788 | }  | 
                                                        
@@ -800,7 +800,7 @@ discard block  | 
                                                    ||
| 800 | 800 | * @return String success or false  | 
                                                        
| 801 | 801 | *  | 
                                                        
| 802 | 802 | */  | 
                                                        
| 803 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')  | 
                                                        |
| 803 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')  | 
                                                        |
| 804 | 804 |  	{ | 
                                                        
| 805 | 805 | global $globalURL, $globalArchive, $globalDebug;  | 
                                                        
| 806 | 806 | $Common = new Common();  | 
                                                        
@@ -852,26 +852,26 @@ discard block  | 
                                                    ||
| 852 | 852 |  		if ($date == '') $date = date("Y-m-d H:i:s", time()); | 
                                                        
| 853 | 853 | |
| 854 | 854 | |
| 855 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);  | 
                                                        |
| 856 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING);  | 
                                                        |
| 857 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 858 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 859 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 860 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 861 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING);  | 
                                                        |
| 862 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING);  | 
                                                        |
| 863 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 864 | - $type = filter_var($type,FILTER_SANITIZE_STRING);  | 
                                                        |
| 865 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 866 | - $status = filter_var($status,FILTER_SANITIZE_STRING);  | 
                                                        |
| 867 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING);  | 
                                                        |
| 868 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);  | 
                                                        |
| 869 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);  | 
                                                        |
| 870 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);  | 
                                                        |
| 855 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 856 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 857 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 858 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 859 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 860 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 861 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING);  | 
                                                        |
| 862 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING);  | 
                                                        |
| 863 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING);  | 
                                                        |
| 864 | + $type = filter_var($type, FILTER_SANITIZE_STRING);  | 
                                                        |
| 865 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 866 | + $status = filter_var($status, FILTER_SANITIZE_STRING);  | 
                                                        |
| 867 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING);  | 
                                                        |
| 868 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);  | 
                                                        |
| 869 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);  | 
                                                        |
| 870 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);  | 
                                                        |
| 871 | 871 | |
| 872 | 872 | |
| 873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;  | 
                                                        |
| 874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;  | 
                                                        |
| 873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;  | 
                                                        |
| 874 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;  | 
                                                        |
| 875 | 875 | if ($arrival_date == '') $arrival_date = NULL;  | 
                                                        
| 876 | 876 | $query = '';  | 
                                                        
| 877 | 877 |  		if ($globalArchive) { | 
                                                        
@@ -881,18 +881,18 @@ discard block  | 
                                                    ||
| 881 | 881 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date)  | 
                                                        
| 882 | 882 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';  | 
                                                        
| 883 | 883 | |
| 884 | -		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); | 
                                                        |
| 884 | +		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); | 
                                                        |
| 885 | 885 |  		try { | 
                                                        
| 886 | 886 | $sth = $this->db->prepare($query);  | 
                                                        
| 887 | 887 | $sth->execute($query_values);  | 
                                                        
| 888 | -		} catch(PDOException $e) { | 
                                                        |
| 888 | +		} catch (PDOException $e) { | 
                                                        |
| 889 | 889 | return "error : ".$e->getMessage();  | 
                                                        
| 890 | 890 | }  | 
                                                        
| 891 | 891 | |
| 892 | 892 |  		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { | 
                                                        
| 893 | 893 | if ($globalDebug) echo '(Add to Marine archive : ';  | 
                                                        
| 894 | 894 | $MarineArchive = new MarineArchive($this->db);  | 
                                                        
| 895 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country);  | 
                                                        |
| 895 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country);  | 
                                                        |
| 896 | 896 | if ($globalDebug) echo $result.')';  | 
                                                        
| 897 | 897 | }  | 
                                                        
| 898 | 898 | return "success";  | 
                                                        
@@ -900,7 +900,7 @@ discard block  | 
                                                    ||
| 900 | 900 | |
| 901 | 901 | public function getOrderBy()  | 
                                                        
| 902 | 902 |  	{ | 
                                                        
| 903 | -		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); | 
                                                        |
| 903 | +		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); | 
                                                        |
| 904 | 904 | return $orderby;  | 
                                                        
| 905 | 905 | }  | 
                                                        
| 906 | 906 | |
@@ -29,7 +29,9 @@ discard block  | 
                                                    ||
| 29 | 29 |  		if (isset($filter[0]['source'])) { | 
                                                        
| 30 | 30 | $filters = array_merge($filters,$filter);  | 
                                                        
| 31 | 31 | }  | 
                                                        
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 32 | +		if (is_array($globalFilter)) { | 
                                                        |
| 33 | + $filter = array_merge($filter,$globalFilter);  | 
                                                        |
| 34 | + }  | 
                                                        |
| 33 | 35 | $filter_query_join = '';  | 
                                                        
| 34 | 36 | $filter_query_where = '';  | 
                                                        
| 35 | 37 |  		foreach($filters as $flt) { | 
                                                        
@@ -76,8 +78,11 @@ discard block  | 
                                                    ||
| 76 | 78 |  		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 77 | 79 |  			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        
| 78 | 80 | }  | 
                                                        
| 79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';  | 
                                                        |
| 80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';  | 
                                                        |
| 81 | +		if ($filter_query_where == '' && $where) { | 
                                                        |
| 82 | + $filter_query_where = ' WHERE';  | 
                                                        |
| 83 | +		} elseif ($filter_query_where != '' && $and) { | 
                                                        |
| 84 | + $filter_query_where .= ' AND';  | 
                                                        |
| 85 | + }  | 
                                                        |
| 81 | 86 |  		if ($filter_query_where != '') { | 
                                                        
| 82 | 87 |  			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); | 
                                                        
| 83 | 88 | }  | 
                                                        
@@ -119,7 +124,9 @@ discard block  | 
                                                    ||
| 119 | 124 | }  | 
                                                        
| 120 | 125 | }  | 
                                                        
| 121 | 126 | |
| 122 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 127 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 128 | + $globalLiveInterval = '200';  | 
                                                        |
| 129 | + }  | 
                                                        |
| 123 | 130 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 124 | 131 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";  | 
                                                        
| 125 | 132 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;  | 
                                                        
@@ -144,7 +151,9 @@ discard block  | 
                                                    ||
| 144 | 151 | |
| 145 | 152 | $filter_query = $this->getFilter($filter,true,true);  | 
                                                        
| 146 | 153 | |
| 147 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 154 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 155 | + $globalLiveInterval = '200';  | 
                                                        |
| 156 | + }  | 
                                                        |
| 148 | 157 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 149 | 158 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        
| 150 | 159 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";  | 
                                                        
@@ -178,7 +187,9 @@ discard block  | 
                                                    ||
| 178 | 187 | |
| 179 | 188 | $filter_query = $this->getFilter($filter,true,true);  | 
                                                        
| 180 | 189 | |
| 181 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 190 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 191 | + $globalLiveInterval = '200';  | 
                                                        |
| 192 | + }  | 
                                                        |
| 182 | 193 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 183 | 194 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        
| 184 | 195 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'  | 
                                                        
@@ -211,7 +222,9 @@ discard block  | 
                                                    ||
| 211 | 222 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 212 | 223 | $filter_query = $this->getFilter($filter,true,true);  | 
                                                        
| 213 | 224 | |
| 214 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 225 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 226 | + $globalLiveInterval = '200';  | 
                                                        |
| 227 | + }  | 
                                                        |
| 215 | 228 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 216 | 229 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';  | 
                                                        
| 217 | 230 |  		} else { | 
                                                        
@@ -239,7 +252,9 @@ discard block  | 
                                                    ||
| 239 | 252 |  	{ | 
                                                        
| 240 | 253 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 241 | 254 | $Spotter = new Spotter($this->db);  | 
                                                        
| 242 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 255 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 256 | + $globalLiveInterval = '200';  | 
                                                        |
| 257 | + }  | 
                                                        |
| 243 | 258 | $filter_query = $this->getFilter($filter);  | 
                                                        
| 244 | 259 | |
| 245 | 260 |  		if (is_array($coord)) { | 
                                                        
@@ -247,7 +262,9 @@ discard block  | 
                                                    ||
| 247 | 262 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 248 | 263 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 249 | 264 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 250 | - } else return array();  | 
                                                        |
| 265 | +		} else { | 
                                                        |
| 266 | + return array();  | 
                                                        |
| 267 | + }  | 
                                                        |
| 251 | 268 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 252 | 269 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;  | 
                                                        
| 253 | 270 |  		} else { | 
                                                        
@@ -267,7 +284,9 @@ discard block  | 
                                                    ||
| 267 | 284 |  	{ | 
                                                        
| 268 | 285 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 269 | 286 | $Spotter = new Spotter($this->db);  | 
                                                        
| 270 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 287 | +		if (!isset($globalLiveInterval)) { | 
                                                        |
| 288 | + $globalLiveInterval = '200';  | 
                                                        |
| 289 | + }  | 
                                                        |
| 271 | 290 | $filter_query = $this->getFilter($filter);  | 
                                                        
| 272 | 291 | |
| 273 | 292 |  		if (is_array($coord)) { | 
                                                        
@@ -275,7 +294,9 @@ discard block  | 
                                                    ||
| 275 | 294 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 276 | 295 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 277 | 296 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        
| 278 | - } else return array();  | 
                                                        |
| 297 | +		} else { | 
                                                        |
| 298 | + return array();  | 
                                                        |
| 299 | + }  | 
                                                        |
| 279 | 300 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 280 | 301 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source  | 
                                                        
| 281 | 302 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."  | 
                                                        
@@ -443,11 +464,15 @@ discard block  | 
                                                    ||
| 443 | 464 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';  | 
                                                        
| 444 | 465 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
| 445 | 466 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';  | 
                                                        
| 446 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';  | 
                                                        |
| 467 | +			if ($liveinterval) { | 
                                                        |
| 468 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';  | 
                                                        |
| 469 | + }  | 
                                                        |
| 447 | 470 | $query .= ' ORDER BY date';  | 
                                                        
| 448 | 471 |  		} else { | 
                                                        
| 449 | 472 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';  | 
                                                        
| 450 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";  | 
                                                        |
| 473 | +			if ($liveinterval) { | 
                                                        |
| 474 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";  | 
                                                        |
| 475 | + }  | 
                                                        |
| 451 | 476 | $query .= ' ORDER BY date';  | 
                                                        
| 452 | 477 | }  | 
                                                        
| 453 | 478 | |
@@ -542,7 +567,9 @@ discard block  | 
                                                    ||
| 542 | 567 | $i++;  | 
                                                        
| 543 | 568 | $j++;  | 
                                                        
| 544 | 569 |  				if ($j == 30) { | 
                                                        
| 545 | - if ($globalDebug) echo ".";  | 
                                                        |
| 570 | +					if ($globalDebug) { | 
                                                        |
| 571 | + echo ".";  | 
                                                        |
| 572 | + }  | 
                                                        |
| 546 | 573 |  				    	try { | 
                                                        
| 547 | 574 | |
| 548 | 575 | $sth = $this->db->prepare(substr($query_delete,0,-1).")");  | 
                                                        
@@ -822,7 +849,9 @@ discard block  | 
                                                    ||
| 822 | 849 |  			{ | 
                                                        
| 823 | 850 | return false;  | 
                                                        
| 824 | 851 | }  | 
                                                        
| 825 | - } else return '';  | 
                                                        |
| 852 | +		} else { | 
                                                        |
| 853 | + return '';  | 
                                                        |
| 854 | + }  | 
                                                        |
| 826 | 855 | |
| 827 | 856 | if ($longitude != '')  | 
                                                        
| 828 | 857 |  		{ | 
                                                        
@@ -830,7 +859,9 @@ discard block  | 
                                                    ||
| 830 | 859 |  			{ | 
                                                        
| 831 | 860 | return false;  | 
                                                        
| 832 | 861 | }  | 
                                                        
| 833 | - } else return '';  | 
                                                        |
| 862 | +		} else { | 
                                                        |
| 863 | + return '';  | 
                                                        |
| 864 | + }  | 
                                                        |
| 834 | 865 | |
| 835 | 866 | |
| 836 | 867 | if ($heading != '')  | 
                                                        
@@ -839,7 +870,9 @@ discard block  | 
                                                    ||
| 839 | 870 |  			{ | 
                                                        
| 840 | 871 | return false;  | 
                                                        
| 841 | 872 | }  | 
                                                        
| 842 | - } else $heading = 0;  | 
                                                        |
| 873 | +		} else { | 
                                                        |
| 874 | + $heading = 0;  | 
                                                        |
| 875 | + }  | 
                                                        |
| 843 | 876 | |
| 844 | 877 | if ($groundspeed != '')  | 
                                                        
| 845 | 878 |  		{ | 
                                                        
@@ -847,9 +880,13 @@ discard block  | 
                                                    ||
| 847 | 880 |  			{ | 
                                                        
| 848 | 881 | return false;  | 
                                                        
| 849 | 882 | }  | 
                                                        
| 850 | - } else $groundspeed = 0;  | 
                                                        |
| 883 | +		} else { | 
                                                        |
| 884 | + $groundspeed = 0;  | 
                                                        |
| 885 | + }  | 
                                                        |
| 851 | 886 |  		date_default_timezone_set('UTC'); | 
                                                        
| 852 | -		if ($date == '') $date = date("Y-m-d H:i:s", time()); | 
                                                        |
| 887 | +		if ($date == '') { | 
                                                        |
| 888 | +			$date = date("Y-m-d H:i:s", time()); | 
                                                        |
| 889 | + }  | 
                                                        |
| 853 | 890 | |
| 854 | 891 | |
| 855 | 892 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);  | 
                                                        
@@ -870,12 +907,20 @@ discard block  | 
                                                    ||
| 870 | 907 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);  | 
                                                        
| 871 | 908 | |
| 872 | 909 | |
| 873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;  | 
                                                        |
| 874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;  | 
                                                        |
| 875 | - if ($arrival_date == '') $arrival_date = NULL;  | 
                                                        |
| 910 | +            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { | 
                                                        |
| 911 | + $groundspeed = 0;  | 
                                                        |
| 912 | + }  | 
                                                        |
| 913 | +            	if ($heading == '' || $Common->isInteger($heading) === false ) { | 
                                                        |
| 914 | + $heading = 0;  | 
                                                        |
| 915 | + }  | 
                                                        |
| 916 | +            	if ($arrival_date == '') { | 
                                                        |
| 917 | + $arrival_date = NULL;  | 
                                                        |
| 918 | + }  | 
                                                        |
| 876 | 919 | $query = '';  | 
                                                        
| 877 | 920 |  		if ($globalArchive) { | 
                                                        
| 878 | - if ($globalDebug) echo '-- Delete previous data -- ';  | 
                                                        |
| 921 | +			if ($globalDebug) { | 
                                                        |
| 922 | + echo '-- Delete previous data -- ';  | 
                                                        |
| 923 | + }  | 
                                                        |
| 879 | 924 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';  | 
                                                        
| 880 | 925 | }  | 
                                                        
| 881 | 926 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date)  | 
                                                        
@@ -890,10 +935,14 @@ discard block  | 
                                                    ||
| 890 | 935 | }  | 
                                                        
| 891 | 936 | |
| 892 | 937 |  		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { | 
                                                        
| 893 | - if ($globalDebug) echo '(Add to Marine archive : ';  | 
                                                        |
| 938 | +			if ($globalDebug) { | 
                                                        |
| 939 | + echo '(Add to Marine archive : ';  | 
                                                        |
| 940 | + }  | 
                                                        |
| 894 | 941 | $MarineArchive = new MarineArchive($this->db);  | 
                                                        
| 895 | 942 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country);  | 
                                                        
| 896 | - if ($globalDebug) echo $result.')';  | 
                                                        |
| 943 | +			if ($globalDebug) { | 
                                                        |
| 944 | + echo $result.')';  | 
                                                        |
| 945 | + }  | 
                                                        |
| 897 | 946 | }  | 
                                                        
| 898 | 947 | return "success";  | 
                                                        
| 899 | 948 | }  | 
                                                        
@@ -8,11 +8,11 @@ discard block  | 
                                                    ||
| 8 | 8 | $this->db = $Connection->db;  | 
                                                        
| 9 | 9 | }  | 
                                                        
| 10 | 10 | |
| 11 | - /**  | 
                                                        |
| 12 | - * Get SQL query part for filter used  | 
                                                        |
| 13 | - * @param Array $filter the filter  | 
                                                        |
| 14 | - * @return Array the SQL part  | 
                                                        |
| 15 | - */  | 
                                                        |
| 11 | + /**  | 
                                                        |
| 12 | + * Get SQL query part for filter used  | 
                                                        |
| 13 | + * @param Array $filter the filter  | 
                                                        |
| 14 | + * @return Array the SQL part  | 
                                                        |
| 15 | + */  | 
                                                        |
| 16 | 16 | /*  | 
                                                        
| 17 | 17 |      public function getFilter($filter = array(),$where = false,$and = false) { | 
                                                        
| 18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;  | 
                                                        
@@ -122,44 +122,44 @@ discard block  | 
                                                    ||
| 122 | 122 | }  | 
                                                        
| 123 | 123 | |
| 124 | 124 | |
| 125 | - /**  | 
                                                        |
| 126 | - * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 127 | - *  | 
                                                        |
| 128 | - * @return Array the spotter information  | 
                                                        |
| 129 | - *  | 
                                                        |
| 130 | - */  | 
                                                        |
| 131 | - public function getLastArchiveMarineDataByIdent($ident)  | 
                                                        |
| 132 | -        { | 
                                                        |
| 125 | + /**  | 
                                                        |
| 126 | + * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 127 | + *  | 
                                                        |
| 128 | + * @return Array the spotter information  | 
                                                        |
| 129 | + *  | 
                                                        |
| 130 | + */  | 
                                                        |
| 131 | + public function getLastArchiveMarineDataByIdent($ident)  | 
                                                        |
| 132 | +		{ | 
                                                        |
| 133 | 133 | $Marine = new Marine($this->db);  | 
                                                        
| 134 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 134 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 135 | 135 | |
| 136 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 137 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 138 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 136 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 137 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 138 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 139 | 139 | |
| 140 | -                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); | 
                                                        |
| 140 | +				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); | 
                                                        |
| 141 | 141 | |
| 142 | - return $spotter_array;  | 
                                                        |
| 143 | - }  | 
                                                        |
| 142 | + return $spotter_array;  | 
                                                        |
| 143 | + }  | 
                                                        |
| 144 | 144 | |
| 145 | 145 | |
| 146 | - /**  | 
                                                        |
| 147 | - * Gets last the spotter information based on a particular id  | 
                                                        |
| 148 | - *  | 
                                                        |
| 149 | - * @return Array the spotter information  | 
                                                        |
| 150 | - *  | 
                                                        |
| 151 | - */  | 
                                                        |
| 152 | - public function getLastArchiveMarineDataById($id)  | 
                                                        |
| 153 | -        { | 
                                                        |
| 154 | - $Marine = new Marine($this->db);  | 
                                                        |
| 155 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 156 | - $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 157 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 158 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 159 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 146 | + /**  | 
                                                        |
| 147 | + * Gets last the spotter information based on a particular id  | 
                                                        |
| 148 | + *  | 
                                                        |
| 149 | + * @return Array the spotter information  | 
                                                        |
| 150 | + *  | 
                                                        |
| 151 | + */  | 
                                                        |
| 152 | + public function getLastArchiveMarineDataById($id)  | 
                                                        |
| 153 | +		{ | 
                                                        |
| 154 | + $Marine = new Marine($this->db);  | 
                                                        |
| 155 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 156 | + $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 157 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 158 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 159 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 160 | 160 | |
| 161 | 161 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 162 | - /*  | 
                                                        |
| 162 | + /*  | 
                                                        |
| 163 | 163 |                  try { | 
                                                        
| 164 | 164 | $Connection = new Connection();  | 
                                                        
| 165 | 165 | $sth = Connection->$db->prepare($query);  | 
                                                        
@@ -169,232 +169,232 @@ discard block  | 
                                                    ||
| 169 | 169 | }  | 
                                                        
| 170 | 170 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);  | 
                                                        
| 171 | 171 | */  | 
                                                        
| 172 | -                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        |
| 173 | -  | 
                                                        |
| 174 | - return $spotter_array;  | 
                                                        |
| 175 | - }  | 
                                                        |
| 176 | -  | 
                                                        |
| 177 | - /**  | 
                                                        |
| 178 | - * Gets all the spotter information based on a particular id  | 
                                                        |
| 179 | - *  | 
                                                        |
| 180 | - * @return Array the spotter information  | 
                                                        |
| 181 | - *  | 
                                                        |
| 182 | - */  | 
                                                        |
| 183 | - public function getAllArchiveMarineDataById($id)  | 
                                                        |
| 172 | +				$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        |
| 173 | +  | 
                                                        |
| 174 | + return $spotter_array;  | 
                                                        |
| 175 | + }  | 
                                                        |
| 176 | +  | 
                                                        |
| 177 | + /**  | 
                                                        |
| 178 | + * Gets all the spotter information based on a particular id  | 
                                                        |
| 179 | + *  | 
                                                        |
| 180 | + * @return Array the spotter information  | 
                                                        |
| 181 | + *  | 
                                                        |
| 182 | + */  | 
                                                        |
| 183 | + public function getAllArchiveMarineDataById($id)  | 
                                                        |
| 184 | 184 |  	{ | 
                                                        
| 185 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 186 | - $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 187 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 185 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 186 | + $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 187 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 188 | 188 | |
| 189 | 189 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 190 | 190 | |
| 191 | -                try { | 
                                                        |
| 192 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 193 | -                        $sth->execute(array(':id' => $id)); | 
                                                        |
| 194 | -                } catch(PDOException $e) { | 
                                                        |
| 195 | - echo $e->getMessage();  | 
                                                        |
| 196 | - die;  | 
                                                        |
| 197 | - }  | 
                                                        |
| 198 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 199 | -  | 
                                                        |
| 200 | - return $spotter_array;  | 
                                                        |
| 201 | - }  | 
                                                        |
| 202 | -  | 
                                                        |
| 203 | - /**  | 
                                                        |
| 204 | - * Gets coordinate & time spotter information based on a particular id  | 
                                                        |
| 205 | - *  | 
                                                        |
| 206 | - * @return Array the spotter information  | 
                                                        |
| 207 | - *  | 
                                                        |
| 208 | - */  | 
                                                        |
| 209 | - public function getCoordArchiveMarineDataById($id)  | 
                                                        |
| 210 | -        { | 
                                                        |
| 211 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 212 | - $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 213 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 191 | +				try { | 
                                                        |
| 192 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 193 | +						$sth->execute(array(':id' => $id)); | 
                                                        |
| 194 | +				} catch(PDOException $e) { | 
                                                        |
| 195 | + echo $e->getMessage();  | 
                                                        |
| 196 | + die;  | 
                                                        |
| 197 | + }  | 
                                                        |
| 198 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 199 | +  | 
                                                        |
| 200 | + return $spotter_array;  | 
                                                        |
| 201 | + }  | 
                                                        |
| 202 | +  | 
                                                        |
| 203 | + /**  | 
                                                        |
| 204 | + * Gets coordinate & time spotter information based on a particular id  | 
                                                        |
| 205 | + *  | 
                                                        |
| 206 | + * @return Array the spotter information  | 
                                                        |
| 207 | + *  | 
                                                        |
| 208 | + */  | 
                                                        |
| 209 | + public function getCoordArchiveMarineDataById($id)  | 
                                                        |
| 210 | +		{ | 
                                                        |
| 211 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 212 | + $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 213 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 214 | 214 | |
| 215 | 215 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 216 | 216 | |
| 217 | -                try { | 
                                                        |
| 218 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 219 | -                        $sth->execute(array(':id' => $id)); | 
                                                        |
| 220 | -                } catch(PDOException $e) { | 
                                                        |
| 221 | - echo $e->getMessage();  | 
                                                        |
| 222 | - die;  | 
                                                        |
| 223 | - }  | 
                                                        |
| 224 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 217 | +				try { | 
                                                        |
| 218 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 219 | +						$sth->execute(array(':id' => $id)); | 
                                                        |
| 220 | +				} catch(PDOException $e) { | 
                                                        |
| 221 | + echo $e->getMessage();  | 
                                                        |
| 222 | + die;  | 
                                                        |
| 223 | + }  | 
                                                        |
| 224 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 225 | 225 | |
| 226 | - return $spotter_array;  | 
                                                        |
| 227 | - }  | 
                                                        |
| 226 | + return $spotter_array;  | 
                                                        |
| 227 | + }  | 
                                                        |
| 228 | 228 | |
| 229 | 229 | |
| 230 | - /**  | 
                                                        |
| 231 | - * Gets altitude information based on a particular callsign  | 
                                                        |
| 232 | - *  | 
                                                        |
| 233 | - * @return Array the spotter information  | 
                                                        |
| 234 | - *  | 
                                                        |
| 235 | - */  | 
                                                        |
| 236 | - public function getAltitudeArchiveMarineDataByIdent($ident)  | 
                                                        |
| 237 | -        { | 
                                                        |
| 230 | + /**  | 
                                                        |
| 231 | + * Gets altitude information based on a particular callsign  | 
                                                        |
| 232 | + *  | 
                                                        |
| 233 | + * @return Array the spotter information  | 
                                                        |
| 234 | + *  | 
                                                        |
| 235 | + */  | 
                                                        |
| 236 | + public function getAltitudeArchiveMarineDataByIdent($ident)  | 
                                                        |
| 237 | +		{ | 
                                                        |
| 238 | 238 | |
| 239 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 239 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 240 | 240 | |
| 241 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 242 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 241 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 242 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 243 | 243 | |
| 244 | -                try { | 
                                                        |
| 245 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 246 | -                        $sth->execute(array(':ident' => $ident)); | 
                                                        |
| 247 | -                } catch(PDOException $e) { | 
                                                        |
| 248 | - echo $e->getMessage();  | 
                                                        |
| 249 | - die;  | 
                                                        |
| 250 | - }  | 
                                                        |
| 251 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 244 | +				try { | 
                                                        |
| 245 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 246 | +						$sth->execute(array(':ident' => $ident)); | 
                                                        |
| 247 | +				} catch(PDOException $e) { | 
                                                        |
| 248 | + echo $e->getMessage();  | 
                                                        |
| 249 | + die;  | 
                                                        |
| 250 | + }  | 
                                                        |
| 251 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 252 | 252 | |
| 253 | - return $spotter_array;  | 
                                                        |
| 254 | - }  | 
                                                        |
| 253 | + return $spotter_array;  | 
                                                        |
| 254 | + }  | 
                                                        |
| 255 | 255 | |
| 256 | - /**  | 
                                                        |
| 257 | - * Gets altitude information based on a particular id  | 
                                                        |
| 258 | - *  | 
                                                        |
| 259 | - * @return Array the spotter information  | 
                                                        |
| 260 | - *  | 
                                                        |
| 261 | - */  | 
                                                        |
| 262 | - public function getAltitudeArchiveMarineDataById($id)  | 
                                                        |
| 263 | -        { | 
                                                        |
| 256 | + /**  | 
                                                        |
| 257 | + * Gets altitude information based on a particular id  | 
                                                        |
| 258 | + *  | 
                                                        |
| 259 | + * @return Array the spotter information  | 
                                                        |
| 260 | + *  | 
                                                        |
| 261 | + */  | 
                                                        |
| 262 | + public function getAltitudeArchiveMarineDataById($id)  | 
                                                        |
| 263 | +		{ | 
                                                        |
| 264 | 264 | |
| 265 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 265 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 266 | 266 | |
| 267 | - $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 268 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 267 | + $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 268 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 269 | 269 | |
| 270 | -                try { | 
                                                        |
| 271 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 272 | -                        $sth->execute(array(':id' => $id)); | 
                                                        |
| 273 | -                } catch(PDOException $e) { | 
                                                        |
| 274 | - echo $e->getMessage();  | 
                                                        |
| 275 | - die;  | 
                                                        |
| 276 | - }  | 
                                                        |
| 277 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 270 | +				try { | 
                                                        |
| 271 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 272 | +						$sth->execute(array(':id' => $id)); | 
                                                        |
| 273 | +				} catch(PDOException $e) { | 
                                                        |
| 274 | + echo $e->getMessage();  | 
                                                        |
| 275 | + die;  | 
                                                        |
| 276 | + }  | 
                                                        |
| 277 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 278 | 278 | |
| 279 | - return $spotter_array;  | 
                                                        |
| 280 | - }  | 
                                                        |
| 279 | + return $spotter_array;  | 
                                                        |
| 280 | + }  | 
                                                        |
| 281 | 281 | |
| 282 | - /**  | 
                                                        |
| 283 | - * Gets altitude & speed information based on a particular id  | 
                                                        |
| 284 | - *  | 
                                                        |
| 285 | - * @return Array the spotter information  | 
                                                        |
| 286 | - *  | 
                                                        |
| 287 | - */  | 
                                                        |
| 288 | - public function getAltitudeSpeedArchiveMarineDataById($id)  | 
                                                        |
| 289 | -        { | 
                                                        |
| 282 | + /**  | 
                                                        |
| 283 | + * Gets altitude & speed information based on a particular id  | 
                                                        |
| 284 | + *  | 
                                                        |
| 285 | + * @return Array the spotter information  | 
                                                        |
| 286 | + *  | 
                                                        |
| 287 | + */  | 
                                                        |
| 288 | + public function getAltitudeSpeedArchiveMarineDataById($id)  | 
                                                        |
| 289 | +		{ | 
                                                        |
| 290 | 290 | |
| 291 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 291 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 292 | 292 | |
| 293 | - $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 294 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 293 | + $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        |
| 294 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 295 | 295 | |
| 296 | -                try { | 
                                                        |
| 297 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 298 | -                        $sth->execute(array(':id' => $id)); | 
                                                        |
| 299 | -                } catch(PDOException $e) { | 
                                                        |
| 300 | - echo $e->getMessage();  | 
                                                        |
| 301 | - die;  | 
                                                        |
| 302 | - }  | 
                                                        |
| 303 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 296 | +				try { | 
                                                        |
| 297 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 298 | +						$sth->execute(array(':id' => $id)); | 
                                                        |
| 299 | +				} catch(PDOException $e) { | 
                                                        |
| 300 | + echo $e->getMessage();  | 
                                                        |
| 301 | + die;  | 
                                                        |
| 302 | + }  | 
                                                        |
| 303 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 304 | 304 | |
| 305 | - return $spotter_array;  | 
                                                        |
| 306 | - }  | 
                                                        |
| 305 | + return $spotter_array;  | 
                                                        |
| 306 | + }  | 
                                                        |
| 307 | 307 | |
| 308 | 308 | |
| 309 | - /**  | 
                                                        |
| 310 | - * Gets altitude information based on a particular callsign  | 
                                                        |
| 311 | - *  | 
                                                        |
| 312 | - * @return Array the spotter information  | 
                                                        |
| 313 | - *  | 
                                                        |
| 314 | - */  | 
                                                        |
| 315 | - public function getLastAltitudeArchiveMarineDataByIdent($ident)  | 
                                                        |
| 316 | -        { | 
                                                        |
| 309 | + /**  | 
                                                        |
| 310 | + * Gets altitude information based on a particular callsign  | 
                                                        |
| 311 | + *  | 
                                                        |
| 312 | + * @return Array the spotter information  | 
                                                        |
| 313 | + *  | 
                                                        |
| 314 | + */  | 
                                                        |
| 315 | + public function getLastAltitudeArchiveMarineDataByIdent($ident)  | 
                                                        |
| 316 | +		{ | 
                                                        |
| 317 | 317 | |
| 318 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 318 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 319 | 319 | |
| 320 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 321 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 320 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 321 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 322 | 322 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";  | 
                                                        
| 323 | 323 | |
| 324 | -                try { | 
                                                        |
| 325 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 326 | -                        $sth->execute(array(':ident' => $ident)); | 
                                                        |
| 327 | -                } catch(PDOException $e) { | 
                                                        |
| 328 | - echo $e->getMessage();  | 
                                                        |
| 329 | - die;  | 
                                                        |
| 330 | - }  | 
                                                        |
| 331 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 324 | +				try { | 
                                                        |
| 325 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 326 | +						$sth->execute(array(':ident' => $ident)); | 
                                                        |
| 327 | +				} catch(PDOException $e) { | 
                                                        |
| 328 | + echo $e->getMessage();  | 
                                                        |
| 329 | + die;  | 
                                                        |
| 330 | + }  | 
                                                        |
| 331 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 332 | 332 | |
| 333 | - return $spotter_array;  | 
                                                        |
| 334 | - }  | 
                                                        |
| 333 | + return $spotter_array;  | 
                                                        |
| 334 | + }  | 
                                                        |
| 335 | 335 | |
| 336 | 336 | |
| 337 | 337 | |
| 338 | - /**  | 
                                                        |
| 339 | - * Gets all the archive spotter information  | 
                                                        |
| 340 | - *  | 
                                                        |
| 341 | - * @return Array the spotter information  | 
                                                        |
| 342 | - *  | 
                                                        |
| 343 | - */  | 
                                                        |
| 344 | - public function getMarineArchiveData($ident,$fammarine_id,$date)  | 
                                                        |
| 345 | -        { | 
                                                        |
| 346 | - $Marine = new Marine($this->db);  | 
                                                        |
| 347 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 348 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";  | 
                                                        |
| 338 | + /**  | 
                                                        |
| 339 | + * Gets all the archive spotter information  | 
                                                        |
| 340 | + *  | 
                                                        |
| 341 | + * @return Array the spotter information  | 
                                                        |
| 342 | + *  | 
                                                        |
| 343 | + */  | 
                                                        |
| 344 | + public function getMarineArchiveData($ident,$fammarine_id,$date)  | 
                                                        |
| 345 | +		{ | 
                                                        |
| 346 | + $Marine = new Marine($this->db);  | 
                                                        |
| 347 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        |
| 348 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";  | 
                                                        |
| 349 | 349 | |
| 350 | -                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); | 
                                                        |
| 350 | +				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); | 
                                                        |
| 351 | 351 | |
| 352 | - return $spotter_array;  | 
                                                        |
| 353 | - }  | 
                                                        |
| 352 | + return $spotter_array;  | 
                                                        |
| 353 | + }  | 
                                                        |
| 354 | 354 | |
| 355 | - public function deleteMarineArchiveTrackData()  | 
                                                        |
| 356 | -        { | 
                                                        |
| 355 | + public function deleteMarineArchiveTrackData()  | 
                                                        |
| 356 | +		{ | 
                                                        |
| 357 | 357 | global $globalArchiveKeepTrackMonths;  | 
                                                        
| 358 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 358 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 359 | 359 | $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';  | 
                                                        
| 360 | -                try { | 
                                                        |
| 361 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 362 | - $sth->execute();  | 
                                                        |
| 363 | -                } catch(PDOException $e) { | 
                                                        |
| 364 | - echo $e->getMessage();  | 
                                                        |
| 365 | - die;  | 
                                                        |
| 366 | - }  | 
                                                        |
| 360 | +				try { | 
                                                        |
| 361 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 362 | + $sth->execute();  | 
                                                        |
| 363 | +				} catch(PDOException $e) { | 
                                                        |
| 364 | + echo $e->getMessage();  | 
                                                        |
| 365 | + die;  | 
                                                        |
| 366 | + }  | 
                                                        |
| 367 | 367 | }  | 
                                                        
| 368 | 368 | |
| 369 | 369 | /**  | 
                                                        
| 370 | - * Gets Minimal Live Marine data  | 
                                                        |
| 371 | - *  | 
                                                        |
| 372 | - * @return Array the spotter information  | 
                                                        |
| 373 | - *  | 
                                                        |
| 374 | - */  | 
                                                        |
| 375 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array())  | 
                                                        |
| 376 | -        { | 
                                                        |
| 377 | - global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 378 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 379 | -  | 
                                                        |
| 380 | - $filter_query = '';  | 
                                                        |
| 381 | -                if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 382 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 383 | - }  | 
                                                        |
| 384 | - // Use spotter_output also ?  | 
                                                        |
| 385 | -                if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 386 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 387 | - }  | 
                                                        |
| 388 | -                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 389 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 390 | - }  | 
                                                        |
| 391 | -                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 392 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 393 | - }  | 
                                                        |
| 394 | -  | 
                                                        |
| 395 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 396 | -                if ($globalDBdriver == 'mysql') { | 
                                                        |
| 397 | - /*  | 
                                                        |
| 370 | + * Gets Minimal Live Marine data  | 
                                                        |
| 371 | + *  | 
                                                        |
| 372 | + * @return Array the spotter information  | 
                                                        |
| 373 | + *  | 
                                                        |
| 374 | + */  | 
                                                        |
| 375 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array())  | 
                                                        |
| 376 | +		{ | 
                                                        |
| 377 | + global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 378 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 379 | +  | 
                                                        |
| 380 | + $filter_query = '';  | 
                                                        |
| 381 | +				if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 382 | +						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 383 | + }  | 
                                                        |
| 384 | + // Use spotter_output also ?  | 
                                                        |
| 385 | +				if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 386 | +						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 387 | + }  | 
                                                        |
| 388 | +				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 389 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 390 | + }  | 
                                                        |
| 391 | +				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 392 | +						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 393 | + }  | 
                                                        |
| 394 | +  | 
                                                        |
| 395 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 396 | +				if ($globalDBdriver == 'mysql') { | 
                                                        |
| 397 | + /*  | 
                                                        |
| 398 | 398 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk  | 
                                                        
| 399 | 399 | FROM marine_archive  | 
                                                        
| 400 | 400 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';  | 
                                                        
@@ -413,56 +413,56 @@ discard block  | 
                                                    ||
| 413 | 413 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao  | 
                                                        
| 414 | 414 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".'  | 
                                                        
| 415 | 415 | '.$filter_query.' ORDER BY fammarine_id';  | 
                                                        
| 416 | -                } else { | 
                                                        |
| 417 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';  | 
                                                        |
| 418 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 416 | +				} else { | 
                                                        |
| 417 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';  | 
                                                        |
| 418 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 419 | 419 | FROM marine_archive  | 
                                                        
| 420 | 420 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao  | 
                                                        
| 421 | 421 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'  | 
                                                        
| 422 | 422 | '.$filter_query.' ORDER BY fammarine_id';  | 
                                                        
| 423 | - }  | 
                                                        |
| 424 | - //echo $query;  | 
                                                        |
| 425 | -                try { | 
                                                        |
| 426 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 427 | - $sth->execute();  | 
                                                        |
| 428 | -                } catch(PDOException $e) { | 
                                                        |
| 429 | - echo $e->getMessage();  | 
                                                        |
| 430 | - die;  | 
                                                        |
| 431 | - }  | 
                                                        |
| 432 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 433 | -  | 
                                                        |
| 434 | - return $spotter_array;  | 
                                                        |
| 435 | - }  | 
                                                        |
| 423 | + }  | 
                                                        |
| 424 | + //echo $query;  | 
                                                        |
| 425 | +				try { | 
                                                        |
| 426 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 427 | + $sth->execute();  | 
                                                        |
| 428 | +				} catch(PDOException $e) { | 
                                                        |
| 429 | + echo $e->getMessage();  | 
                                                        |
| 430 | + die;  | 
                                                        |
| 431 | + }  | 
                                                        |
| 432 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 433 | +  | 
                                                        |
| 434 | + return $spotter_array;  | 
                                                        |
| 435 | + }  | 
                                                        |
| 436 | 436 | |
| 437 | 437 | /**  | 
                                                        
| 438 | - * Gets Minimal Live Marine data  | 
                                                        |
| 439 | - *  | 
                                                        |
| 440 | - * @return Array the spotter information  | 
                                                        |
| 441 | - *  | 
                                                        |
| 442 | - */  | 
                                                        |
| 443 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())  | 
                                                        |
| 444 | -        { | 
                                                        |
| 445 | - global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 446 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 447 | -  | 
                                                        |
| 448 | - $filter_query = '';  | 
                                                        |
| 449 | -                if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 450 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 451 | - }  | 
                                                        |
| 452 | - // Should use spotter_output also ?  | 
                                                        |
| 453 | -                if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 454 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 455 | - }  | 
                                                        |
| 456 | -                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 457 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 458 | - }  | 
                                                        |
| 459 | -                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 460 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 461 | - }  | 
                                                        |
| 462 | -  | 
                                                        |
| 463 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 464 | -                if ($globalDBdriver == 'mysql') { | 
                                                        |
| 465 | - /*  | 
                                                        |
| 438 | + * Gets Minimal Live Marine data  | 
                                                        |
| 439 | + *  | 
                                                        |
| 440 | + * @return Array the spotter information  | 
                                                        |
| 441 | + *  | 
                                                        |
| 442 | + */  | 
                                                        |
| 443 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())  | 
                                                        |
| 444 | +		{ | 
                                                        |
| 445 | + global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 446 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 447 | +  | 
                                                        |
| 448 | + $filter_query = '';  | 
                                                        |
| 449 | +				if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 450 | +						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 451 | + }  | 
                                                        |
| 452 | + // Should use spotter_output also ?  | 
                                                        |
| 453 | +				if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 454 | +						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 455 | + }  | 
                                                        |
| 456 | +				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 457 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 458 | + }  | 
                                                        |
| 459 | +				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 460 | +						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 461 | + }  | 
                                                        |
| 462 | +  | 
                                                        |
| 463 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 464 | +				if ($globalDBdriver == 'mysql') { | 
                                                        |
| 465 | + /*  | 
                                                        |
| 466 | 466 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk  | 
                                                        
| 467 | 467 | FROM marine_archive  | 
                                                        
| 468 | 468 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';  | 
                                                        
@@ -473,95 +473,95 @@ discard block  | 
                                                    ||
| 473 | 473 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".')  | 
                                                        
| 474 | 474 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';  | 
                                                        
| 475 | 475 | |
| 476 | -                } else { | 
                                                        |
| 477 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';  | 
                                                        |
| 478 | - /*  | 
                                                        |
| 476 | +				} else { | 
                                                        |
| 477 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';  | 
                                                        |
| 478 | + /*  | 
                                                        |
| 479 | 479 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow  | 
                                                        
| 480 | 480 | FROM marine_archive_output  | 
                                                        
| 481 | 481 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao  | 
                                                        
| 482 | 482 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'  | 
                                                        
| 483 | 483 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';  | 
                                                        
| 484 | 484 | */  | 
                                                        
| 485 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow  | 
                                                        |
| 485 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow  | 
                                                        |
| 486 | 486 | FROM marine_archive_output  | 
                                                        
| 487 | 487 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao  | 
                                                        
| 488 | 488 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'  | 
                                                        
| 489 | 489 | '.$filter_query.' LIMIT 200 OFFSET 0';  | 
                                                        
| 490 | 490 | // .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';  | 
                                                        
| 491 | 491 | |
| 492 | - }  | 
                                                        |
| 493 | - //echo $query;  | 
                                                        |
| 494 | -                try { | 
                                                        |
| 495 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 496 | - $sth->execute();  | 
                                                        |
| 497 | -                } catch(PDOException $e) { | 
                                                        |
| 498 | - echo $e->getMessage();  | 
                                                        |
| 499 | - die;  | 
                                                        |
| 500 | - }  | 
                                                        |
| 501 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 502 | -  | 
                                                        |
| 503 | - return $spotter_array;  | 
                                                        |
| 504 | - }  | 
                                                        |
| 492 | + }  | 
                                                        |
| 493 | + //echo $query;  | 
                                                        |
| 494 | +				try { | 
                                                        |
| 495 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 496 | + $sth->execute();  | 
                                                        |
| 497 | +				} catch(PDOException $e) { | 
                                                        |
| 498 | + echo $e->getMessage();  | 
                                                        |
| 499 | + die;  | 
                                                        |
| 500 | + }  | 
                                                        |
| 501 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);  | 
                                                        |
| 502 | +  | 
                                                        |
| 503 | + return $spotter_array;  | 
                                                        |
| 504 | + }  | 
                                                        |
| 505 | 505 | |
| 506 | 506 | /**  | 
                                                        
| 507 | - * Gets count Live Marine data  | 
                                                        |
| 508 | - *  | 
                                                        |
| 509 | - * @return Array the spotter information  | 
                                                        |
| 510 | - *  | 
                                                        |
| 511 | - */  | 
                                                        |
| 512 | - public function getLiveMarineCount($begindate,$enddate,$filter = array())  | 
                                                        |
| 513 | -        { | 
                                                        |
| 514 | - global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 515 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 516 | -  | 
                                                        |
| 517 | - $filter_query = '';  | 
                                                        |
| 518 | -                if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 519 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 520 | - }  | 
                                                        |
| 521 | -                if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 522 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 523 | - }  | 
                                                        |
| 524 | -                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 525 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 526 | - }  | 
                                                        |
| 527 | -                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 528 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 529 | - }  | 
                                                        |
| 530 | -  | 
                                                        |
| 531 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 532 | -                if ($globalDBdriver == 'mysql') { | 
                                                        |
| 507 | + * Gets count Live Marine data  | 
                                                        |
| 508 | + *  | 
                                                        |
| 509 | + * @return Array the spotter information  | 
                                                        |
| 510 | + *  | 
                                                        |
| 511 | + */  | 
                                                        |
| 512 | + public function getLiveMarineCount($begindate,$enddate,$filter = array())  | 
                                                        |
| 513 | +		{ | 
                                                        |
| 514 | + global $globalDBdriver, $globalLiveInterval;  | 
                                                        |
| 515 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 516 | +  | 
                                                        |
| 517 | + $filter_query = '';  | 
                                                        |
| 518 | +				if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        |
| 519 | +						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 520 | + }  | 
                                                        |
| 521 | +				if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        |
| 522 | +						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 523 | + }  | 
                                                        |
| 524 | +				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        |
| 525 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        |
| 526 | + }  | 
                                                        |
| 527 | +				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        |
| 528 | +						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 529 | + }  | 
                                                        |
| 530 | +  | 
                                                        |
| 531 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        |
| 532 | +				if ($globalDBdriver == 'mysql') { | 
                                                        |
| 533 | 533 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb  | 
                                                        
| 534 | 534 | FROM marine_archive l  | 
                                                        
| 535 | 535 |  			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; | 
                                                        
| 536 | -                } else { | 
                                                        |
| 536 | +				} else { | 
                                                        |
| 537 | 537 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;  | 
                                                        
| 538 | - }  | 
                                                        |
| 539 | - //echo $query;  | 
                                                        |
| 540 | -                try { | 
                                                        |
| 541 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 542 | - $sth->execute();  | 
                                                        |
| 543 | -                } catch(PDOException $e) { | 
                                                        |
| 544 | - echo $e->getMessage();  | 
                                                        |
| 545 | - die;  | 
                                                        |
| 546 | - }  | 
                                                        |
| 538 | + }  | 
                                                        |
| 539 | + //echo $query;  | 
                                                        |
| 540 | +				try { | 
                                                        |
| 541 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 542 | + $sth->execute();  | 
                                                        |
| 543 | +				} catch(PDOException $e) { | 
                                                        |
| 544 | + echo $e->getMessage();  | 
                                                        |
| 545 | + die;  | 
                                                        |
| 546 | + }  | 
                                                        |
| 547 | 547 | $result = $sth->fetch(PDO::FETCH_ASSOC);  | 
                                                        
| 548 | 548 | $sth->closeCursor();  | 
                                                        
| 549 | - return $result['nb'];  | 
                                                        |
| 549 | + return $result['nb'];  | 
                                                        |
| 550 | 550 | |
| 551 | - }  | 
                                                        |
| 551 | + }  | 
                                                        |
| 552 | 552 | |
| 553 | 553 | |
| 554 | 554 | |
| 555 | 555 | // marine_archive_output  | 
                                                        
| 556 | 556 | |
| 557 | - /**  | 
                                                        |
| 558 | - * Gets all the spotter information  | 
                                                        |
| 559 | - *  | 
                                                        |
| 560 | - * @return Array the spotter information  | 
                                                        |
| 561 | - *  | 
                                                        |
| 562 | - */  | 
                                                        |
| 563 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())  | 
                                                        |
| 564 | -    { | 
                                                        |
| 557 | + /**  | 
                                                        |
| 558 | + * Gets all the spotter information  | 
                                                        |
| 559 | + *  | 
                                                        |
| 560 | + * @return Array the spotter information  | 
                                                        |
| 561 | + *  | 
                                                        |
| 562 | + */  | 
                                                        |
| 563 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())  | 
                                                        |
| 564 | +	{ | 
                                                        |
| 565 | 565 | global $globalTimezone, $globalDBdriver;  | 
                                                        
| 566 | 566 | require_once(dirname(__FILE__).'/class.Translation.php');  | 
                                                        
| 567 | 567 | $Translation = new Translation();  | 
                                                        
@@ -575,159 +575,159 @@ discard block  | 
                                                    ||
| 575 | 575 | $filter_query = $this->getFilter($filters);  | 
                                                        
| 576 | 576 | if ($q != "")  | 
                                                        
| 577 | 577 |  	{ | 
                                                        
| 578 | - if (!is_string($q))  | 
                                                        |
| 579 | -	    { | 
                                                        |
| 578 | + if (!is_string($q))  | 
                                                        |
| 579 | +		{ | 
                                                        |
| 580 | 580 | return false;  | 
                                                        
| 581 | -	    } else { | 
                                                        |
| 581 | +		} else { | 
                                                        |
| 582 | 582 | |
| 583 | 583 |  		$q_array = explode(" ", $q); | 
                                                        
| 584 | 584 | |
| 585 | 585 |  		foreach ($q_array as $q_item){ | 
                                                        
| 586 | -		    $additional_query .= " AND ("; | 
                                                        |
| 587 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";  | 
                                                        |
| 588 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 589 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";  | 
                                                        |
| 590 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";  | 
                                                        |
| 591 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 592 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";  | 
                                                        |
| 593 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";  | 
                                                        |
| 594 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 595 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";  | 
                                                        |
| 596 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";  | 
                                                        |
| 597 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";  | 
                                                        |
| 598 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 599 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";  | 
                                                        |
| 600 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";  | 
                                                        |
| 601 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";  | 
                                                        |
| 602 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";  | 
                                                        |
| 603 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";  | 
                                                        |
| 604 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";  | 
                                                        |
| 605 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";  | 
                                                        |
| 606 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";  | 
                                                        |
| 607 | - $translate = $Translation->ident2icao($q_item);  | 
                                                        |
| 608 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";  | 
                                                        |
| 609 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";  | 
                                                        |
| 610 | - $additional_query .= ")";  | 
                                                        |
| 586 | +			$additional_query .= " AND ("; | 
                                                        |
| 587 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";  | 
                                                        |
| 588 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 589 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";  | 
                                                        |
| 590 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";  | 
                                                        |
| 591 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 592 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";  | 
                                                        |
| 593 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";  | 
                                                        |
| 594 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 595 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";  | 
                                                        |
| 596 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";  | 
                                                        |
| 597 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";  | 
                                                        |
| 598 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";  | 
                                                        |
| 599 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";  | 
                                                        |
| 600 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";  | 
                                                        |
| 601 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";  | 
                                                        |
| 602 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";  | 
                                                        |
| 603 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";  | 
                                                        |
| 604 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";  | 
                                                        |
| 605 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";  | 
                                                        |
| 606 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";  | 
                                                        |
| 607 | + $translate = $Translation->ident2icao($q_item);  | 
                                                        |
| 608 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";  | 
                                                        |
| 609 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";  | 
                                                        |
| 610 | + $additional_query .= ")";  | 
                                                        |
| 611 | + }  | 
                                                        |
| 611 | 612 | }  | 
                                                        
| 612 | - }  | 
                                                        |
| 613 | 613 | }  | 
                                                        
| 614 | 614 | |
| 615 | 615 | if ($registration != "")  | 
                                                        
| 616 | 616 |  	{ | 
                                                        
| 617 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING);  | 
                                                        |
| 618 | - if (!is_string($registration))  | 
                                                        |
| 619 | -	    { | 
                                                        |
| 617 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING);  | 
                                                        |
| 618 | + if (!is_string($registration))  | 
                                                        |
| 619 | +		{ | 
                                                        |
| 620 | 620 | return false;  | 
                                                        
| 621 | -	    } else { | 
                                                        |
| 621 | +		} else { | 
                                                        |
| 622 | 622 | $additional_query .= " AND (marine_archive_output.registration = '".$registration."')";  | 
                                                        
| 623 | - }  | 
                                                        |
| 623 | + }  | 
                                                        |
| 624 | 624 | }  | 
                                                        
| 625 | 625 | |
| 626 | 626 | if ($aircraft_icao != "")  | 
                                                        
| 627 | 627 |  	{ | 
                                                        
| 628 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 629 | - if (!is_string($aircraft_icao))  | 
                                                        |
| 630 | -	    { | 
                                                        |
| 628 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 629 | + if (!is_string($aircraft_icao))  | 
                                                        |
| 630 | +		{ | 
                                                        |
| 631 | 631 | return false;  | 
                                                        
| 632 | -	    } else { | 
                                                        |
| 632 | +		} else { | 
                                                        |
| 633 | 633 | $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";  | 
                                                        
| 634 | - }  | 
                                                        |
| 634 | + }  | 
                                                        |
| 635 | 635 | }  | 
                                                        
| 636 | 636 | |
| 637 | 637 | if ($aircraft_manufacturer != "")  | 
                                                        
| 638 | 638 |  	{ | 
                                                        
| 639 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);  | 
                                                        |
| 640 | - if (!is_string($aircraft_manufacturer))  | 
                                                        |
| 641 | -	    { | 
                                                        |
| 639 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);  | 
                                                        |
| 640 | + if (!is_string($aircraft_manufacturer))  | 
                                                        |
| 641 | +		{ | 
                                                        |
| 642 | 642 | return false;  | 
                                                        
| 643 | -	    } else { | 
                                                        |
| 643 | +		} else { | 
                                                        |
| 644 | 644 | $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";  | 
                                                        
| 645 | - }  | 
                                                        |
| 645 | + }  | 
                                                        |
| 646 | 646 | }  | 
                                                        
| 647 | 647 | |
| 648 | 648 | if ($highlights == "true")  | 
                                                        
| 649 | 649 |  	{ | 
                                                        
| 650 | - if (!is_string($highlights))  | 
                                                        |
| 651 | -	    { | 
                                                        |
| 650 | + if (!is_string($highlights))  | 
                                                        |
| 651 | +		{ | 
                                                        |
| 652 | 652 | return false;  | 
                                                        
| 653 | -	    } else { | 
                                                        |
| 653 | +		} else { | 
                                                        |
| 654 | 654 | $additional_query .= " AND (marine_archive_output.highlight <> '')";  | 
                                                        
| 655 | - }  | 
                                                        |
| 655 | + }  | 
                                                        |
| 656 | 656 | }  | 
                                                        
| 657 | 657 | |
| 658 | 658 | if ($airline_icao != "")  | 
                                                        
| 659 | 659 |  	{ | 
                                                        
| 660 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 661 | - if (!is_string($airline_icao))  | 
                                                        |
| 662 | -	    { | 
                                                        |
| 660 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 661 | + if (!is_string($airline_icao))  | 
                                                        |
| 662 | +		{ | 
                                                        |
| 663 | 663 | return false;  | 
                                                        
| 664 | -	    } else { | 
                                                        |
| 664 | +		} else { | 
                                                        |
| 665 | 665 | $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";  | 
                                                        
| 666 | - }  | 
                                                        |
| 666 | + }  | 
                                                        |
| 667 | 667 | }  | 
                                                        
| 668 | 668 | |
| 669 | 669 | if ($airline_country != "")  | 
                                                        
| 670 | 670 |  	{ | 
                                                        
| 671 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 672 | - if (!is_string($airline_country))  | 
                                                        |
| 673 | -	    { | 
                                                        |
| 671 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 672 | + if (!is_string($airline_country))  | 
                                                        |
| 673 | +		{ | 
                                                        |
| 674 | 674 | return false;  | 
                                                        
| 675 | -	    } else { | 
                                                        |
| 675 | +		} else { | 
                                                        |
| 676 | 676 | $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";  | 
                                                        
| 677 | - }  | 
                                                        |
| 677 | + }  | 
                                                        |
| 678 | 678 | }  | 
                                                        
| 679 | 679 | |
| 680 | 680 | if ($airline_type != "")  | 
                                                        
| 681 | 681 |  	{ | 
                                                        
| 682 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);  | 
                                                        |
| 683 | - if (!is_string($airline_type))  | 
                                                        |
| 684 | -	    { | 
                                                        |
| 682 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);  | 
                                                        |
| 683 | + if (!is_string($airline_type))  | 
                                                        |
| 684 | +		{ | 
                                                        |
| 685 | 685 | return false;  | 
                                                        
| 686 | -	    } else { | 
                                                        |
| 686 | +		} else { | 
                                                        |
| 687 | 687 | if ($airline_type == "passenger")  | 
                                                        
| 688 | 688 |  		{ | 
                                                        
| 689 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";  | 
                                                        |
| 689 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";  | 
                                                        |
| 690 | 690 | }  | 
                                                        
| 691 | 691 | if ($airline_type == "cargo")  | 
                                                        
| 692 | 692 |  		{ | 
                                                        
| 693 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";  | 
                                                        |
| 693 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";  | 
                                                        |
| 694 | 694 | }  | 
                                                        
| 695 | 695 | if ($airline_type == "military")  | 
                                                        
| 696 | 696 |  		{ | 
                                                        
| 697 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')";  | 
                                                        |
| 697 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')";  | 
                                                        |
| 698 | + }  | 
                                                        |
| 698 | 699 | }  | 
                                                        
| 699 | - }  | 
                                                        |
| 700 | 700 | }  | 
                                                        
| 701 | 701 | |
| 702 | 702 | if ($airport != "")  | 
                                                        
| 703 | 703 |  	{ | 
                                                        
| 704 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING);  | 
                                                        |
| 705 | - if (!is_string($airport))  | 
                                                        |
| 706 | -	    { | 
                                                        |
| 704 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING);  | 
                                                        |
| 705 | + if (!is_string($airport))  | 
                                                        |
| 706 | +		{ | 
                                                        |
| 707 | 707 | return false;  | 
                                                        
| 708 | -	    } else { | 
                                                        |
| 708 | +		} else { | 
                                                        |
| 709 | 709 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";  | 
                                                        
| 710 | - }  | 
                                                        |
| 710 | + }  | 
                                                        |
| 711 | 711 | }  | 
                                                        
| 712 | 712 | |
| 713 | 713 | if ($airport_country != "")  | 
                                                        
| 714 | 714 |  	{ | 
                                                        
| 715 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 716 | - if (!is_string($airport_country))  | 
                                                        |
| 717 | -	    { | 
                                                        |
| 715 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 716 | + if (!is_string($airport_country))  | 
                                                        |
| 717 | +		{ | 
                                                        |
| 718 | 718 | return false;  | 
                                                        
| 719 | -	    } else { | 
                                                        |
| 719 | +		} else { | 
                                                        |
| 720 | 720 | $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";  | 
                                                        
| 721 | - }  | 
                                                        |
| 721 | + }  | 
                                                        |
| 722 | 722 | }  | 
                                                        
| 723 | 723 | |
| 724 | 724 | if ($callsign != "")  | 
                                                        
| 725 | 725 |  	{ | 
                                                        
| 726 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);  | 
                                                        |
| 727 | - if (!is_string($callsign))  | 
                                                        |
| 728 | -	    { | 
                                                        |
| 726 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);  | 
                                                        |
| 727 | + if (!is_string($callsign))  | 
                                                        |
| 728 | +		{ | 
                                                        |
| 729 | 729 | return false;  | 
                                                        
| 730 | -	    } else { | 
                                                        |
| 730 | +		} else { | 
                                                        |
| 731 | 731 | $translate = $Translation->ident2icao($callsign);  | 
                                                        
| 732 | 732 |  		if ($translate != $callsign) { | 
                                                        
| 733 | 733 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";  | 
                                                        
@@ -735,99 +735,99 @@ discard block  | 
                                                    ||
| 735 | 735 |  		} else { | 
                                                        
| 736 | 736 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";  | 
                                                        
| 737 | 737 | }  | 
                                                        
| 738 | - }  | 
                                                        |
| 738 | + }  | 
                                                        |
| 739 | 739 | }  | 
                                                        
| 740 | 740 | |
| 741 | 741 | if ($owner != "")  | 
                                                        
| 742 | 742 |  	{ | 
                                                        
| 743 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING);  | 
                                                        |
| 744 | - if (!is_string($owner))  | 
                                                        |
| 745 | -	    { | 
                                                        |
| 743 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING);  | 
                                                        |
| 744 | + if (!is_string($owner))  | 
                                                        |
| 745 | +		{ | 
                                                        |
| 746 | 746 | return false;  | 
                                                        
| 747 | -	    } else { | 
                                                        |
| 747 | +		} else { | 
                                                        |
| 748 | 748 | $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";  | 
                                                        
| 749 | - }  | 
                                                        |
| 749 | + }  | 
                                                        |
| 750 | 750 | }  | 
                                                        
| 751 | 751 | |
| 752 | 752 | if ($pilot_name != "")  | 
                                                        
| 753 | 753 |  	{ | 
                                                        
| 754 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);  | 
                                                        |
| 755 | - if (!is_string($pilot_name))  | 
                                                        |
| 756 | -	    { | 
                                                        |
| 754 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);  | 
                                                        |
| 755 | + if (!is_string($pilot_name))  | 
                                                        |
| 756 | +		{ | 
                                                        |
| 757 | 757 | return false;  | 
                                                        
| 758 | -	    } else { | 
                                                        |
| 758 | +		} else { | 
                                                        |
| 759 | 759 | $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";  | 
                                                        
| 760 | - }  | 
                                                        |
| 760 | + }  | 
                                                        |
| 761 | 761 | }  | 
                                                        
| 762 | 762 | |
| 763 | 763 | if ($pilot_id != "")  | 
                                                        
| 764 | 764 |  	{ | 
                                                        
| 765 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 766 | - if (!is_string($pilot_id))  | 
                                                        |
| 767 | -	    { | 
                                                        |
| 765 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 766 | + if (!is_string($pilot_id))  | 
                                                        |
| 767 | +		{ | 
                                                        |
| 768 | 768 | return false;  | 
                                                        
| 769 | -	    } else { | 
                                                        |
| 769 | +		} else { | 
                                                        |
| 770 | 770 | $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";  | 
                                                        
| 771 | - }  | 
                                                        |
| 771 | + }  | 
                                                        |
| 772 | 772 | }  | 
                                                        
| 773 | 773 | |
| 774 | 774 | if ($departure_airport_route != "")  | 
                                                        
| 775 | 775 |  	{ | 
                                                        
| 776 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 777 | - if (!is_string($departure_airport_route))  | 
                                                        |
| 778 | -	    { | 
                                                        |
| 776 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 777 | + if (!is_string($departure_airport_route))  | 
                                                        |
| 778 | +		{ | 
                                                        |
| 779 | 779 | return false;  | 
                                                        
| 780 | -	    } else { | 
                                                        |
| 780 | +		} else { | 
                                                        |
| 781 | 781 | $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";  | 
                                                        
| 782 | - }  | 
                                                        |
| 782 | + }  | 
                                                        |
| 783 | 783 | }  | 
                                                        
| 784 | 784 | |
| 785 | 785 | if ($arrival_airport_route != "")  | 
                                                        
| 786 | 786 |  	{ | 
                                                        
| 787 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 788 | - if (!is_string($arrival_airport_route))  | 
                                                        |
| 789 | -	    { | 
                                                        |
| 787 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 788 | + if (!is_string($arrival_airport_route))  | 
                                                        |
| 789 | +		{ | 
                                                        |
| 790 | 790 | return false;  | 
                                                        
| 791 | -	    } else { | 
                                                        |
| 791 | +		} else { | 
                                                        |
| 792 | 792 | $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";  | 
                                                        
| 793 | - }  | 
                                                        |
| 793 | + }  | 
                                                        |
| 794 | 794 | }  | 
                                                        
| 795 | 795 | |
| 796 | 796 | if ($altitude != "")  | 
                                                        
| 797 | 797 |  	{ | 
                                                        
| 798 | -	    $altitude_array = explode(",", $altitude); | 
                                                        |
| 798 | +		$altitude_array = explode(",", $altitude); | 
                                                        |
| 799 | 799 | |
| 800 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 801 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 800 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 801 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 802 | 802 | |
| 803 | 803 | |
| 804 | - if ($altitude_array[1] != "")  | 
                                                        |
| 805 | -	    {                 | 
                                                        |
| 804 | + if ($altitude_array[1] != "")  | 
                                                        |
| 805 | +		{                 | 
                                                        |
| 806 | 806 | $altitude_array[0] = substr($altitude_array[0], 0, -2);  | 
                                                        
| 807 | 807 | $altitude_array[1] = substr($altitude_array[1], 0, -2);  | 
                                                        
| 808 | 808 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";  | 
                                                        
| 809 | -	    } else { | 
                                                        |
| 809 | +		} else { | 
                                                        |
| 810 | 810 | $altitude_array[0] = substr($altitude_array[0], 0, -2);  | 
                                                        
| 811 | 811 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' ";  | 
                                                        
| 812 | - }  | 
                                                        |
| 812 | + }  | 
                                                        |
| 813 | 813 | }  | 
                                                        
| 814 | 814 | |
| 815 | 815 | if ($date_posted != "")  | 
                                                        
| 816 | 816 |  	{ | 
                                                        
| 817 | -	    $date_array = explode(",", $date_posted); | 
                                                        |
| 817 | +		$date_array = explode(",", $date_posted); | 
                                                        |
| 818 | 818 | |
| 819 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);  | 
                                                        |
| 820 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);  | 
                                                        |
| 819 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);  | 
                                                        |
| 820 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);  | 
                                                        |
| 821 | 821 | |
| 822 | -	    if ($globalTimezone != '') { | 
                                                        |
| 822 | +		if ($globalTimezone != '') { | 
                                                        |
| 823 | 823 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 824 | 824 | $datetime = new DateTime();  | 
                                                        
| 825 | 825 |  		$offset = $datetime->format('P'); | 
                                                        
| 826 | - } else $offset = '+00:00';  | 
                                                        |
| 826 | + } else $offset = '+00:00';  | 
                                                        |
| 827 | 827 | |
| 828 | 828 | |
| 829 | - if ($date_array[1] != "")  | 
                                                        |
| 830 | -	    {                 | 
                                                        |
| 829 | + if ($date_array[1] != "")  | 
                                                        |
| 830 | +		{                 | 
                                                        |
| 831 | 831 |  		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); | 
                                                        
| 832 | 832 |  		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); | 
                                                        
| 833 | 833 |  		if ($globalDBdriver == 'mysql') { | 
                                                        
@@ -835,28 +835,28 @@ discard block  | 
                                                    ||
| 835 | 835 |  		} else { | 
                                                        
| 836 | 836 |  			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; | 
                                                        
| 837 | 837 | }  | 
                                                        
| 838 | -	    } else { | 
                                                        |
| 838 | +		} else { | 
                                                        |
| 839 | 839 |  		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); | 
                                                        
| 840 | -                if ($globalDBdriver == 'mysql') { | 
                                                        |
| 840 | +				if ($globalDBdriver == 'mysql') { | 
                                                        |
| 841 | 841 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";  | 
                                                        
| 842 | 842 |  		} else { | 
                                                        
| 843 | 843 |  			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; | 
                                                        
| 844 | 844 | }  | 
                                                        
| 845 | - }  | 
                                                        |
| 845 | + }  | 
                                                        |
| 846 | 846 | }  | 
                                                        
| 847 | 847 | |
| 848 | 848 | if ($limit != "")  | 
                                                        
| 849 | 849 |  	{ | 
                                                        
| 850 | -	    $limit_array = explode(",", $limit); | 
                                                        |
| 850 | +		$limit_array = explode(",", $limit); | 
                                                        |
| 851 | 851 | |
| 852 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 853 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 852 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 853 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 854 | 854 | |
| 855 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 856 | -	    { | 
                                                        |
| 855 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 856 | +		{ | 
                                                        |
| 857 | 857 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 858 | 858 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 859 | - }  | 
                                                        |
| 859 | + }  | 
                                                        |
| 860 | 860 | }  | 
                                                        
| 861 | 861 | |
| 862 | 862 | |
@@ -887,33 +887,33 @@ discard block  | 
                                                    ||
| 887 | 887 | $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);  | 
                                                        
| 888 | 888 | |
| 889 | 889 | return $spotter_array;  | 
                                                        
| 890 | - }  | 
                                                        |
| 890 | + }  | 
                                                        |
| 891 | 891 | |
| 892 | - public function deleteMarineArchiveData()  | 
                                                        |
| 893 | -    { | 
                                                        |
| 892 | + public function deleteMarineArchiveData()  | 
                                                        |
| 893 | +	{ | 
                                                        |
| 894 | 894 | global $globalArchiveKeepMonths, $globalDBdriver;  | 
                                                        
| 895 | -                date_default_timezone_set('UTC'); | 
                                                        |
| 896 | -                if ($globalDBdriver == 'mysql') { | 
                                                        |
| 895 | +				date_default_timezone_set('UTC'); | 
                                                        |
| 896 | +				if ($globalDBdriver == 'mysql') { | 
                                                        |
| 897 | 897 | $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';  | 
                                                        
| 898 | 898 |  		} else { | 
                                                        
| 899 | 899 | $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";  | 
                                                        
| 900 | 900 | }  | 
                                                        
| 901 | -                try { | 
                                                        |
| 902 | - $sth = $this->db->prepare($query);  | 
                                                        |
| 903 | - $sth->execute();  | 
                                                        |
| 904 | -                } catch(PDOException $e) { | 
                                                        |
| 905 | - return "error";  | 
                                                        |
| 906 | - }  | 
                                                        |
| 901 | +				try { | 
                                                        |
| 902 | + $sth = $this->db->prepare($query);  | 
                                                        |
| 903 | + $sth->execute();  | 
                                                        |
| 904 | +				} catch(PDOException $e) { | 
                                                        |
| 905 | + return "error";  | 
                                                        |
| 906 | + }  | 
                                                        |
| 907 | 907 | }  | 
                                                        
| 908 | 908 | |
| 909 | - /**  | 
                                                        |
| 910 | - * Gets all the spotter information based on the callsign  | 
                                                        |
| 911 | - *  | 
                                                        |
| 912 | - * @return Array the spotter information  | 
                                                        |
| 913 | - *  | 
                                                        |
| 914 | - */  | 
                                                        |
| 915 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')  | 
                                                        |
| 916 | -    { | 
                                                        |
| 909 | + /**  | 
                                                        |
| 910 | + * Gets all the spotter information based on the callsign  | 
                                                        |
| 911 | + *  | 
                                                        |
| 912 | + * @return Array the spotter information  | 
                                                        |
| 913 | + *  | 
                                                        |
| 914 | + */  | 
                                                        |
| 915 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')  | 
                                                        |
| 916 | +	{ | 
                                                        |
| 917 | 917 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output";  | 
                                                        
| 918 | 918 | |
| 919 | 919 |  	date_default_timezone_set('UTC'); | 
                                                        
@@ -925,35 +925,35 @@ discard block  | 
                                                    ||
| 925 | 925 | |
| 926 | 926 | if ($ident != "")  | 
                                                        
| 927 | 927 |  	{ | 
                                                        
| 928 | - if (!is_string($ident))  | 
                                                        |
| 929 | -	    { | 
                                                        |
| 928 | + if (!is_string($ident))  | 
                                                        |
| 929 | +		{ | 
                                                        |
| 930 | 930 | return false;  | 
                                                        
| 931 | -	    } else { | 
                                                        |
| 931 | +		} else { | 
                                                        |
| 932 | 932 | $additional_query = " AND (marine_archive_output.ident = :ident)";  | 
                                                        
| 933 | 933 |  		$query_values = array(':ident' => $ident); | 
                                                        
| 934 | - }  | 
                                                        |
| 934 | + }  | 
                                                        |
| 935 | 935 | }  | 
                                                        
| 936 | 936 | |
| 937 | 937 | if ($limit != "")  | 
                                                        
| 938 | 938 |  	{ | 
                                                        
| 939 | -	    $limit_array = explode(",", $limit); | 
                                                        |
| 939 | +		$limit_array = explode(",", $limit); | 
                                                        |
| 940 | 940 | |
| 941 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 942 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 941 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 942 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 943 | 943 | |
| 944 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 945 | -	    { | 
                                                        |
| 944 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 945 | +		{ | 
                                                        |
| 946 | 946 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 947 | 947 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 948 | - }  | 
                                                        |
| 948 | + }  | 
                                                        |
| 949 | 949 | }  | 
                                                        
| 950 | 950 | |
| 951 | 951 | if ($sort != "")  | 
                                                        
| 952 | 952 |  	{ | 
                                                        
| 953 | - $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 954 | - $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 953 | + $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 954 | + $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 955 | 955 |  	} else { | 
                                                        
| 956 | - $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 956 | + $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 957 | 957 | }  | 
                                                        
| 958 | 958 | |
| 959 | 959 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query;  | 
                                                        
@@ -961,17 +961,17 @@ discard block  | 
                                                    ||
| 961 | 961 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);  | 
                                                        
| 962 | 962 | |
| 963 | 963 | return $spotter_array;  | 
                                                        
| 964 | - }  | 
                                                        |
| 964 | + }  | 
                                                        |
| 965 | 965 | |
| 966 | 966 | |
| 967 | - /**  | 
                                                        |
| 968 | - * Gets all the spotter information based on the owner  | 
                                                        |
| 969 | - *  | 
                                                        |
| 970 | - * @return Array the spotter information  | 
                                                        |
| 971 | - *  | 
                                                        |
| 972 | - */  | 
                                                        |
| 973 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())  | 
                                                        |
| 974 | -    { | 
                                                        |
| 967 | + /**  | 
                                                        |
| 968 | + * Gets all the spotter information based on the owner  | 
                                                        |
| 969 | + *  | 
                                                        |
| 970 | + * @return Array the spotter information  | 
                                                        |
| 971 | + *  | 
                                                        |
| 972 | + */  | 
                                                        |
| 973 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())  | 
                                                        |
| 974 | +	{ | 
                                                        |
| 975 | 975 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output";  | 
                                                        
| 976 | 976 | |
| 977 | 977 |  	date_default_timezone_set('UTC'); | 
                                                        
@@ -984,35 +984,35 @@ discard block  | 
                                                    ||
| 984 | 984 | |
| 985 | 985 | if ($owner != "")  | 
                                                        
| 986 | 986 |  	{ | 
                                                        
| 987 | - if (!is_string($owner))  | 
                                                        |
| 988 | -	    { | 
                                                        |
| 987 | + if (!is_string($owner))  | 
                                                        |
| 988 | +		{ | 
                                                        |
| 989 | 989 | return false;  | 
                                                        
| 990 | -	    } else { | 
                                                        |
| 990 | +		} else { | 
                                                        |
| 991 | 991 | $additional_query = " AND (marine_archive_output.owner_name = :owner)";  | 
                                                        
| 992 | 992 |  		$query_values = array(':owner' => $owner); | 
                                                        
| 993 | - }  | 
                                                        |
| 993 | + }  | 
                                                        |
| 994 | 994 | }  | 
                                                        
| 995 | 995 | |
| 996 | 996 | if ($limit != "")  | 
                                                        
| 997 | 997 |  	{ | 
                                                        
| 998 | -	    $limit_array = explode(",", $limit); | 
                                                        |
| 998 | +		$limit_array = explode(",", $limit); | 
                                                        |
| 999 | 999 | |
| 1000 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1001 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1000 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1001 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1002 | 1002 | |
| 1003 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 1004 | -	    { | 
                                                        |
| 1003 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 1004 | +		{ | 
                                                        |
| 1005 | 1005 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 1006 | 1006 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 1007 | - }  | 
                                                        |
| 1007 | + }  | 
                                                        |
| 1008 | 1008 | }  | 
                                                        
| 1009 | 1009 | |
| 1010 | 1010 | if ($sort != "")  | 
                                                        
| 1011 | 1011 |  	{ | 
                                                        
| 1012 | - $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1013 | - $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1012 | + $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1013 | + $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1014 | 1014 |  	} else { | 
                                                        
| 1015 | - $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1015 | + $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1016 | 1016 | }  | 
                                                        
| 1017 | 1017 | |
| 1018 | 1018 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;  | 
                                                        
@@ -1020,16 +1020,16 @@ discard block  | 
                                                    ||
| 1020 | 1020 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);  | 
                                                        
| 1021 | 1021 | |
| 1022 | 1022 | return $spotter_array;  | 
                                                        
| 1023 | - }  | 
                                                        |
| 1023 | + }  | 
                                                        |
| 1024 | 1024 | |
| 1025 | - /**  | 
                                                        |
| 1026 | - * Gets all the spotter information based on the pilot  | 
                                                        |
| 1027 | - *  | 
                                                        |
| 1028 | - * @return Array the spotter information  | 
                                                        |
| 1029 | - *  | 
                                                        |
| 1030 | - */  | 
                                                        |
| 1031 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())  | 
                                                        |
| 1032 | -    { | 
                                                        |
| 1025 | + /**  | 
                                                        |
| 1026 | + * Gets all the spotter information based on the pilot  | 
                                                        |
| 1027 | + *  | 
                                                        |
| 1028 | + * @return Array the spotter information  | 
                                                        |
| 1029 | + *  | 
                                                        |
| 1030 | + */  | 
                                                        |
| 1031 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())  | 
                                                        |
| 1032 | +	{ | 
                                                        |
| 1033 | 1033 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output";  | 
                                                        
| 1034 | 1034 | |
| 1035 | 1035 |  	date_default_timezone_set('UTC'); | 
                                                        
@@ -1048,24 +1048,24 @@ discard block  | 
                                                    ||
| 1048 | 1048 | |
| 1049 | 1049 | if ($limit != "")  | 
                                                        
| 1050 | 1050 |  	{ | 
                                                        
| 1051 | -	    $limit_array = explode(",", $limit); | 
                                                        |
| 1051 | +		$limit_array = explode(",", $limit); | 
                                                        |
| 1052 | 1052 | |
| 1053 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1054 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1053 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1054 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1055 | 1055 | |
| 1056 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 1057 | -	    { | 
                                                        |
| 1056 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 1057 | +		{ | 
                                                        |
| 1058 | 1058 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 1059 | 1059 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 1060 | - }  | 
                                                        |
| 1060 | + }  | 
                                                        |
| 1061 | 1061 | }  | 
                                                        
| 1062 | 1062 | |
| 1063 | 1063 | if ($sort != "")  | 
                                                        
| 1064 | 1064 |  	{ | 
                                                        
| 1065 | - $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1066 | - $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1065 | + $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1066 | + $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1067 | 1067 |  	} else { | 
                                                        
| 1068 | - $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1068 | + $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1069 | 1069 | }  | 
                                                        
| 1070 | 1070 | |
| 1071 | 1071 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;  | 
                                                        
@@ -1073,16 +1073,16 @@ discard block  | 
                                                    ||
| 1073 | 1073 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);  | 
                                                        
| 1074 | 1074 | |
| 1075 | 1075 | return $spotter_array;  | 
                                                        
| 1076 | - }  | 
                                                        |
| 1076 | + }  | 
                                                        |
| 1077 | 1077 | |
| 1078 | - /**  | 
                                                        |
| 1079 | - * Gets all number of flight over countries  | 
                                                        |
| 1080 | - *  | 
                                                        |
| 1081 | - * @return Array the airline country list  | 
                                                        |
| 1082 | - *  | 
                                                        |
| 1083 | - */  | 
                                                        |
| 1084 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1085 | -    { | 
                                                        |
| 1078 | + /**  | 
                                                        |
| 1079 | + * Gets all number of flight over countries  | 
                                                        |
| 1080 | + *  | 
                                                        |
| 1081 | + * @return Array the airline country list  | 
                                                        |
| 1082 | + *  | 
                                                        |
| 1083 | + */  | 
                                                        |
| 1084 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1085 | +	{ | 
                                                        |
| 1086 | 1086 | global $globalDBdriver;  | 
                                                        
| 1087 | 1087 | /*  | 
                                                        
| 1088 | 1088 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb  | 
                                                        
@@ -1092,14 +1092,14 @@ discard block  | 
                                                    ||
| 1092 | 1092 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb  | 
                                                        
| 1093 | 1093 | FROM countries c, marine_archive s  | 
                                                        
| 1094 | 1094 | WHERE c.iso2 = s.over_country ";  | 
                                                        
| 1095 | -                if ($olderthanmonths > 0) { | 
                                                        |
| 1096 | -            		if ($globalDBdriver == 'mysql') { | 
                                                        |
| 1095 | +				if ($olderthanmonths > 0) { | 
                                                        |
| 1096 | +					if ($globalDBdriver == 'mysql') { | 
                                                        |
| 1097 | 1097 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';  | 
                                                        
| 1098 | 1098 |  			} else { | 
                                                        
| 1099 | 1099 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        
| 1100 | 1100 | }  | 
                                                        
| 1101 | 1101 | }  | 
                                                        
| 1102 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";  | 
                                                        |
| 1102 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";  | 
                                                        |
| 1103 | 1103 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";  | 
                                                        
| 1104 | 1104 | if ($limit) $query .= " LIMIT 0,10";  | 
                                                        
| 1105 | 1105 | |
@@ -1112,23 +1112,23 @@ discard block  | 
                                                    ||
| 1112 | 1112 | |
| 1113 | 1113 | while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        
| 1114 | 1114 |  	{ | 
                                                        
| 1115 | - $temp_array['flight_count'] = $row['nb'];  | 
                                                        |
| 1116 | - $temp_array['flight_country'] = $row['name'];  | 
                                                        |
| 1117 | - $temp_array['flight_country_iso3'] = $row['iso3'];  | 
                                                        |
| 1118 | - $temp_array['flight_country_iso2'] = $row['iso2'];  | 
                                                        |
| 1119 | - $flight_array[] = $temp_array;  | 
                                                        |
| 1115 | + $temp_array['flight_count'] = $row['nb'];  | 
                                                        |
| 1116 | + $temp_array['flight_country'] = $row['name'];  | 
                                                        |
| 1117 | + $temp_array['flight_country_iso3'] = $row['iso3'];  | 
                                                        |
| 1118 | + $temp_array['flight_country_iso2'] = $row['iso2'];  | 
                                                        |
| 1119 | + $flight_array[] = $temp_array;  | 
                                                        |
| 1120 | 1120 | }  | 
                                                        
| 1121 | 1121 | return $flight_array;  | 
                                                        
| 1122 | - }  | 
                                                        |
| 1122 | + }  | 
                                                        |
| 1123 | 1123 | |
| 1124 | - /**  | 
                                                        |
| 1125 | - * Gets all number of flight over countries  | 
                                                        |
| 1126 | - *  | 
                                                        |
| 1127 | - * @return Array the airline country list  | 
                                                        |
| 1128 | - *  | 
                                                        |
| 1129 | - */  | 
                                                        |
| 1130 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1131 | -    { | 
                                                        |
| 1124 | + /**  | 
                                                        |
| 1125 | + * Gets all number of flight over countries  | 
                                                        |
| 1126 | + *  | 
                                                        |
| 1127 | + * @return Array the airline country list  | 
                                                        |
| 1128 | + *  | 
                                                        |
| 1129 | + */  | 
                                                        |
| 1130 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1131 | +	{ | 
                                                        |
| 1132 | 1132 | global $globalDBdriver;  | 
                                                        
| 1133 | 1133 | /*  | 
                                                        
| 1134 | 1134 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb  | 
                                                        
@@ -1138,14 +1138,14 @@ discard block  | 
                                                    ||
| 1138 | 1138 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb  | 
                                                        
| 1139 | 1139 | FROM countries c, marine_archive s, spotter_output o  | 
                                                        
| 1140 | 1140 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id ";  | 
                                                        
| 1141 | -                if ($olderthanmonths > 0) { | 
                                                        |
| 1142 | -            		if ($globalDBdriver == 'mysql') { | 
                                                        |
| 1141 | +				if ($olderthanmonths > 0) { | 
                                                        |
| 1142 | +					if ($globalDBdriver == 'mysql') { | 
                                                        |
| 1143 | 1143 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';  | 
                                                        
| 1144 | 1144 |  			} else { | 
                                                        
| 1145 | 1145 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        
| 1146 | 1146 | }  | 
                                                        
| 1147 | 1147 | }  | 
                                                        
| 1148 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";  | 
                                                        |
| 1148 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";  | 
                                                        |
| 1149 | 1149 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";  | 
                                                        
| 1150 | 1150 | if ($limit) $query .= " LIMIT 0,10";  | 
                                                        
| 1151 | 1151 | |
@@ -1158,24 +1158,24 @@ discard block  | 
                                                    ||
| 1158 | 1158 | |
| 1159 | 1159 | while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        
| 1160 | 1160 |  	{ | 
                                                        
| 1161 | - $temp_array['airline_icao'] = $row['airline_icao'];  | 
                                                        |
| 1162 | - $temp_array['flight_count'] = $row['nb'];  | 
                                                        |
| 1163 | - $temp_array['flight_country'] = $row['name'];  | 
                                                        |
| 1164 | - $temp_array['flight_country_iso3'] = $row['iso3'];  | 
                                                        |
| 1165 | - $temp_array['flight_country_iso2'] = $row['iso2'];  | 
                                                        |
| 1166 | - $flight_array[] = $temp_array;  | 
                                                        |
| 1161 | + $temp_array['airline_icao'] = $row['airline_icao'];  | 
                                                        |
| 1162 | + $temp_array['flight_count'] = $row['nb'];  | 
                                                        |
| 1163 | + $temp_array['flight_country'] = $row['name'];  | 
                                                        |
| 1164 | + $temp_array['flight_country_iso3'] = $row['iso3'];  | 
                                                        |
| 1165 | + $temp_array['flight_country_iso2'] = $row['iso2'];  | 
                                                        |
| 1166 | + $flight_array[] = $temp_array;  | 
                                                        |
| 1167 | 1167 | }  | 
                                                        
| 1168 | 1168 | return $flight_array;  | 
                                                        
| 1169 | - }  | 
                                                        |
| 1169 | + }  | 
                                                        |
| 1170 | 1170 | |
| 1171 | - /**  | 
                                                        |
| 1172 | - * Gets last spotter information based on a particular callsign  | 
                                                        |
| 1173 | - *  | 
                                                        |
| 1174 | - * @return Array the spotter information  | 
                                                        |
| 1175 | - *  | 
                                                        |
| 1176 | - */  | 
                                                        |
| 1177 | - public function getDateArchiveMarineDataById($id,$date)  | 
                                                        |
| 1178 | -    { | 
                                                        |
| 1171 | + /**  | 
                                                        |
| 1172 | + * Gets last spotter information based on a particular callsign  | 
                                                        |
| 1173 | + *  | 
                                                        |
| 1174 | + * @return Array the spotter information  | 
                                                        |
| 1175 | + *  | 
                                                        |
| 1176 | + */  | 
                                                        |
| 1177 | + public function getDateArchiveMarineDataById($id,$date)  | 
                                                        |
| 1178 | +	{ | 
                                                        |
| 1179 | 1179 | $Marine = new Marine($this->db);  | 
                                                        
| 1180 | 1180 |  	date_default_timezone_set('UTC'); | 
                                                        
| 1181 | 1181 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
@@ -1183,16 +1183,16 @@ discard block  | 
                                                    ||
| 1183 | 1183 |  	$date = date('c',$date); | 
                                                        
| 1184 | 1184 |  	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); | 
                                                        
| 1185 | 1185 | return $spotter_array;  | 
                                                        
| 1186 | - }  | 
                                                        |
| 1186 | + }  | 
                                                        |
| 1187 | 1187 | |
| 1188 | - /**  | 
                                                        |
| 1189 | - * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 1190 | - *  | 
                                                        |
| 1191 | - * @return Array the spotter information  | 
                                                        |
| 1192 | - *  | 
                                                        |
| 1193 | - */  | 
                                                        |
| 1194 | - public function getDateArchiveMarineDataByIdent($ident,$date)  | 
                                                        |
| 1195 | -    { | 
                                                        |
| 1188 | + /**  | 
                                                        |
| 1189 | + * Gets all the spotter information based on a particular callsign  | 
                                                        |
| 1190 | + *  | 
                                                        |
| 1191 | + * @return Array the spotter information  | 
                                                        |
| 1192 | + *  | 
                                                        |
| 1193 | + */  | 
                                                        |
| 1194 | + public function getDateArchiveMarineDataByIdent($ident,$date)  | 
                                                        |
| 1195 | +	{ | 
                                                        |
| 1196 | 1196 | $Marine = new Marine($this->db);  | 
                                                        
| 1197 | 1197 |  	date_default_timezone_set('UTC'); | 
                                                        
| 1198 | 1198 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
@@ -1200,16 +1200,16 @@ discard block  | 
                                                    ||
| 1200 | 1200 |  	$date = date('c',$date); | 
                                                        
| 1201 | 1201 |  	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); | 
                                                        
| 1202 | 1202 | return $spotter_array;  | 
                                                        
| 1203 | - }  | 
                                                        |
| 1203 | + }  | 
                                                        |
| 1204 | 1204 | |
| 1205 | - /**  | 
                                                        |
| 1206 | - * Gets all the spotter information based on the airport  | 
                                                        |
| 1207 | - *  | 
                                                        |
| 1208 | - * @return Array the spotter information  | 
                                                        |
| 1209 | - *  | 
                                                        |
| 1210 | - */  | 
                                                        |
| 1211 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())  | 
                                                        |
| 1212 | -    { | 
                                                        |
| 1205 | + /**  | 
                                                        |
| 1206 | + * Gets all the spotter information based on the airport  | 
                                                        |
| 1207 | + *  | 
                                                        |
| 1208 | + * @return Array the spotter information  | 
                                                        |
| 1209 | + *  | 
                                                        |
| 1210 | + */  | 
                                                        |
| 1211 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())  | 
                                                        |
| 1212 | +	{ | 
                                                        |
| 1213 | 1213 | global $global_query;  | 
                                                        
| 1214 | 1214 | $Marine = new Marine();  | 
                                                        
| 1215 | 1215 |  	date_default_timezone_set('UTC'); | 
                                                        
@@ -1220,35 +1220,35 @@ discard block  | 
                                                    ||
| 1220 | 1220 | |
| 1221 | 1221 | if ($airport != "")  | 
                                                        
| 1222 | 1222 |  	{ | 
                                                        
| 1223 | - if (!is_string($airport))  | 
                                                        |
| 1224 | -	    { | 
                                                        |
| 1223 | + if (!is_string($airport))  | 
                                                        |
| 1224 | +		{ | 
                                                        |
| 1225 | 1225 | return false;  | 
                                                        
| 1226 | -	    } else { | 
                                                        |
| 1226 | +		} else { | 
                                                        |
| 1227 | 1227 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";  | 
                                                        
| 1228 | 1228 |  		$query_values = array(':airport' => $airport); | 
                                                        
| 1229 | - }  | 
                                                        |
| 1229 | + }  | 
                                                        |
| 1230 | 1230 | }  | 
                                                        
| 1231 | 1231 | |
| 1232 | 1232 | if ($limit != "")  | 
                                                        
| 1233 | 1233 |  	{ | 
                                                        
| 1234 | -	    $limit_array = explode(",", $limit); | 
                                                        |
| 1234 | +		$limit_array = explode(",", $limit); | 
                                                        |
| 1235 | 1235 | |
| 1236 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1237 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1236 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1237 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1238 | 1238 | |
| 1239 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 1240 | -	    { | 
                                                        |
| 1239 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        |
| 1240 | +		{ | 
                                                        |
| 1241 | 1241 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];  | 
                                                        
| 1242 | 1242 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];  | 
                                                        
| 1243 | - }  | 
                                                        |
| 1243 | + }  | 
                                                        |
| 1244 | 1244 | }  | 
                                                        
| 1245 | 1245 | |
| 1246 | 1246 | if ($sort != "")  | 
                                                        
| 1247 | 1247 |  	{ | 
                                                        
| 1248 | - $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1249 | - $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1248 | + $search_orderby_array = $Marine->getOrderBy();  | 
                                                        |
| 1249 | + $orderby_query = $search_orderby_array[$sort]['sql'];  | 
                                                        |
| 1250 | 1250 |  	} else { | 
                                                        
| 1251 | - $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1251 | + $orderby_query = " ORDER BY marine_archive_output.date DESC";  | 
                                                        |
| 1252 | 1252 | }  | 
                                                        
| 1253 | 1253 | |
| 1254 | 1254 | $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;  | 
                                                        
@@ -1256,6 +1256,6 @@ discard block  | 
                                                    ||
| 1256 | 1256 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);  | 
                                                        
| 1257 | 1257 | |
| 1258 | 1258 | return $spotter_array;  | 
                                                        
| 1259 | - }  | 
                                                        |
| 1259 | + }  | 
                                                        |
| 1260 | 1260 | }  | 
                                                        
| 1261 | 1261 | ?>  | 
                                                        
| 1262 | 1262 | \ No newline at end of file  | 
                                                        
@@ -94,7 +94,7 @@ discard block  | 
                                                    ||
| 94 | 94 | }  | 
                                                        
| 95 | 95 | */  | 
                                                        
| 96 | 96 | // marine_archive  | 
                                                        
| 97 | -	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { | 
                                                        |
| 97 | +	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { | 
                                                        |
| 98 | 98 | /*  | 
                                                        
| 99 | 99 | require_once(dirname(__FILE__).'/class.Marine.php');  | 
                                                        
| 100 | 100 |  		if ($over_country == '') { | 
                                                        
@@ -106,16 +106,16 @@ discard block  | 
                                                    ||
| 106 | 106 | */  | 
                                                        
| 107 | 107 | $country = $over_country;  | 
                                                        
| 108 | 108 | // Route is not added in marine_archive  | 
                                                        
| 109 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date)  | 
                                                        |
| 109 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date)  | 
                                                        |
| 110 | 110 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';  | 
                                                        
| 111 | 111 | |
| 112 | -		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); | 
                                                        |
| 112 | +		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); | 
                                                        |
| 113 | 113 | |
| 114 | 114 |  		try { | 
                                                        
| 115 | 115 | $sth = $this->db->prepare($query);  | 
                                                        
| 116 | 116 | $sth->execute($query_values);  | 
                                                        
| 117 | 117 | $sth->closeCursor();  | 
                                                        
| 118 | -		} catch(PDOException $e) { | 
                                                        |
| 118 | +		} catch (PDOException $e) { | 
                                                        |
| 119 | 119 | return "error : ".$e->getMessage();  | 
                                                        
| 120 | 120 | }  | 
                                                        
| 121 | 121 | return "success";  | 
                                                        
@@ -135,9 +135,9 @@ discard block  | 
                                                    ||
| 135 | 135 | |
| 136 | 136 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 137 | 137 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        
| 138 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 138 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 139 | 139 | |
| 140 | -                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); | 
                                                        |
| 140 | +                $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); | 
                                                        |
| 141 | 141 | |
| 142 | 142 | return $spotter_array;  | 
                                                        
| 143 | 143 | }  | 
                                                        
@@ -156,7 +156,7 @@ discard block  | 
                                                    ||
| 156 | 156 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 157 | 157 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";  | 
                                                        
| 158 | 158 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        
| 159 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 159 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";  | 
                                                        |
| 160 | 160 | |
| 161 | 161 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 162 | 162 | /*  | 
                                                        
@@ -169,7 +169,7 @@ discard block  | 
                                                    ||
| 169 | 169 | }  | 
                                                        
| 170 | 170 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);  | 
                                                        
| 171 | 171 | */  | 
                                                        
| 172 | -                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        |
| 172 | +                $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); | 
                                                        |
| 173 | 173 | |
| 174 | 174 | return $spotter_array;  | 
                                                        
| 175 | 175 | }  | 
                                                        
@@ -184,14 +184,14 @@ discard block  | 
                                                    ||
| 184 | 184 |  	{ | 
                                                        
| 185 | 185 |                  date_default_timezone_set('UTC'); | 
                                                        
| 186 | 186 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 187 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 187 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 188 | 188 | |
| 189 | 189 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 190 | 190 | |
| 191 | 191 |                  try { | 
                                                        
| 192 | 192 | $sth = $this->db->prepare($query);  | 
                                                        
| 193 | 193 |                          $sth->execute(array(':id' => $id)); | 
                                                        
| 194 | -                } catch(PDOException $e) { | 
                                                        |
| 194 | +                } catch (PDOException $e) { | 
                                                        |
| 195 | 195 | echo $e->getMessage();  | 
                                                        
| 196 | 196 | die;  | 
                                                        
| 197 | 197 | }  | 
                                                        
@@ -210,14 +210,14 @@ discard block  | 
                                                    ||
| 210 | 210 |          { | 
                                                        
| 211 | 211 |                  date_default_timezone_set('UTC'); | 
                                                        
| 212 | 212 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 213 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 213 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";  | 
                                                        |
| 214 | 214 | |
| 215 | 215 |  //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); | 
                                                        
| 216 | 216 | |
| 217 | 217 |                  try { | 
                                                        
| 218 | 218 | $sth = $this->db->prepare($query);  | 
                                                        
| 219 | 219 |                          $sth->execute(array(':id' => $id)); | 
                                                        
| 220 | -                } catch(PDOException $e) { | 
                                                        |
| 220 | +                } catch (PDOException $e) { | 
                                                        |
| 221 | 221 | echo $e->getMessage();  | 
                                                        
| 222 | 222 | die;  | 
                                                        
| 223 | 223 | }  | 
                                                        
@@ -239,12 +239,12 @@ discard block  | 
                                                    ||
| 239 | 239 |                  date_default_timezone_set('UTC'); | 
                                                        
| 240 | 240 | |
| 241 | 241 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 242 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 242 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 243 | 243 | |
| 244 | 244 |                  try { | 
                                                        
| 245 | 245 | $sth = $this->db->prepare($query);  | 
                                                        
| 246 | 246 |                          $sth->execute(array(':ident' => $ident)); | 
                                                        
| 247 | -                } catch(PDOException $e) { | 
                                                        |
| 247 | +                } catch (PDOException $e) { | 
                                                        |
| 248 | 248 | echo $e->getMessage();  | 
                                                        
| 249 | 249 | die;  | 
                                                        
| 250 | 250 | }  | 
                                                        
@@ -265,12 +265,12 @@ discard block  | 
                                                    ||
| 265 | 265 |                  date_default_timezone_set('UTC'); | 
                                                        
| 266 | 266 | |
| 267 | 267 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 268 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 268 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";  | 
                                                        |
| 269 | 269 | |
| 270 | 270 |                  try { | 
                                                        
| 271 | 271 | $sth = $this->db->prepare($query);  | 
                                                        
| 272 | 272 |                          $sth->execute(array(':id' => $id)); | 
                                                        
| 273 | -                } catch(PDOException $e) { | 
                                                        |
| 273 | +                } catch (PDOException $e) { | 
                                                        |
| 274 | 274 | echo $e->getMessage();  | 
                                                        
| 275 | 275 | die;  | 
                                                        
| 276 | 276 | }  | 
                                                        
@@ -291,12 +291,12 @@ discard block  | 
                                                    ||
| 291 | 291 |                  date_default_timezone_set('UTC'); | 
                                                        
| 292 | 292 | |
| 293 | 293 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 294 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 294 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";  | 
                                                        |
| 295 | 295 | |
| 296 | 296 |                  try { | 
                                                        
| 297 | 297 | $sth = $this->db->prepare($query);  | 
                                                        
| 298 | 298 |                          $sth->execute(array(':id' => $id)); | 
                                                        
| 299 | -                } catch(PDOException $e) { | 
                                                        |
| 299 | +                } catch (PDOException $e) { | 
                                                        |
| 300 | 300 | echo $e->getMessage();  | 
                                                        
| 301 | 301 | die;  | 
                                                        
| 302 | 302 | }  | 
                                                        
@@ -318,13 +318,13 @@ discard block  | 
                                                    ||
| 318 | 318 |                  date_default_timezone_set('UTC'); | 
                                                        
| 319 | 319 | |
| 320 | 320 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 321 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 321 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";  | 
                                                        |
| 322 | 322 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";  | 
                                                        
| 323 | 323 | |
| 324 | 324 |                  try { | 
                                                        
| 325 | 325 | $sth = $this->db->prepare($query);  | 
                                                        
| 326 | 326 |                          $sth->execute(array(':ident' => $ident)); | 
                                                        
| 327 | -                } catch(PDOException $e) { | 
                                                        |
| 327 | +                } catch (PDOException $e) { | 
                                                        |
| 328 | 328 | echo $e->getMessage();  | 
                                                        
| 329 | 329 | die;  | 
                                                        
| 330 | 330 | }  | 
                                                        
@@ -341,13 +341,13 @@ discard block  | 
                                                    ||
| 341 | 341 | * @return Array the spotter information  | 
                                                        
| 342 | 342 | *  | 
                                                        
| 343 | 343 | */  | 
                                                        
| 344 | - public function getMarineArchiveData($ident,$fammarine_id,$date)  | 
                                                        |
| 344 | + public function getMarineArchiveData($ident, $fammarine_id, $date)  | 
                                                        |
| 345 | 345 |          { | 
                                                        
| 346 | 346 | $Marine = new Marine($this->db);  | 
                                                        
| 347 | 347 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 348 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";  | 
                                                        |
| 348 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";  | 
                                                        |
| 349 | 349 | |
| 350 | -                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); | 
                                                        |
| 350 | +                $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); | 
                                                        |
| 351 | 351 | |
| 352 | 352 | return $spotter_array;  | 
                                                        
| 353 | 353 | }  | 
                                                        
@@ -360,7 +360,7 @@ discard block  | 
                                                    ||
| 360 | 360 |                  try { | 
                                                        
| 361 | 361 | $sth = $this->db->prepare($query);  | 
                                                        
| 362 | 362 | $sth->execute();  | 
                                                        
| 363 | -                } catch(PDOException $e) { | 
                                                        |
| 363 | +                } catch (PDOException $e) { | 
                                                        |
| 364 | 364 | echo $e->getMessage();  | 
                                                        
| 365 | 365 | die;  | 
                                                        
| 366 | 366 | }  | 
                                                        
@@ -372,24 +372,24 @@ discard block  | 
                                                    ||
| 372 | 372 | * @return Array the spotter information  | 
                                                        
| 373 | 373 | *  | 
                                                        
| 374 | 374 | */  | 
                                                        
| 375 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array())  | 
                                                        |
| 375 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array())  | 
                                                        |
| 376 | 376 |          { | 
                                                        
| 377 | 377 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 378 | 378 |                  date_default_timezone_set('UTC'); | 
                                                        
| 379 | 379 | |
| 380 | 380 | $filter_query = '';  | 
                                                        
| 381 | 381 |                  if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        
| 382 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 382 | +                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; | 
                                                        |
| 383 | 383 | }  | 
                                                        
| 384 | 384 | // Use spotter_output also ?  | 
                                                        
| 385 | 385 |                  if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        
| 386 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 386 | +                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 387 | 387 | }  | 
                                                        
| 388 | 388 |                  if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        
| 389 | 389 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        
| 390 | 390 | }  | 
                                                        
| 391 | 391 |                  if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 392 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 392 | +                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; | 
                                                        |
| 393 | 393 | }  | 
                                                        
| 394 | 394 | |
| 395 | 395 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        
@@ -408,14 +408,14 @@ discard block  | 
                                                    ||
| 408 | 408 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id  | 
                                                        
| 409 | 409 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';  | 
                                                        
| 410 | 410 | */  | 
                                                        
| 411 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 411 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 412 | 412 | FROM marine_archive  | 
                                                        
| 413 | 413 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao  | 
                                                        
| 414 | 414 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".'  | 
                                                        
| 415 | 415 | '.$filter_query.' ORDER BY fammarine_id';  | 
                                                        
| 416 | 416 |                  } else { | 
                                                        
| 417 | 417 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';  | 
                                                        
| 418 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 418 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category  | 
                                                        |
| 419 | 419 | FROM marine_archive  | 
                                                        
| 420 | 420 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao  | 
                                                        
| 421 | 421 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'  | 
                                                        
@@ -425,7 +425,7 @@ discard block  | 
                                                    ||
| 425 | 425 |                  try { | 
                                                        
| 426 | 426 | $sth = $this->db->prepare($query);  | 
                                                        
| 427 | 427 | $sth->execute();  | 
                                                        
| 428 | -                } catch(PDOException $e) { | 
                                                        |
| 428 | +                } catch (PDOException $e) { | 
                                                        |
| 429 | 429 | echo $e->getMessage();  | 
                                                        
| 430 | 430 | die;  | 
                                                        
| 431 | 431 | }  | 
                                                        
@@ -440,24 +440,24 @@ discard block  | 
                                                    ||
| 440 | 440 | * @return Array the spotter information  | 
                                                        
| 441 | 441 | *  | 
                                                        
| 442 | 442 | */  | 
                                                        
| 443 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())  | 
                                                        |
| 443 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array())  | 
                                                        |
| 444 | 444 |          { | 
                                                        
| 445 | 445 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 446 | 446 |                  date_default_timezone_set('UTC'); | 
                                                        
| 447 | 447 | |
| 448 | 448 | $filter_query = '';  | 
                                                        
| 449 | 449 |                  if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        
| 450 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 450 | +                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; | 
                                                        |
| 451 | 451 | }  | 
                                                        
| 452 | 452 | // Should use spotter_output also ?  | 
                                                        
| 453 | 453 |                  if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        
| 454 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 454 | +                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 455 | 455 | }  | 
                                                        
| 456 | 456 |                  if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        
| 457 | 457 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        
| 458 | 458 | }  | 
                                                        
| 459 | 459 |                  if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 460 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 460 | +                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; | 
                                                        |
| 461 | 461 | }  | 
                                                        
| 462 | 462 | |
| 463 | 463 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        
@@ -467,7 +467,7 @@ discard block  | 
                                                    ||
| 467 | 467 | FROM marine_archive  | 
                                                        
| 468 | 468 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';  | 
                                                        
| 469 | 469 | */  | 
                                                        
| 470 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk  | 
                                                        |
| 470 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk  | 
                                                        |
| 471 | 471 | FROM marine_archive_output  | 
                                                        
| 472 | 472 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao  | 
                                                        
| 473 | 473 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".')  | 
                                                        
@@ -482,7 +482,7 @@ discard block  | 
                                                    ||
| 482 | 482 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'  | 
                                                        
| 483 | 483 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';  | 
                                                        
| 484 | 484 | */  | 
                                                        
| 485 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow  | 
                                                        |
| 485 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow  | 
                                                        |
| 486 | 486 | FROM marine_archive_output  | 
                                                        
| 487 | 487 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao  | 
                                                        
| 488 | 488 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'  | 
                                                        
@@ -494,7 +494,7 @@ discard block  | 
                                                    ||
| 494 | 494 |                  try { | 
                                                        
| 495 | 495 | $sth = $this->db->prepare($query);  | 
                                                        
| 496 | 496 | $sth->execute();  | 
                                                        
| 497 | -                } catch(PDOException $e) { | 
                                                        |
| 497 | +                } catch (PDOException $e) { | 
                                                        |
| 498 | 498 | echo $e->getMessage();  | 
                                                        
| 499 | 499 | die;  | 
                                                        
| 500 | 500 | }  | 
                                                        
@@ -509,23 +509,23 @@ discard block  | 
                                                    ||
| 509 | 509 | * @return Array the spotter information  | 
                                                        
| 510 | 510 | *  | 
                                                        
| 511 | 511 | */  | 
                                                        
| 512 | - public function getLiveMarineCount($begindate,$enddate,$filter = array())  | 
                                                        |
| 512 | + public function getLiveMarineCount($begindate, $enddate, $filter = array())  | 
                                                        |
| 513 | 513 |          { | 
                                                        
| 514 | 514 | global $globalDBdriver, $globalLiveInterval;  | 
                                                        
| 515 | 515 |                  date_default_timezone_set('UTC'); | 
                                                        
| 516 | 516 | |
| 517 | 517 | $filter_query = '';  | 
                                                        
| 518 | 518 |                  if (isset($filter['source']) && !empty($filter['source'])) { | 
                                                        
| 519 | -                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; | 
                                                        |
| 519 | +                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; | 
                                                        |
| 520 | 520 | }  | 
                                                        
| 521 | 521 |                  if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
                                                        
| 522 | -                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 522 | +                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; | 
                                                        |
| 523 | 523 | }  | 
                                                        
| 524 | 524 |                  if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
                                                        
| 525 | 525 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";  | 
                                                        
| 526 | 526 | }  | 
                                                        
| 527 | 527 |                  if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
                                                        
| 528 | -                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
                                                        |
| 528 | +                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; | 
                                                        |
| 529 | 529 | }  | 
                                                        
| 530 | 530 | |
| 531 | 531 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';  | 
                                                        
@@ -540,7 +540,7 @@ discard block  | 
                                                    ||
| 540 | 540 |                  try { | 
                                                        
| 541 | 541 | $sth = $this->db->prepare($query);  | 
                                                        
| 542 | 542 | $sth->execute();  | 
                                                        
| 543 | -                } catch(PDOException $e) { | 
                                                        |
| 543 | +                } catch (PDOException $e) { | 
                                                        |
| 544 | 544 | echo $e->getMessage();  | 
                                                        
| 545 | 545 | die;  | 
                                                        
| 546 | 546 | }  | 
                                                        
@@ -560,7 +560,7 @@ discard block  | 
                                                    ||
| 560 | 560 | * @return Array the spotter information  | 
                                                        
| 561 | 561 | *  | 
                                                        
| 562 | 562 | */  | 
                                                        
| 563 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())  | 
                                                        |
| 563 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())  | 
                                                        |
| 564 | 564 |      { | 
                                                        
| 565 | 565 | global $globalTimezone, $globalDBdriver;  | 
                                                        
| 566 | 566 | require_once(dirname(__FILE__).'/class.Translation.php');  | 
                                                        
@@ -582,7 +582,7 @@ discard block  | 
                                                    ||
| 582 | 582 | |
| 583 | 583 |  		$q_array = explode(" ", $q); | 
                                                        
| 584 | 584 | |
| 585 | -		foreach ($q_array as $q_item){ | 
                                                        |
| 585 | +		foreach ($q_array as $q_item) { | 
                                                        |
| 586 | 586 |  		    $additional_query .= " AND ("; | 
                                                        
| 587 | 587 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";  | 
                                                        
| 588 | 588 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";  | 
                                                        
@@ -614,7 +614,7 @@ discard block  | 
                                                    ||
| 614 | 614 | |
| 615 | 615 | if ($registration != "")  | 
                                                        
| 616 | 616 |  	{ | 
                                                        
| 617 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING);  | 
                                                        |
| 617 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING);  | 
                                                        |
| 618 | 618 | if (!is_string($registration))  | 
                                                        
| 619 | 619 |  	    { | 
                                                        
| 620 | 620 | return false;  | 
                                                        
@@ -625,7 +625,7 @@ discard block  | 
                                                    ||
| 625 | 625 | |
| 626 | 626 | if ($aircraft_icao != "")  | 
                                                        
| 627 | 627 |  	{ | 
                                                        
| 628 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 628 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);  | 
                                                        |
| 629 | 629 | if (!is_string($aircraft_icao))  | 
                                                        
| 630 | 630 |  	    { | 
                                                        
| 631 | 631 | return false;  | 
                                                        
@@ -636,7 +636,7 @@ discard block  | 
                                                    ||
| 636 | 636 | |
| 637 | 637 | if ($aircraft_manufacturer != "")  | 
                                                        
| 638 | 638 |  	{ | 
                                                        
| 639 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);  | 
                                                        |
| 639 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);  | 
                                                        |
| 640 | 640 | if (!is_string($aircraft_manufacturer))  | 
                                                        
| 641 | 641 |  	    { | 
                                                        
| 642 | 642 | return false;  | 
                                                        
@@ -657,7 +657,7 @@ discard block  | 
                                                    ||
| 657 | 657 | |
| 658 | 658 | if ($airline_icao != "")  | 
                                                        
| 659 | 659 |  	{ | 
                                                        
| 660 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);  | 
                                                        |
| 660 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);  | 
                                                        |
| 661 | 661 | if (!is_string($airline_icao))  | 
                                                        
| 662 | 662 |  	    { | 
                                                        
| 663 | 663 | return false;  | 
                                                        
@@ -668,7 +668,7 @@ discard block  | 
                                                    ||
| 668 | 668 | |
| 669 | 669 | if ($airline_country != "")  | 
                                                        
| 670 | 670 |  	{ | 
                                                        
| 671 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 671 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);  | 
                                                        |
| 672 | 672 | if (!is_string($airline_country))  | 
                                                        
| 673 | 673 |  	    { | 
                                                        
| 674 | 674 | return false;  | 
                                                        
@@ -679,7 +679,7 @@ discard block  | 
                                                    ||
| 679 | 679 | |
| 680 | 680 | if ($airline_type != "")  | 
                                                        
| 681 | 681 |  	{ | 
                                                        
| 682 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);  | 
                                                        |
| 682 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);  | 
                                                        |
| 683 | 683 | if (!is_string($airline_type))  | 
                                                        
| 684 | 684 |  	    { | 
                                                        
| 685 | 685 | return false;  | 
                                                        
@@ -701,7 +701,7 @@ discard block  | 
                                                    ||
| 701 | 701 | |
| 702 | 702 | if ($airport != "")  | 
                                                        
| 703 | 703 |  	{ | 
                                                        
| 704 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING);  | 
                                                        |
| 704 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING);  | 
                                                        |
| 705 | 705 | if (!is_string($airport))  | 
                                                        
| 706 | 706 |  	    { | 
                                                        
| 707 | 707 | return false;  | 
                                                        
@@ -712,7 +712,7 @@ discard block  | 
                                                    ||
| 712 | 712 | |
| 713 | 713 | if ($airport_country != "")  | 
                                                        
| 714 | 714 |  	{ | 
                                                        
| 715 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);  | 
                                                        |
| 715 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);  | 
                                                        |
| 716 | 716 | if (!is_string($airport_country))  | 
                                                        
| 717 | 717 |  	    { | 
                                                        
| 718 | 718 | return false;  | 
                                                        
@@ -723,7 +723,7 @@ discard block  | 
                                                    ||
| 723 | 723 | |
| 724 | 724 | if ($callsign != "")  | 
                                                        
| 725 | 725 |  	{ | 
                                                        
| 726 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);  | 
                                                        |
| 726 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);  | 
                                                        |
| 727 | 727 | if (!is_string($callsign))  | 
                                                        
| 728 | 728 |  	    { | 
                                                        
| 729 | 729 | return false;  | 
                                                        
@@ -731,7 +731,7 @@ discard block  | 
                                                    ||
| 731 | 731 | $translate = $Translation->ident2icao($callsign);  | 
                                                        
| 732 | 732 |  		if ($translate != $callsign) { | 
                                                        
| 733 | 733 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";  | 
                                                        
| 734 | -			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); | 
                                                        |
| 734 | +			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); | 
                                                        |
| 735 | 735 |  		} else { | 
                                                        
| 736 | 736 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";  | 
                                                        
| 737 | 737 | }  | 
                                                        
@@ -740,7 +740,7 @@ discard block  | 
                                                    ||
| 740 | 740 | |
| 741 | 741 | if ($owner != "")  | 
                                                        
| 742 | 742 |  	{ | 
                                                        
| 743 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING);  | 
                                                        |
| 743 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING);  | 
                                                        |
| 744 | 744 | if (!is_string($owner))  | 
                                                        
| 745 | 745 |  	    { | 
                                                        
| 746 | 746 | return false;  | 
                                                        
@@ -751,7 +751,7 @@ discard block  | 
                                                    ||
| 751 | 751 | |
| 752 | 752 | if ($pilot_name != "")  | 
                                                        
| 753 | 753 |  	{ | 
                                                        
| 754 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);  | 
                                                        |
| 754 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);  | 
                                                        |
| 755 | 755 | if (!is_string($pilot_name))  | 
                                                        
| 756 | 756 |  	    { | 
                                                        
| 757 | 757 | return false;  | 
                                                        
@@ -762,7 +762,7 @@ discard block  | 
                                                    ||
| 762 | 762 | |
| 763 | 763 | if ($pilot_id != "")  | 
                                                        
| 764 | 764 |  	{ | 
                                                        
| 765 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 765 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 766 | 766 | if (!is_string($pilot_id))  | 
                                                        
| 767 | 767 |  	    { | 
                                                        
| 768 | 768 | return false;  | 
                                                        
@@ -773,7 +773,7 @@ discard block  | 
                                                    ||
| 773 | 773 | |
| 774 | 774 | if ($departure_airport_route != "")  | 
                                                        
| 775 | 775 |  	{ | 
                                                        
| 776 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 776 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);  | 
                                                        |
| 777 | 777 | if (!is_string($departure_airport_route))  | 
                                                        
| 778 | 778 |  	    { | 
                                                        
| 779 | 779 | return false;  | 
                                                        
@@ -784,7 +784,7 @@ discard block  | 
                                                    ||
| 784 | 784 | |
| 785 | 785 | if ($arrival_airport_route != "")  | 
                                                        
| 786 | 786 |  	{ | 
                                                        
| 787 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);  | 
                                                        |
| 787 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);  | 
                                                        |
| 788 | 788 | if (!is_string($arrival_airport_route))  | 
                                                        
| 789 | 789 |  	    { | 
                                                        
| 790 | 790 | return false;  | 
                                                        
@@ -797,8 +797,8 @@ discard block  | 
                                                    ||
| 797 | 797 |  	{ | 
                                                        
| 798 | 798 |  	    $altitude_array = explode(",", $altitude); | 
                                                        
| 799 | 799 | |
| 800 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 801 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 800 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 801 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);  | 
                                                        |
| 802 | 802 | |
| 803 | 803 | |
| 804 | 804 | if ($altitude_array[1] != "")  | 
                                                        
@@ -816,8 +816,8 @@ discard block  | 
                                                    ||
| 816 | 816 |  	{ | 
                                                        
| 817 | 817 |  	    $date_array = explode(",", $date_posted); | 
                                                        
| 818 | 818 | |
| 819 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);  | 
                                                        |
| 820 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);  | 
                                                        |
| 819 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);  | 
                                                        |
| 820 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);  | 
                                                        |
| 821 | 821 | |
| 822 | 822 |  	    if ($globalTimezone != '') { | 
                                                        
| 823 | 823 | date_default_timezone_set($globalTimezone);  | 
                                                        
@@ -849,8 +849,8 @@ discard block  | 
                                                    ||
| 849 | 849 |  	{ | 
                                                        
| 850 | 850 |  	    $limit_array = explode(",", $limit); | 
                                                        
| 851 | 851 | |
| 852 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 853 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 852 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 853 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 854 | 854 | |
| 855 | 855 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 856 | 856 |  	    { | 
                                                        
@@ -861,8 +861,8 @@ discard block  | 
                                                    ||
| 861 | 861 | |
| 862 | 862 | |
| 863 | 863 |  	if ($origLat != "" && $origLon != "" && $dist != "") { | 
                                                        
| 864 | - $dist = number_format($dist*0.621371,2,'.','');  | 
                                                        |
| 865 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(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  | 
                                                        |
| 864 | + $dist = number_format($dist*0.621371, 2, '.', '');  | 
                                                        |
| 865 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(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  | 
                                                        |
| 866 | 866 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69))  | 
                                                        
| 867 | 867 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(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." ORDER BY distance";  | 
                                                        
| 868 | 868 |  	} else { | 
                                                        
@@ -879,12 +879,12 @@ discard block  | 
                                                    ||
| 879 | 879 | $additional_query .= " AND (marine_archive_output.waypoints <> '')";  | 
                                                        
| 880 | 880 | }  | 
                                                        
| 881 | 881 | |
| 882 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output  | 
                                                        |
| 882 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output  | 
                                                        |
| 883 | 883 | WHERE marine_archive_output.ident <> ''  | 
                                                        
| 884 | 884 | ".$additional_query."  | 
                                                        
| 885 | 885 | ".$filter_query.$orderby_query;  | 
                                                        
| 886 | 886 | }  | 
                                                        
| 887 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);  | 
                                                        |
| 887 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);  | 
                                                        |
| 888 | 888 | |
| 889 | 889 | return $spotter_array;  | 
                                                        
| 890 | 890 | }  | 
                                                        
@@ -901,7 +901,7 @@ discard block  | 
                                                    ||
| 901 | 901 |                  try { | 
                                                        
| 902 | 902 | $sth = $this->db->prepare($query);  | 
                                                        
| 903 | 903 | $sth->execute();  | 
                                                        
| 904 | -                } catch(PDOException $e) { | 
                                                        |
| 904 | +                } catch (PDOException $e) { | 
                                                        |
| 905 | 905 | return "error";  | 
                                                        
| 906 | 906 | }  | 
                                                        
| 907 | 907 | }  | 
                                                        
@@ -938,8 +938,8 @@ discard block  | 
                                                    ||
| 938 | 938 |  	{ | 
                                                        
| 939 | 939 |  	    $limit_array = explode(",", $limit); | 
                                                        
| 940 | 940 | |
| 941 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 942 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 941 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 942 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 943 | 943 | |
| 944 | 944 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 945 | 945 |  	    { | 
                                                        
@@ -980,7 +980,7 @@ discard block  | 
                                                    ||
| 980 | 980 | $query_values = array();  | 
                                                        
| 981 | 981 | $limit_query = '';  | 
                                                        
| 982 | 982 | $additional_query = '';  | 
                                                        
| 983 | - $filter_query = $this->getFilter($filter,true,true);  | 
                                                        |
| 983 | + $filter_query = $this->getFilter($filter, true, true);  | 
                                                        |
| 984 | 984 | |
| 985 | 985 | if ($owner != "")  | 
                                                        
| 986 | 986 |  	{ | 
                                                        
@@ -997,8 +997,8 @@ discard block  | 
                                                    ||
| 997 | 997 |  	{ | 
                                                        
| 998 | 998 |  	    $limit_array = explode(",", $limit); | 
                                                        
| 999 | 999 | |
| 1000 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1001 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1000 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1001 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1002 | 1002 | |
| 1003 | 1003 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 1004 | 1004 |  	    { | 
                                                        
@@ -1038,7 +1038,7 @@ discard block  | 
                                                    ||
| 1038 | 1038 | $query_values = array();  | 
                                                        
| 1039 | 1039 | $limit_query = '';  | 
                                                        
| 1040 | 1040 | $additional_query = '';  | 
                                                        
| 1041 | - $filter_query = $this->getFilter($filter,true,true);  | 
                                                        |
| 1041 | + $filter_query = $this->getFilter($filter, true, true);  | 
                                                        |
| 1042 | 1042 | |
| 1043 | 1043 | if ($pilot != "")  | 
                                                        
| 1044 | 1044 |  	{ | 
                                                        
@@ -1050,8 +1050,8 @@ discard block  | 
                                                    ||
| 1050 | 1050 |  	{ | 
                                                        
| 1051 | 1051 |  	    $limit_array = explode(",", $limit); | 
                                                        
| 1052 | 1052 | |
| 1053 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1054 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1053 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1054 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1055 | 1055 | |
| 1056 | 1056 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 1057 | 1057 |  	    { | 
                                                        
@@ -1081,7 +1081,7 @@ discard block  | 
                                                    ||
| 1081 | 1081 | * @return Array the airline country list  | 
                                                        
| 1082 | 1082 | *  | 
                                                        
| 1083 | 1083 | */  | 
                                                        
| 1084 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1084 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')  | 
                                                        |
| 1085 | 1085 |      { | 
                                                        
| 1086 | 1086 | global $globalDBdriver;  | 
                                                        
| 1087 | 1087 | /*  | 
                                                        
@@ -1110,7 +1110,7 @@ discard block  | 
                                                    ||
| 1110 | 1110 | $flight_array = array();  | 
                                                        
| 1111 | 1111 | $temp_array = array();  | 
                                                        
| 1112 | 1112 | |
| 1113 | - while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 1113 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 1114 | 1114 |  	{ | 
                                                        
| 1115 | 1115 | $temp_array['flight_count'] = $row['nb'];  | 
                                                        
| 1116 | 1116 | $temp_array['flight_country'] = $row['name'];  | 
                                                        
@@ -1127,7 +1127,7 @@ discard block  | 
                                                    ||
| 1127 | 1127 | * @return Array the airline country list  | 
                                                        
| 1128 | 1128 | *  | 
                                                        
| 1129 | 1129 | */  | 
                                                        
| 1130 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')  | 
                                                        |
| 1130 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')  | 
                                                        |
| 1131 | 1131 |      { | 
                                                        
| 1132 | 1132 | global $globalDBdriver;  | 
                                                        
| 1133 | 1133 | /*  | 
                                                        
@@ -1156,7 +1156,7 @@ discard block  | 
                                                    ||
| 1156 | 1156 | $flight_array = array();  | 
                                                        
| 1157 | 1157 | $temp_array = array();  | 
                                                        
| 1158 | 1158 | |
| 1159 | - while($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 1159 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC))  | 
                                                        |
| 1160 | 1160 |  	{ | 
                                                        
| 1161 | 1161 | $temp_array['airline_icao'] = $row['airline_icao'];  | 
                                                        
| 1162 | 1162 | $temp_array['flight_count'] = $row['nb'];  | 
                                                        
@@ -1174,14 +1174,14 @@ discard block  | 
                                                    ||
| 1174 | 1174 | * @return Array the spotter information  | 
                                                        
| 1175 | 1175 | *  | 
                                                        
| 1176 | 1176 | */  | 
                                                        
| 1177 | - public function getDateArchiveMarineDataById($id,$date)  | 
                                                        |
| 1177 | + public function getDateArchiveMarineDataById($id, $date)  | 
                                                        |
| 1178 | 1178 |      { | 
                                                        
| 1179 | 1179 | $Marine = new Marine($this->db);  | 
                                                        
| 1180 | 1180 |  	date_default_timezone_set('UTC'); | 
                                                        
| 1181 | 1181 | $id = filter_var($id, FILTER_SANITIZE_STRING);  | 
                                                        
| 1182 | 1182 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';  | 
                                                        
| 1183 | -	$date = date('c',$date); | 
                                                        |
| 1184 | -	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); | 
                                                        |
| 1183 | +	$date = date('c', $date); | 
                                                        |
| 1184 | +	$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); | 
                                                        |
| 1185 | 1185 | return $spotter_array;  | 
                                                        
| 1186 | 1186 | }  | 
                                                        
| 1187 | 1187 | |
@@ -1191,14 +1191,14 @@ discard block  | 
                                                    ||
| 1191 | 1191 | * @return Array the spotter information  | 
                                                        
| 1192 | 1192 | *  | 
                                                        
| 1193 | 1193 | */  | 
                                                        
| 1194 | - public function getDateArchiveMarineDataByIdent($ident,$date)  | 
                                                        |
| 1194 | + public function getDateArchiveMarineDataByIdent($ident, $date)  | 
                                                        |
| 1195 | 1195 |      { | 
                                                        
| 1196 | 1196 | $Marine = new Marine($this->db);  | 
                                                        
| 1197 | 1197 |  	date_default_timezone_set('UTC'); | 
                                                        
| 1198 | 1198 | $ident = filter_var($ident, FILTER_SANITIZE_STRING);  | 
                                                        
| 1199 | 1199 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';  | 
                                                        
| 1200 | -	$date = date('c',$date); | 
                                                        |
| 1201 | -	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); | 
                                                        |
| 1200 | +	$date = date('c', $date); | 
                                                        |
| 1201 | +	$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); | 
                                                        |
| 1202 | 1202 | return $spotter_array;  | 
                                                        
| 1203 | 1203 | }  | 
                                                        
| 1204 | 1204 | |
@@ -1208,7 +1208,7 @@ discard block  | 
                                                    ||
| 1208 | 1208 | * @return Array the spotter information  | 
                                                        
| 1209 | 1209 | *  | 
                                                        
| 1210 | 1210 | */  | 
                                                        
| 1211 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())  | 
                                                        |
| 1211 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())  | 
                                                        |
| 1212 | 1212 |      { | 
                                                        
| 1213 | 1213 | global $global_query;  | 
                                                        
| 1214 | 1214 | $Marine = new Marine();  | 
                                                        
@@ -1216,7 +1216,7 @@ discard block  | 
                                                    ||
| 1216 | 1216 | $query_values = array();  | 
                                                        
| 1217 | 1217 | $limit_query = '';  | 
                                                        
| 1218 | 1218 | $additional_query = '';  | 
                                                        
| 1219 | - $filter_query = $this->getFilter($filters,true,true);  | 
                                                        |
| 1219 | + $filter_query = $this->getFilter($filters, true, true);  | 
                                                        |
| 1220 | 1220 | |
| 1221 | 1221 | if ($airport != "")  | 
                                                        
| 1222 | 1222 |  	{ | 
                                                        
@@ -1233,8 +1233,8 @@ discard block  | 
                                                    ||
| 1233 | 1233 |  	{ | 
                                                        
| 1234 | 1234 |  	    $limit_array = explode(",", $limit); | 
                                                        
| 1235 | 1235 | |
| 1236 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1237 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1236 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1237 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);  | 
                                                        |
| 1238 | 1238 | |
| 1239 | 1239 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0)  | 
                                                        
| 1240 | 1240 |  	    { | 
                                                        
@@ -605,7 +605,9 @@ discard block  | 
                                                    ||
| 605 | 605 | $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";  | 
                                                        
| 606 | 606 | $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";  | 
                                                        
| 607 | 607 | $translate = $Translation->ident2icao($q_item);  | 
                                                        
| 608 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";  | 
                                                        |
| 608 | +		    if ($translate != $q_item) { | 
                                                        |
| 609 | + $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";  | 
                                                        |
| 610 | + }  | 
                                                        |
| 609 | 611 | $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";  | 
                                                        
| 610 | 612 | $additional_query .= ")";  | 
                                                        
| 611 | 613 | }  | 
                                                        
@@ -823,7 +825,9 @@ discard block  | 
                                                    ||
| 823 | 825 | date_default_timezone_set($globalTimezone);  | 
                                                        
| 824 | 826 | $datetime = new DateTime();  | 
                                                        
| 825 | 827 |  		$offset = $datetime->format('P'); | 
                                                        
| 826 | - } else $offset = '+00:00';  | 
                                                        |
| 828 | +	    } else { | 
                                                        |
| 829 | + $offset = '+00:00';  | 
                                                        |
| 830 | + }  | 
                                                        |
| 827 | 831 | |
| 828 | 832 | |
| 829 | 833 | if ($date_array[1] != "")  | 
                                                        
@@ -1099,9 +1103,13 @@ discard block  | 
                                                    ||
| 1099 | 1103 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        
| 1100 | 1104 | }  | 
                                                        
| 1101 | 1105 | }  | 
                                                        
| 1102 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";  | 
                                                        |
| 1106 | +                if ($sincedate != '') { | 
                                                        |
| 1107 | + $query .= "AND date > '".$sincedate."' ";  | 
                                                        |
| 1108 | + }  | 
                                                        |
| 1103 | 1109 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";  | 
                                                        
| 1104 | - if ($limit) $query .= " LIMIT 0,10";  | 
                                                        |
| 1110 | +	if ($limit) { | 
                                                        |
| 1111 | + $query .= " LIMIT 0,10";  | 
                                                        |
| 1112 | + }  | 
                                                        |
| 1105 | 1113 | |
| 1106 | 1114 | |
| 1107 | 1115 | $sth = $this->db->prepare($query);  | 
                                                        
@@ -1145,9 +1153,13 @@ discard block  | 
                                                    ||
| 1145 | 1153 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";  | 
                                                        
| 1146 | 1154 | }  | 
                                                        
| 1147 | 1155 | }  | 
                                                        
| 1148 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";  | 
                                                        |
| 1156 | +                if ($sincedate != '') { | 
                                                        |
| 1157 | + $query .= "AND s.date > '".$sincedate."' ";  | 
                                                        |
| 1158 | + }  | 
                                                        |
| 1149 | 1159 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";  | 
                                                        
| 1150 | - if ($limit) $query .= " LIMIT 0,10";  | 
                                                        |
| 1160 | +	if ($limit) { | 
                                                        |
| 1161 | + $query .= " LIMIT 0,10";  | 
                                                        |
| 1162 | + }  | 
                                                        |
| 1151 | 1163 | |
| 1152 | 1164 | |
| 1153 | 1165 | $sth = $this->db->prepare($query);  |