@@ -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 | |
@@ -496,13 +496,13 @@ discard block |
||
| 496 | 496 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
| 497 | 497 | |
| 498 | 498 | if ( |
| 499 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
| 500 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
| 499 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
| 500 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
| 501 | 501 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
| 502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
| 503 | - || (isset($history) && $history != '' && $history != 'NA' && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 504 | - || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
| 505 | - ) { |
|
| 503 | + || (isset($history) && $history != '' && $history != 'NA' && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 504 | + || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
| 505 | + ) { |
|
| 506 | 506 | if ($tracker) { |
| 507 | 507 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']); |
| 508 | 508 | } elseif ($marine) { |
@@ -555,26 +555,26 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | 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))))) { |
| 558 | - $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 559 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
| 558 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 559 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
| 560 | 560 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
| 561 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
| 561 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
| 562 | 562 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
| 563 | 563 | if (isset($dairport[0]['latitude'])) { |
| 564 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
| 564 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
| 565 | 565 | } |
| 566 | - } |
|
| 567 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
| 566 | + } |
|
| 567 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
| 568 | 568 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
| 569 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
| 569 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
| 570 | 570 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
| 571 | 571 | if (isset($aairport[0]['latitude'])) { |
| 572 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
| 572 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
| 573 | 573 | } |
| 574 | - } |
|
| 575 | - $output_air .= ']}},'; |
|
| 576 | - $output .= $output_air; |
|
| 577 | - unset($output_air); |
|
| 574 | + } |
|
| 575 | + $output_air .= ']}},'; |
|
| 576 | + $output .= $output_air; |
|
| 577 | + unset($output_air); |
|
| 578 | 578 | } |
| 579 | 579 | } |
| 580 | 580 | $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')); |
|
| 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')); |
|
| 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'); |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
| 244 | 244 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 245 | 245 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
| 246 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
| 246 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
| 247 | 247 | } elseif (isset($spotter_item['aircraft_type'])) { |
| 248 | 248 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
| 249 | 249 | } elseif (!$min) { |
@@ -383,16 +383,16 @@ discard block |
||
| 383 | 383 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
| 384 | 384 | |
| 385 | 385 | if (isset($archivespeed)) { |
| 386 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
| 386 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed); |
|
| 387 | 387 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 388 | 388 | } elseif ($usenextlatlon) { |
| 389 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
| 389 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']); |
|
| 390 | 390 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | if (!$min) $output .= '"image": "'.$image.'",'; |
| 394 | 394 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 395 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
| 395 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
| 396 | 396 | } |
| 397 | 397 | if (isset($spotter_item['image_source_website'])) { |
| 398 | 398 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
| 415 | 415 | } |
| 416 | 416 | if (isset($spotter_item['acars'])) { |
| 417 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
| 417 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
| 418 | 418 | } |
| 419 | 419 | // type when not aircraft ? |
| 420 | 420 | if (isset($spotter_item['type'])) { |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | } |
| 494 | 494 | */ |
| 495 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
| 495 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
| 496 | 496 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
| 497 | 497 | |
| 498 | 498 | if ( |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
| 501 | 501 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
| 502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
| 503 | - || (isset($history) && $history != '' && $history != 'NA' && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 503 | + || (isset($history) && $history != '' && $history != 'NA' && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
| 504 | 504 | || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
| 505 | 505 | ) { |
| 506 | 506 | if ($tracker) { |
@@ -529,9 +529,9 @@ discard block |
||
| 529 | 529 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
| 530 | 530 | } |
| 531 | 531 | $output_history .= '['; |
| 532 | - $output_history .= $spotter_history['longitude'].', '; |
|
| 533 | - $output_history .= $spotter_history['latitude'].', '; |
|
| 534 | - $output_history .= $spotter_history['altitude']*30.48; |
|
| 532 | + $output_history .= $spotter_history['longitude'].', '; |
|
| 533 | + $output_history .= $spotter_history['latitude'].', '; |
|
| 534 | + $output_history .= $spotter_history['altitude']*30.48; |
|
| 535 | 535 | $output_history .= '],'; |
| 536 | 536 | $prev_alt = $alt; |
| 537 | 537 | } else { |
@@ -540,8 +540,8 @@ discard block |
||
| 540 | 540 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
| 541 | 541 | } else $d = true; |
| 542 | 542 | $output_history .= '['; |
| 543 | - $output_history .= $spotter_history['longitude'].', '; |
|
| 544 | - $output_history .= $spotter_history['latitude']; |
|
| 543 | + $output_history .= $spotter_history['longitude'].', '; |
|
| 544 | + $output_history .= $spotter_history['latitude']; |
|
| 545 | 545 | $output_history .= '],'; |
| 546 | 546 | } |
| 547 | 547 | } |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | $output = substr($output, 0, -1); |
| 581 | 581 | $output .= ']'; |
| 582 | 582 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 583 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
| 583 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
| 584 | 584 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
| 585 | 585 | $output .= '"fc": "'.$j.'"'; |
| 586 | 586 | } 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')); |
|
| 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')); |
|
| 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,13 +282,21 @@ 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": "'.$spotter_item['ident'].'",'; |
|
| 238 | - else $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
| 285 | + if ($compress) { |
|
| 286 | + $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
| 287 | + } else { |
|
| 288 | + $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
| 289 | + } |
|
| 239 | 290 | } else { |
| 240 | - if ($compress) $output .= '"c": "NA",'; |
|
| 241 | - else $output .= '"callsign": "NA",'; |
|
| 291 | + if ($compress) { |
|
| 292 | + $output .= '"c": "NA",'; |
|
| 293 | + } else { |
|
| 294 | + $output .= '"callsign": "NA",'; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + if (isset($spotter_item['registration'])) { |
|
| 298 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 242 | 299 | } |
| 243 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 244 | 300 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 245 | 301 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
| 246 | 302 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -253,15 +309,21 @@ discard block |
||
| 253 | 309 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
| 254 | 310 | } |
| 255 | 311 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker) { |
| 256 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
| 257 | - else { |
|
| 312 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
| 313 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 314 | + } else { |
|
| 258 | 315 | $aircraft_icao = $spotter_item['aircraft_icao']; |
| 259 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
| 260 | - else { |
|
| 316 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
| 317 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
| 318 | + } else { |
|
| 261 | 319 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
| 262 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 263 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 264 | - else $spotter_item['aircraft_shadow'] = ''; |
|
| 320 | + if (count($aircraft_info) > 0) { |
|
| 321 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 322 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
| 323 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 324 | + } else { |
|
| 325 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 326 | + } |
|
| 265 | 327 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
| 266 | 328 | } |
| 267 | 329 | } |
@@ -269,73 +331,139 @@ discard block |
||
| 269 | 331 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
| 270 | 332 | if ($tracker) { |
| 271 | 333 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
| 272 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
| 273 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
| 334 | + if ($compress) { |
|
| 335 | + $output .= '"as": "ambulance.png",'; |
|
| 336 | + } else { |
|
| 337 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
| 338 | + } |
|
| 274 | 339 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
| 275 | - if ($compress) $output .= '"as": "police.png",'; |
|
| 276 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
| 340 | + if ($compress) { |
|
| 341 | + $output .= '"as": "police.png",'; |
|
| 342 | + } else { |
|
| 343 | + $output .= '"aircraft_shadow": "police.png",'; |
|
| 344 | + } |
|
| 277 | 345 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
| 278 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 279 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 346 | + if ($compress) { |
|
| 347 | + $output .= '"as": "ship.png",'; |
|
| 348 | + } else { |
|
| 349 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 350 | + } |
|
| 280 | 351 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
| 281 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 282 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 352 | + if ($compress) { |
|
| 353 | + $output .= '"as": "ship.png",'; |
|
| 354 | + } else { |
|
| 355 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 356 | + } |
|
| 283 | 357 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
| 284 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 285 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 358 | + if ($compress) { |
|
| 359 | + $output .= '"as": "ship.png",'; |
|
| 360 | + } else { |
|
| 361 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 362 | + } |
|
| 286 | 363 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
| 287 | - if ($compress) $output .= '"as": "truck.png",'; |
|
| 288 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
| 364 | + if ($compress) { |
|
| 365 | + $output .= '"as": "truck.png",'; |
|
| 366 | + } else { |
|
| 367 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
| 368 | + } |
|
| 289 | 369 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
| 290 | - if ($compress) $output .= '"as": "truck.png",'; |
|
| 291 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
| 370 | + if ($compress) { |
|
| 371 | + $output .= '"as": "truck.png",'; |
|
| 372 | + } else { |
|
| 373 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
| 374 | + } |
|
| 292 | 375 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
| 293 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
| 294 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 376 | + if ($compress) { |
|
| 377 | + $output .= '"as": "aircraft.png",'; |
|
| 378 | + } else { |
|
| 379 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 380 | + } |
|
| 295 | 381 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
| 296 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
| 297 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 382 | + if ($compress) { |
|
| 383 | + $output .= '"as": "aircraft.png",'; |
|
| 384 | + } else { |
|
| 385 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
| 386 | + } |
|
| 298 | 387 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
| 299 | - if ($compress) $output .= '"as": "helico.png",'; |
|
| 300 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
| 388 | + if ($compress) { |
|
| 389 | + $output .= '"as": "helico.png",'; |
|
| 390 | + } else { |
|
| 391 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
| 392 | + } |
|
| 301 | 393 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
| 302 | - if ($compress) $output .= '"as": "rail.png",'; |
|
| 303 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
| 394 | + if ($compress) { |
|
| 395 | + $output .= '"as": "rail.png",'; |
|
| 396 | + } else { |
|
| 397 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
| 398 | + } |
|
| 304 | 399 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
| 305 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
| 306 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
| 400 | + if ($compress) { |
|
| 401 | + $output .= '"as": "firetruck.png",'; |
|
| 402 | + } else { |
|
| 403 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
| 404 | + } |
|
| 307 | 405 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
| 308 | - if ($compress) $output .= '"as": "bus.png",'; |
|
| 309 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
| 406 | + if ($compress) { |
|
| 407 | + $output .= '"as": "bus.png",'; |
|
| 408 | + } else { |
|
| 409 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
| 410 | + } |
|
| 310 | 411 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
| 311 | - if ($compress) $output .= '"as": "phone.png",'; |
|
| 312 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
| 412 | + if ($compress) { |
|
| 413 | + $output .= '"as": "phone.png",'; |
|
| 414 | + } else { |
|
| 415 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
| 416 | + } |
|
| 313 | 417 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
| 314 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
| 315 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
| 418 | + if ($compress) { |
|
| 419 | + $output .= '"as": "jogger.png",'; |
|
| 420 | + } else { |
|
| 421 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
| 422 | + } |
|
| 316 | 423 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
| 317 | - if ($compress) $output .= '"as": "bike.png",'; |
|
| 318 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
| 424 | + if ($compress) { |
|
| 425 | + $output .= '"as": "bike.png",'; |
|
| 426 | + } else { |
|
| 427 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
| 428 | + } |
|
| 319 | 429 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
| 320 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
| 321 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
| 430 | + if ($compress) { |
|
| 431 | + $output .= '"as": "motorcycle.png",'; |
|
| 432 | + } else { |
|
| 433 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
| 434 | + } |
|
| 322 | 435 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
| 323 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
| 324 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
| 436 | + if ($compress) { |
|
| 437 | + $output .= '"as": "balloon.png",'; |
|
| 438 | + } else { |
|
| 439 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
| 440 | + } |
|
| 325 | 441 | } else { |
| 326 | - if ($compress) $output .= '"as": "car.png",'; |
|
| 327 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
| 442 | + if ($compress) { |
|
| 443 | + $output .= '"as": "car.png",'; |
|
| 444 | + } else { |
|
| 445 | + $output .= '"aircraft_shadow": "car.png",'; |
|
| 446 | + } |
|
| 328 | 447 | } |
| 329 | 448 | } elseif ($marine) { |
| 330 | - if ($compress) $output .= '"as": "ship.png",'; |
|
| 331 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
| 449 | + if ($compress) { |
|
| 450 | + $output .= '"as": "ship.png",'; |
|
| 451 | + } else { |
|
| 452 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
| 453 | + } |
|
| 332 | 454 | } else { |
| 333 | - if ($compress) $output .= '"as": "default.png",'; |
|
| 334 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
| 455 | + if ($compress) { |
|
| 456 | + $output .= '"as": "default.png",'; |
|
| 457 | + } else { |
|
| 458 | + $output .= '"aircraft_shadow": "default.png",'; |
|
| 459 | + } |
|
| 335 | 460 | } |
| 336 | 461 | } else { |
| 337 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 338 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 462 | + if ($compress) { |
|
| 463 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 464 | + } else { |
|
| 465 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 466 | + } |
|
| 339 | 467 | } |
| 340 | 468 | if (isset($spotter_item['airline_name'])) { |
| 341 | 469 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -343,8 +471,11 @@ discard block |
||
| 343 | 471 | $output .= '"airline_name": "NA",'; |
| 344 | 472 | } |
| 345 | 473 | if (isset($spotter_item['departure_airport'])) { |
| 346 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 347 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 474 | + if ($compress) { |
|
| 475 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 476 | + } else { |
|
| 477 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 478 | + } |
|
| 348 | 479 | } |
| 349 | 480 | if (isset($spotter_item['departure_airport_city'])) { |
| 350 | 481 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -356,8 +487,11 @@ discard block |
||
| 356 | 487 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
| 357 | 488 | } |
| 358 | 489 | if (isset($spotter_item['arrival_airport'])) { |
| 359 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 360 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 490 | + if ($compress) { |
|
| 491 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 492 | + } else { |
|
| 493 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 494 | + } |
|
| 361 | 495 | } |
| 362 | 496 | if (isset($spotter_item['arrival_airport_city'])) { |
| 363 | 497 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -376,11 +510,17 @@ discard block |
||
| 376 | 510 | } |
| 377 | 511 | |
| 378 | 512 | if (isset($spotter_item['altitude'])) { |
| 379 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 380 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 513 | + if ($compress) { |
|
| 514 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 515 | + } else { |
|
| 516 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 517 | + } |
|
| 518 | + } |
|
| 519 | + if ($compress) { |
|
| 520 | + $output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 521 | + } else { |
|
| 522 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 381 | 523 | } |
| 382 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 383 | - else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 384 | 524 | |
| 385 | 525 | if (isset($archivespeed)) { |
| 386 | 526 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
@@ -390,7 +530,9 @@ discard block |
||
| 390 | 530 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 391 | 531 | } |
| 392 | 532 | |
| 393 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
| 533 | + if (!$min) { |
|
| 534 | + $output .= '"image": "'.$image.'",'; |
|
| 535 | + } |
|
| 394 | 536 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 395 | 537 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
| 396 | 538 | } |
@@ -398,8 +540,11 @@ discard block |
||
| 398 | 540 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
| 399 | 541 | } |
| 400 | 542 | if (isset($spotter_item['squawk'])) { |
| 401 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 402 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 543 | + if ($compress) { |
|
| 544 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 545 | + } else { |
|
| 546 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 547 | + } |
|
| 403 | 548 | } |
| 404 | 549 | if (isset($spotter_item['squawk_usage'])) { |
| 405 | 550 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -418,14 +563,23 @@ discard block |
||
| 418 | 563 | } |
| 419 | 564 | // type when not aircraft ? |
| 420 | 565 | if (isset($spotter_item['type'])) { |
| 421 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
| 422 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
| 566 | + if ($compress) { |
|
| 567 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
| 568 | + } else { |
|
| 569 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
| 570 | + } |
|
| 423 | 571 | } elseif ($marine) { |
| 424 | - if ($compress) $output .= '"t": "ship"'; |
|
| 425 | - else $output .= '"type": "ship"'; |
|
| 572 | + if ($compress) { |
|
| 573 | + $output .= '"t": "ship"'; |
|
| 574 | + } else { |
|
| 575 | + $output .= '"type": "ship"'; |
|
| 576 | + } |
|
| 426 | 577 | } else { |
| 427 | - if ($compress) $output .= '"t": "aircraft"'; |
|
| 428 | - else $output .= '"type": "aircraft"'; |
|
| 578 | + if ($compress) { |
|
| 579 | + $output .= '"t": "aircraft"'; |
|
| 580 | + } else { |
|
| 581 | + $output .= '"type": "aircraft"'; |
|
| 582 | + } |
|
| 429 | 583 | } |
| 430 | 584 | $output .= '},'; |
| 431 | 585 | $output .= '"geometry": {'; |
@@ -493,7 +647,9 @@ discard block |
||
| 493 | 647 | } |
| 494 | 648 | */ |
| 495 | 649 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
| 496 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
| 650 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
| 651 | + $history = $_COOKIE['history']; |
|
| 652 | + } |
|
| 497 | 653 | |
| 498 | 654 | if ( |
| 499 | 655 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -525,8 +681,11 @@ discard block |
||
| 525 | 681 | $output_history .= ']}},'; |
| 526 | 682 | $output .= $output_history; |
| 527 | 683 | } |
| 528 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 529 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 684 | + if ($compress) { |
|
| 685 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 686 | + } else { |
|
| 687 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 688 | + } |
|
| 530 | 689 | } |
| 531 | 690 | $output_history .= '['; |
| 532 | 691 | $output_history .= $spotter_history['longitude'].', '; |
@@ -536,9 +695,14 @@ discard block |
||
| 536 | 695 | $prev_alt = $alt; |
| 537 | 696 | } else { |
| 538 | 697 | if ($d == false) { |
| 539 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 540 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 541 | - } else $d = true; |
|
| 698 | + if ($compress) { |
|
| 699 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 700 | + } else { |
|
| 701 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 702 | + } |
|
| 703 | + } else { |
|
| 704 | + $d = true; |
|
| 705 | + } |
|
| 542 | 706 | $output_history .= '['; |
| 543 | 707 | $output_history .= $spotter_history['longitude'].', '; |
| 544 | 708 | $output_history .= $spotter_history['latitude']; |
@@ -581,7 +745,9 @@ discard block |
||
| 581 | 745 | $output .= ']'; |
| 582 | 746 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 583 | 747 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
| 584 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 748 | + if (isset($begindate)) { |
|
| 749 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 750 | + } |
|
| 585 | 751 | $output .= '"fc": "'.$j.'"'; |
| 586 | 752 | } else { |
| 587 | 753 | $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(); |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | - * Gets all the spotter information based on the latest data entry |
|
| 132 | - * |
|
| 133 | - * @return Array the spotter information |
|
| 134 | - * |
|
| 135 | - */ |
|
| 131 | + * Gets all the spotter information based on the latest data entry |
|
| 132 | + * |
|
| 133 | + * @return Array the spotter information |
|
| 134 | + * |
|
| 135 | + */ |
|
| 136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
| 137 | 137 | { |
| 138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Gets Minimal Live Spotter data |
|
| 178 | - * |
|
| 179 | - * @return Array the spotter information |
|
| 180 | - * |
|
| 181 | - */ |
|
| 177 | + * Gets Minimal Live Spotter data |
|
| 178 | + * |
|
| 179 | + * @return Array the spotter information |
|
| 180 | + * |
|
| 181 | + */ |
|
| 182 | 182 | public function getMinLiveSpotterData($filter = array()) |
| 183 | 183 | { |
| 184 | 184 | global $globalDBdriver, $globalLiveInterval; |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 235 | - * |
|
| 236 | - * @return Array the spotter information |
|
| 237 | - * |
|
| 238 | - */ |
|
| 234 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 235 | + * |
|
| 236 | + * @return Array the spotter information |
|
| 237 | + * |
|
| 238 | + */ |
|
| 239 | 239 | public function getMinLastLiveSpotterData($filter = array()) |
| 240 | 240 | { |
| 241 | 241 | global $globalDBdriver, $globalLiveInterval; |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 254 | 254 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 255 | 255 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 256 | - } else { |
|
| 256 | + } else { |
|
| 257 | 257 | /* |
| 258 | 258 | $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 259 | 259 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | // echo $query; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - try { |
|
| 268 | + try { |
|
| 269 | 269 | $sth = $this->db->prepare($query); |
| 270 | 270 | $sth->execute(); |
| 271 | 271 | } catch(PDOException $e) { |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | - * Gets number of latest data entry |
|
| 281 | - * |
|
| 282 | - * @return String number of entry |
|
| 283 | - * |
|
| 284 | - */ |
|
| 280 | + * Gets number of latest data entry |
|
| 281 | + * |
|
| 282 | + * @return String number of entry |
|
| 283 | + * |
|
| 284 | + */ |
|
| 285 | 285 | public function getLiveSpotterCount($filter = array()) |
| 286 | 286 | { |
| 287 | 287 | global $globalDBdriver, $globalLiveInterval; |
@@ -308,11 +308,11 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
| 311 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 312 | - * |
|
| 313 | - * @return Array the spotter information |
|
| 314 | - * |
|
| 315 | - */ |
|
| 311 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 312 | + * |
|
| 313 | + * @return Array the spotter information |
|
| 314 | + * |
|
| 315 | + */ |
|
| 316 | 316 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 317 | 317 | { |
| 318 | 318 | global $globalDBdriver, $globalLiveInterval; |
@@ -337,11 +337,11 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /** |
| 340 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 341 | - * |
|
| 342 | - * @return Array the spotter information |
|
| 343 | - * |
|
| 344 | - */ |
|
| 340 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 341 | + * |
|
| 342 | + * @return Array the spotter information |
|
| 343 | + * |
|
| 344 | + */ |
|
| 345 | 345 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
| 346 | 346 | { |
| 347 | 347 | global $globalDBdriver, $globalLiveInterval; |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /** |
| 385 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 386 | - * |
|
| 387 | - * @return Array the spotter information |
|
| 388 | - * |
|
| 389 | - */ |
|
| 385 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 386 | + * |
|
| 387 | + * @return Array the spotter information |
|
| 388 | + * |
|
| 389 | + */ |
|
| 390 | 390 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 391 | 391 | { |
| 392 | 392 | $Spotter = new Spotter($this->db); |
@@ -396,145 +396,145 @@ discard block |
||
| 396 | 396 | return false; |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | - if ($lng != '') |
|
| 400 | - { |
|
| 401 | - if (!is_numeric($lng)) |
|
| 402 | - { |
|
| 403 | - return false; |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - if ($radius != '') |
|
| 408 | - { |
|
| 409 | - if (!is_numeric($radius)) |
|
| 410 | - { |
|
| 411 | - return false; |
|
| 412 | - } |
|
| 413 | - } |
|
| 399 | + if ($lng != '') |
|
| 400 | + { |
|
| 401 | + if (!is_numeric($lng)) |
|
| 402 | + { |
|
| 403 | + return false; |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + if ($radius != '') |
|
| 408 | + { |
|
| 409 | + if (!is_numeric($radius)) |
|
| 410 | + { |
|
| 411 | + return false; |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | 414 | $additional_query = ''; |
| 415 | - if ($interval != '') |
|
| 416 | - { |
|
| 417 | - if (!is_string($interval)) |
|
| 418 | - { |
|
| 419 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 420 | - return false; |
|
| 421 | - } else { |
|
| 422 | - if ($interval == '1m') |
|
| 423 | - { |
|
| 424 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 425 | - } else if ($interval == '15m'){ |
|
| 426 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - } else { |
|
| 430 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 415 | + if ($interval != '') |
|
| 416 | + { |
|
| 417 | + if (!is_string($interval)) |
|
| 418 | + { |
|
| 419 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 420 | + return false; |
|
| 421 | + } else { |
|
| 422 | + if ($interval == '1m') |
|
| 423 | + { |
|
| 424 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 425 | + } else if ($interval == '15m'){ |
|
| 426 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + } else { |
|
| 430 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 434 | 434 | WHERE spotter_live.latitude <> '' |
| 435 | 435 | AND spotter_live.longitude <> '' |
| 436 | 436 | ".$additional_query." |
| 437 | 437 | HAVING distance < :radius |
| 438 | 438 | ORDER BY distance"; |
| 439 | 439 | |
| 440 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 440 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 441 | 441 | |
| 442 | - return $spotter_array; |
|
| 443 | - } |
|
| 442 | + return $spotter_array; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | 445 | |
| 446 | - /** |
|
| 447 | - * Gets all the spotter information based on a particular callsign |
|
| 448 | - * |
|
| 449 | - * @return Array the spotter information |
|
| 450 | - * |
|
| 451 | - */ |
|
| 446 | + /** |
|
| 447 | + * Gets all the spotter information based on a particular callsign |
|
| 448 | + * |
|
| 449 | + * @return Array the spotter information |
|
| 450 | + * |
|
| 451 | + */ |
|
| 452 | 452 | public function getLastLiveSpotterDataByIdent($ident) |
| 453 | 453 | { |
| 454 | 454 | $Spotter = new Spotter($this->db); |
| 455 | 455 | date_default_timezone_set('UTC'); |
| 456 | 456 | |
| 457 | 457 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 458 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 458 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 459 | 459 | |
| 460 | 460 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 461 | 461 | |
| 462 | 462 | return $spotter_array; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - /** |
|
| 466 | - * Gets all the spotter information based on a particular callsign |
|
| 467 | - * |
|
| 468 | - * @return Array the spotter information |
|
| 469 | - * |
|
| 470 | - */ |
|
| 465 | + /** |
|
| 466 | + * Gets all the spotter information based on a particular callsign |
|
| 467 | + * |
|
| 468 | + * @return Array the spotter information |
|
| 469 | + * |
|
| 470 | + */ |
|
| 471 | 471 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 472 | 472 | { |
| 473 | 473 | $Spotter = new Spotter($this->db); |
| 474 | 474 | date_default_timezone_set('UTC'); |
| 475 | 475 | |
| 476 | 476 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 477 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 477 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 478 | 478 | |
| 479 | - $date = date('c',$date); |
|
| 479 | + $date = date('c',$date); |
|
| 480 | 480 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 481 | 481 | |
| 482 | 482 | return $spotter_array; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - /** |
|
| 486 | - * Gets last spotter information based on a particular callsign |
|
| 487 | - * |
|
| 488 | - * @return Array the spotter information |
|
| 489 | - * |
|
| 490 | - */ |
|
| 485 | + /** |
|
| 486 | + * Gets last spotter information based on a particular callsign |
|
| 487 | + * |
|
| 488 | + * @return Array the spotter information |
|
| 489 | + * |
|
| 490 | + */ |
|
| 491 | 491 | public function getLastLiveSpotterDataById($id) |
| 492 | 492 | { |
| 493 | 493 | $Spotter = new Spotter($this->db); |
| 494 | 494 | date_default_timezone_set('UTC'); |
| 495 | 495 | |
| 496 | 496 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 497 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 497 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 498 | 498 | |
| 499 | 499 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
| 500 | 500 | |
| 501 | 501 | return $spotter_array; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - /** |
|
| 505 | - * Gets last spotter information based on a particular callsign |
|
| 506 | - * |
|
| 507 | - * @return Array the spotter information |
|
| 508 | - * |
|
| 509 | - */ |
|
| 504 | + /** |
|
| 505 | + * Gets last spotter information based on a particular callsign |
|
| 506 | + * |
|
| 507 | + * @return Array the spotter information |
|
| 508 | + * |
|
| 509 | + */ |
|
| 510 | 510 | public function getDateLiveSpotterDataById($id,$date) |
| 511 | 511 | { |
| 512 | 512 | $Spotter = new Spotter($this->db); |
| 513 | 513 | date_default_timezone_set('UTC'); |
| 514 | 514 | |
| 515 | 515 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 516 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 517 | - $date = date('c',$date); |
|
| 516 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 517 | + $date = date('c',$date); |
|
| 518 | 518 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 519 | 519 | |
| 520 | 520 | return $spotter_array; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - /** |
|
| 524 | - * Gets altitude information based on a particular callsign |
|
| 525 | - * |
|
| 526 | - * @return Array the spotter information |
|
| 527 | - * |
|
| 528 | - */ |
|
| 523 | + /** |
|
| 524 | + * Gets altitude information based on a particular callsign |
|
| 525 | + * |
|
| 526 | + * @return Array the spotter information |
|
| 527 | + * |
|
| 528 | + */ |
|
| 529 | 529 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 530 | 530 | { |
| 531 | 531 | |
| 532 | 532 | date_default_timezone_set('UTC'); |
| 533 | 533 | |
| 534 | 534 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 535 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 535 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 536 | 536 | |
| 537 | - try { |
|
| 537 | + try { |
|
| 538 | 538 | |
| 539 | 539 | $sth = $this->db->prepare($query); |
| 540 | 540 | $sth->execute(array(':ident' => $ident)); |
@@ -547,12 +547,12 @@ discard block |
||
| 547 | 547 | return $spotter_array; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - /** |
|
| 551 | - * Gets all the spotter information based on a particular id |
|
| 552 | - * |
|
| 553 | - * @return Array the spotter information |
|
| 554 | - * |
|
| 555 | - */ |
|
| 550 | + /** |
|
| 551 | + * Gets all the spotter information based on a particular id |
|
| 552 | + * |
|
| 553 | + * @return Array the spotter information |
|
| 554 | + * |
|
| 555 | + */ |
|
| 556 | 556 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 557 | 557 | { |
| 558 | 558 | global $globalDBdriver, $globalLiveInterval; |
@@ -580,18 +580,18 @@ discard block |
||
| 580 | 580 | return $spotter_array; |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | - /** |
|
| 584 | - * Gets all the spotter information based on a particular ident |
|
| 585 | - * |
|
| 586 | - * @return Array the spotter information |
|
| 587 | - * |
|
| 588 | - */ |
|
| 583 | + /** |
|
| 584 | + * Gets all the spotter information based on a particular ident |
|
| 585 | + * |
|
| 586 | + * @return Array the spotter information |
|
| 587 | + * |
|
| 588 | + */ |
|
| 589 | 589 | public function getAllLiveSpotterDataByIdent($ident) |
| 590 | 590 | { |
| 591 | 591 | date_default_timezone_set('UTC'); |
| 592 | 592 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 593 | 593 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 594 | - try { |
|
| 594 | + try { |
|
| 595 | 595 | |
| 596 | 596 | $sth = $this->db->prepare($query); |
| 597 | 597 | $sth->execute(array(':ident' => $ident)); |
@@ -605,23 +605,23 @@ discard block |
||
| 605 | 605 | |
| 606 | 606 | |
| 607 | 607 | /** |
| 608 | - * Deletes all info in the table |
|
| 609 | - * |
|
| 610 | - * @return String success or false |
|
| 611 | - * |
|
| 612 | - */ |
|
| 608 | + * Deletes all info in the table |
|
| 609 | + * |
|
| 610 | + * @return String success or false |
|
| 611 | + * |
|
| 612 | + */ |
|
| 613 | 613 | public function deleteLiveSpotterData() |
| 614 | 614 | { |
| 615 | 615 | global $globalDBdriver; |
| 616 | 616 | if ($globalDBdriver == 'mysql') { |
| 617 | 617 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 618 | 618 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 619 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 619 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 620 | 620 | } else { |
| 621 | 621 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - try { |
|
| 624 | + try { |
|
| 625 | 625 | |
| 626 | 626 | $sth = $this->db->prepare($query); |
| 627 | 627 | $sth->execute(); |
@@ -633,18 +633,18 @@ discard block |
||
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /** |
| 636 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 637 | - * |
|
| 638 | - * @return String success or false |
|
| 639 | - * |
|
| 640 | - */ |
|
| 636 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 637 | + * |
|
| 638 | + * @return String success or false |
|
| 639 | + * |
|
| 640 | + */ |
|
| 641 | 641 | public function deleteLiveSpotterDataNotUpdated() |
| 642 | 642 | { |
| 643 | 643 | global $globalDBdriver, $globalDebug; |
| 644 | 644 | if ($globalDBdriver == 'mysql') { |
| 645 | 645 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
| 646 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 647 | - try { |
|
| 646 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 647 | + try { |
|
| 648 | 648 | |
| 649 | 649 | $sth = $this->db->prepare($query); |
| 650 | 650 | $sth->execute(); |
@@ -652,8 +652,8 @@ discard block |
||
| 652 | 652 | return "error"; |
| 653 | 653 | } |
| 654 | 654 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 655 | - $i = 0; |
|
| 656 | - $j =0; |
|
| 655 | + $i = 0; |
|
| 656 | + $j =0; |
|
| 657 | 657 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 658 | 658 | foreach($all as $row) |
| 659 | 659 | { |
@@ -661,20 +661,20 @@ discard block |
||
| 661 | 661 | $j++; |
| 662 | 662 | if ($j == 30) { |
| 663 | 663 | if ($globalDebug) echo "."; |
| 664 | - try { |
|
| 664 | + try { |
|
| 665 | 665 | |
| 666 | 666 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 667 | 667 | $sth->execute(); |
| 668 | 668 | } catch(PDOException $e) { |
| 669 | 669 | return "error"; |
| 670 | 670 | } |
| 671 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 672 | - $j = 0; |
|
| 671 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 672 | + $j = 0; |
|
| 673 | 673 | } |
| 674 | 674 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 675 | 675 | } |
| 676 | 676 | if ($i > 0) { |
| 677 | - try { |
|
| 677 | + try { |
|
| 678 | 678 | |
| 679 | 679 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 680 | 680 | $sth->execute(); |
@@ -685,9 +685,9 @@ discard block |
||
| 685 | 685 | return "success"; |
| 686 | 686 | } elseif ($globalDBdriver == 'pgsql') { |
| 687 | 687 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
| 688 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 689 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 690 | - try { |
|
| 688 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 689 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 690 | + try { |
|
| 691 | 691 | |
| 692 | 692 | $sth = $this->db->prepare($query); |
| 693 | 693 | $sth->execute(); |
@@ -731,17 +731,17 @@ discard block |
||
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | /** |
| 734 | - * Deletes all info in the table for an ident |
|
| 735 | - * |
|
| 736 | - * @return String success or false |
|
| 737 | - * |
|
| 738 | - */ |
|
| 734 | + * Deletes all info in the table for an ident |
|
| 735 | + * |
|
| 736 | + * @return String success or false |
|
| 737 | + * |
|
| 738 | + */ |
|
| 739 | 739 | public function deleteLiveSpotterDataByIdent($ident) |
| 740 | 740 | { |
| 741 | 741 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 742 | 742 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 743 | 743 | |
| 744 | - try { |
|
| 744 | + try { |
|
| 745 | 745 | |
| 746 | 746 | $sth = $this->db->prepare($query); |
| 747 | 747 | $sth->execute(array(':ident' => $ident)); |
@@ -753,17 +753,17 @@ discard block |
||
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | /** |
| 756 | - * Deletes all info in the table for an id |
|
| 757 | - * |
|
| 758 | - * @return String success or false |
|
| 759 | - * |
|
| 760 | - */ |
|
| 756 | + * Deletes all info in the table for an id |
|
| 757 | + * |
|
| 758 | + * @return String success or false |
|
| 759 | + * |
|
| 760 | + */ |
|
| 761 | 761 | public function deleteLiveSpotterDataById($id) |
| 762 | 762 | { |
| 763 | 763 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 764 | 764 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 765 | 765 | |
| 766 | - try { |
|
| 766 | + try { |
|
| 767 | 767 | |
| 768 | 768 | $sth = $this->db->prepare($query); |
| 769 | 769 | $sth->execute(array(':id' => $id)); |
@@ -776,11 +776,11 @@ discard block |
||
| 776 | 776 | |
| 777 | 777 | |
| 778 | 778 | /** |
| 779 | - * Gets the aircraft ident within the last hour |
|
| 780 | - * |
|
| 781 | - * @return String the ident |
|
| 782 | - * |
|
| 783 | - */ |
|
| 779 | + * Gets the aircraft ident within the last hour |
|
| 780 | + * |
|
| 781 | + * @return String the ident |
|
| 782 | + * |
|
| 783 | + */ |
|
| 784 | 784 | public function getIdentFromLastHour($ident) |
| 785 | 785 | { |
| 786 | 786 | global $globalDBdriver, $globalTimezone; |
@@ -806,14 +806,14 @@ discard block |
||
| 806 | 806 | $ident_result = $row['ident']; |
| 807 | 807 | } |
| 808 | 808 | return $ident_result; |
| 809 | - } |
|
| 809 | + } |
|
| 810 | 810 | |
| 811 | 811 | /** |
| 812 | - * Check recent aircraft |
|
| 813 | - * |
|
| 814 | - * @return String the ident |
|
| 815 | - * |
|
| 816 | - */ |
|
| 812 | + * Check recent aircraft |
|
| 813 | + * |
|
| 814 | + * @return String the ident |
|
| 815 | + * |
|
| 816 | + */ |
|
| 817 | 817 | public function checkIdentRecent($ident) |
| 818 | 818 | { |
| 819 | 819 | global $globalDBdriver, $globalTimezone; |
@@ -839,14 +839,14 @@ discard block |
||
| 839 | 839 | $ident_result = $row['flightaware_id']; |
| 840 | 840 | } |
| 841 | 841 | return $ident_result; |
| 842 | - } |
|
| 842 | + } |
|
| 843 | 843 | |
| 844 | 844 | /** |
| 845 | - * Check recent aircraft by id |
|
| 846 | - * |
|
| 847 | - * @return String the ident |
|
| 848 | - * |
|
| 849 | - */ |
|
| 845 | + * Check recent aircraft by id |
|
| 846 | + * |
|
| 847 | + * @return String the ident |
|
| 848 | + * |
|
| 849 | + */ |
|
| 850 | 850 | public function checkIdRecent($id) |
| 851 | 851 | { |
| 852 | 852 | global $globalDBdriver, $globalTimezone; |
@@ -872,14 +872,14 @@ discard block |
||
| 872 | 872 | $ident_result = $row['flightaware_id']; |
| 873 | 873 | } |
| 874 | 874 | return $ident_result; |
| 875 | - } |
|
| 875 | + } |
|
| 876 | 876 | |
| 877 | 877 | /** |
| 878 | - * Check recent aircraft by ModeS |
|
| 879 | - * |
|
| 880 | - * @return String the ModeS |
|
| 881 | - * |
|
| 882 | - */ |
|
| 878 | + * Check recent aircraft by ModeS |
|
| 879 | + * |
|
| 880 | + * @return String the ModeS |
|
| 881 | + * |
|
| 882 | + */ |
|
| 883 | 883 | public function checkModeSRecent($modes) |
| 884 | 884 | { |
| 885 | 885 | global $globalDBdriver, $globalTimezone; |
@@ -906,19 +906,19 @@ discard block |
||
| 906 | 906 | $ident_result = $row['flightaware_id']; |
| 907 | 907 | } |
| 908 | 908 | return $ident_result; |
| 909 | - } |
|
| 909 | + } |
|
| 910 | 910 | |
| 911 | 911 | /** |
| 912 | - * Adds a new spotter data |
|
| 913 | - * |
|
| 914 | - * @param String $flightaware_id the ID from flightaware |
|
| 915 | - * @param String $ident the flight ident |
|
| 916 | - * @param String $aircraft_icao the aircraft type |
|
| 917 | - * @param String $departure_airport_icao the departure airport |
|
| 918 | - * @param String $arrival_airport_icao the arrival airport |
|
| 919 | - * @return String success or false |
|
| 920 | - * |
|
| 921 | - */ |
|
| 912 | + * Adds a new spotter data |
|
| 913 | + * |
|
| 914 | + * @param String $flightaware_id the ID from flightaware |
|
| 915 | + * @param String $ident the flight ident |
|
| 916 | + * @param String $aircraft_icao the aircraft type |
|
| 917 | + * @param String $departure_airport_icao the departure airport |
|
| 918 | + * @param String $arrival_airport_icao the arrival airport |
|
| 919 | + * @return String success or false |
|
| 920 | + * |
|
| 921 | + */ |
|
| 922 | 922 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
| 923 | 923 | { |
| 924 | 924 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1053,10 +1053,10 @@ discard block |
||
| 1053 | 1053 | $arrival_airport_country = ''; |
| 1054 | 1054 | |
| 1055 | 1055 | |
| 1056 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1057 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1058 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1059 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1056 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1057 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1058 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1059 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1060 | 1060 | |
| 1061 | 1061 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
| 1062 | 1062 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -1066,14 +1066,14 @@ discard block |
||
| 1066 | 1066 | |
| 1067 | 1067 | $sth = $this->db->prepare($query); |
| 1068 | 1068 | $sth->execute($query_values); |
| 1069 | - } catch(PDOException $e) { |
|
| 1070 | - return "error : ".$e->getMessage(); |
|
| 1071 | - } |
|
| 1069 | + } catch(PDOException $e) { |
|
| 1070 | + return "error : ".$e->getMessage(); |
|
| 1071 | + } |
|
| 1072 | 1072 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1073 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1074 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 1075 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1076 | - if ($globalDebug) echo $result.')'; |
|
| 1073 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1074 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 1075 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1076 | + if ($globalDebug) echo $result.')'; |
|
| 1077 | 1077 | } |
| 1078 | 1078 | return "success"; |
| 1079 | 1079 | |
@@ -16,62 +16,62 @@ 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['airlines']) && !empty($flt['airlines'])) { |
| 37 | 37 | if ($flt['airlines'][0] != '') { |
| 38 | 38 | if (isset($flt['source'])) { |
| 39 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 39 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 40 | 40 | } else { |
| 41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 46 | 46 | if (isset($flt['source'])) { |
| 47 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 47 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 48 | 48 | } else { |
| 49 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 49 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 53 | 53 | if (isset($flt['source'])) { |
| 54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 55 | 55 | } else { |
| 56 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 56 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 60 | 60 | if (isset($flt['source'])) { |
| 61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 62 | 62 | } else { |
| 63 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 63 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 67 | 67 | if (isset($flt['source'])) { |
| 68 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 68 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 73 | 73 | if ($filter['airlines'][0] != '') { |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
| 82 | 82 | } |
| 83 | 83 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 84 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 84 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 85 | 85 | } |
| 86 | 86 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 87 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 87 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 88 | 88 | } |
| 89 | 89 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 90 | 90 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 116 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 117 | 117 | } |
| 118 | 118 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 119 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 119 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 120 | 120 | } |
| 121 | 121 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 122 | 122 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 123 | 123 | if ($filter_query_where != '') { |
| 124 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 124 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 125 | 125 | } |
| 126 | 126 | $filter_query = $filter_query_join.$filter_query_where; |
| 127 | 127 | return $filter_query; |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | if ($limit != '') |
| 145 | 145 | { |
| 146 | 146 | $limit_array = explode(',', $limit); |
| 147 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 147 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 149 | 149 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 150 | 150 | { |
| 151 | 151 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | } else { |
| 169 | 169 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
| 170 | 170 | } |
| 171 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 171 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 172 | 172 | |
| 173 | 173 | return $spotter_array; |
| 174 | 174 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | global $globalDBdriver, $globalLiveInterval; |
| 185 | 185 | date_default_timezone_set('UTC'); |
| 186 | 186 | |
| 187 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 187 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 188 | 188 | |
| 189 | 189 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 190 | 190 | if ($globalDBdriver == 'mysql') { |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $query = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 196 | 196 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
| 197 | 197 | */ |
| 198 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 198 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 199 | 199 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
| 200 | 200 | |
| 201 | 201 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 211 | 211 | */ |
| 212 | 212 | |
| 213 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 213 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 214 | 214 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 215 | 215 | |
| 216 | 216 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | try { |
| 222 | 222 | $sth = $this->db->prepare($query); |
| 223 | 223 | $sth->execute(); |
| 224 | - } catch(PDOException $e) { |
|
| 224 | + } catch (PDOException $e) { |
|
| 225 | 225 | echo $e->getMessage(); |
| 226 | 226 | die; |
| 227 | 227 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | global $globalDBdriver, $globalLiveInterval; |
| 242 | 242 | date_default_timezone_set('UTC'); |
| 243 | 243 | |
| 244 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 244 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 245 | 245 | |
| 246 | 246 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 247 | 247 | if ($globalDBdriver == 'mysql') { |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 251 | 251 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 252 | 252 | */ |
| 253 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 253 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 254 | 254 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 255 | 255 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 256 | 256 | } else { |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 260 | 260 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 261 | 261 | */ |
| 262 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 262 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 263 | 263 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 264 | 264 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 265 | 265 | // echo $query; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | try { |
| 269 | 269 | $sth = $this->db->prepare($query); |
| 270 | 270 | $sth->execute(); |
| 271 | - } catch(PDOException $e) { |
|
| 271 | + } catch (PDOException $e) { |
|
| 272 | 272 | echo $e->getMessage(); |
| 273 | 273 | die; |
| 274 | 274 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | public function getLiveSpotterCount($filter = array()) |
| 286 | 286 | { |
| 287 | 287 | global $globalDBdriver, $globalLiveInterval; |
| 288 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 288 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 289 | 289 | |
| 290 | 290 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 291 | 291 | if ($globalDBdriver == 'mysql') { |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | try { |
| 299 | 299 | $sth = $this->db->prepare($query); |
| 300 | 300 | $sth->execute(); |
| 301 | - } catch(PDOException $e) { |
|
| 301 | + } catch (PDOException $e) { |
|
| 302 | 302 | echo $e->getMessage(); |
| 303 | 303 | die; |
| 304 | 304 | } |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | $filter_query = $this->getFilter($filter); |
| 322 | 322 | |
| 323 | 323 | if (is_array($coord)) { |
| 324 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 325 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 326 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 327 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 324 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 325 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 326 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 327 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 328 | 328 | } else return array(); |
| 329 | 329 | if ($globalDBdriver == 'mysql') { |
| 330 | 330 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -347,13 +347,13 @@ discard block |
||
| 347 | 347 | global $globalDBdriver, $globalLiveInterval; |
| 348 | 348 | $Spotter = new Spotter($this->db); |
| 349 | 349 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 350 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 350 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 351 | 351 | |
| 352 | 352 | if (is_array($coord)) { |
| 353 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 354 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 355 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 356 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 353 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 354 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 355 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 356 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 357 | 357 | } else return array(); |
| 358 | 358 | if ($globalDBdriver == 'mysql') { |
| 359 | 359 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | try { |
| 374 | 374 | $sth = $this->db->prepare($query); |
| 375 | 375 | $sth->execute(); |
| 376 | - } catch(PDOException $e) { |
|
| 376 | + } catch (PDOException $e) { |
|
| 377 | 377 | echo $e->getMessage(); |
| 378 | 378 | die; |
| 379 | 379 | } |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | if ($interval == '1m') |
| 423 | 423 | { |
| 424 | 424 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 425 | - } else if ($interval == '15m'){ |
|
| 425 | + } else if ($interval == '15m') { |
|
| 426 | 426 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -430,14 +430,14 @@ discard block |
||
| 430 | 430 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 433 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 434 | 434 | WHERE spotter_live.latitude <> '' |
| 435 | 435 | AND spotter_live.longitude <> '' |
| 436 | 436 | ".$additional_query." |
| 437 | 437 | HAVING distance < :radius |
| 438 | 438 | ORDER BY distance"; |
| 439 | 439 | |
| 440 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 440 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 441 | 441 | |
| 442 | 442 | return $spotter_array; |
| 443 | 443 | } |
@@ -455,9 +455,9 @@ discard block |
||
| 455 | 455 | date_default_timezone_set('UTC'); |
| 456 | 456 | |
| 457 | 457 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 458 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 458 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 459 | 459 | |
| 460 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 460 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 461 | 461 | |
| 462 | 462 | return $spotter_array; |
| 463 | 463 | } |
@@ -468,16 +468,16 @@ discard block |
||
| 468 | 468 | * @return Array the spotter information |
| 469 | 469 | * |
| 470 | 470 | */ |
| 471 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 471 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 472 | 472 | { |
| 473 | 473 | $Spotter = new Spotter($this->db); |
| 474 | 474 | date_default_timezone_set('UTC'); |
| 475 | 475 | |
| 476 | 476 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 477 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 477 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 478 | 478 | |
| 479 | - $date = date('c',$date); |
|
| 480 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 479 | + $date = date('c', $date); |
|
| 480 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 481 | 481 | |
| 482 | 482 | return $spotter_array; |
| 483 | 483 | } |
@@ -494,9 +494,9 @@ discard block |
||
| 494 | 494 | date_default_timezone_set('UTC'); |
| 495 | 495 | |
| 496 | 496 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 497 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 497 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 498 | 498 | |
| 499 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 499 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 500 | 500 | |
| 501 | 501 | return $spotter_array; |
| 502 | 502 | } |
@@ -507,15 +507,15 @@ discard block |
||
| 507 | 507 | * @return Array the spotter information |
| 508 | 508 | * |
| 509 | 509 | */ |
| 510 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 510 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 511 | 511 | { |
| 512 | 512 | $Spotter = new Spotter($this->db); |
| 513 | 513 | date_default_timezone_set('UTC'); |
| 514 | 514 | |
| 515 | 515 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 516 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 517 | - $date = date('c',$date); |
|
| 518 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 516 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 517 | + $date = date('c', $date); |
|
| 518 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 519 | 519 | |
| 520 | 520 | return $spotter_array; |
| 521 | 521 | } |
@@ -532,13 +532,13 @@ discard block |
||
| 532 | 532 | date_default_timezone_set('UTC'); |
| 533 | 533 | |
| 534 | 534 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 535 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 535 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 536 | 536 | |
| 537 | 537 | try { |
| 538 | 538 | |
| 539 | 539 | $sth = $this->db->prepare($query); |
| 540 | 540 | $sth->execute(array(':ident' => $ident)); |
| 541 | - } catch(PDOException $e) { |
|
| 541 | + } catch (PDOException $e) { |
|
| 542 | 542 | echo $e->getMessage(); |
| 543 | 543 | die; |
| 544 | 544 | } |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | * @return Array the spotter information |
| 554 | 554 | * |
| 555 | 555 | */ |
| 556 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 556 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 557 | 557 | { |
| 558 | 558 | global $globalDBdriver, $globalLiveInterval; |
| 559 | 559 | date_default_timezone_set('UTC'); |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | try { |
| 573 | 573 | $sth = $this->db->prepare($query); |
| 574 | 574 | $sth->execute(array(':id' => $id)); |
| 575 | - } catch(PDOException $e) { |
|
| 575 | + } catch (PDOException $e) { |
|
| 576 | 576 | echo $e->getMessage(); |
| 577 | 577 | die; |
| 578 | 578 | } |
@@ -590,12 +590,12 @@ discard block |
||
| 590 | 590 | { |
| 591 | 591 | date_default_timezone_set('UTC'); |
| 592 | 592 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 593 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 593 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 594 | 594 | try { |
| 595 | 595 | |
| 596 | 596 | $sth = $this->db->prepare($query); |
| 597 | 597 | $sth->execute(array(':ident' => $ident)); |
| 598 | - } catch(PDOException $e) { |
|
| 598 | + } catch (PDOException $e) { |
|
| 599 | 599 | echo $e->getMessage(); |
| 600 | 600 | die; |
| 601 | 601 | } |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | |
| 626 | 626 | $sth = $this->db->prepare($query); |
| 627 | 627 | $sth->execute(); |
| 628 | - } catch(PDOException $e) { |
|
| 628 | + } catch (PDOException $e) { |
|
| 629 | 629 | return "error"; |
| 630 | 630 | } |
| 631 | 631 | |
@@ -648,14 +648,14 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | $sth = $this->db->prepare($query); |
| 650 | 650 | $sth->execute(); |
| 651 | - } catch(PDOException $e) { |
|
| 651 | + } catch (PDOException $e) { |
|
| 652 | 652 | return "error"; |
| 653 | 653 | } |
| 654 | 654 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 655 | 655 | $i = 0; |
| 656 | - $j =0; |
|
| 656 | + $j = 0; |
|
| 657 | 657 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 658 | - foreach($all as $row) |
|
| 658 | + foreach ($all as $row) |
|
| 659 | 659 | { |
| 660 | 660 | $i++; |
| 661 | 661 | $j++; |
@@ -663,9 +663,9 @@ discard block |
||
| 663 | 663 | if ($globalDebug) echo "."; |
| 664 | 664 | try { |
| 665 | 665 | |
| 666 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 666 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 667 | 667 | $sth->execute(); |
| 668 | - } catch(PDOException $e) { |
|
| 668 | + } catch (PDOException $e) { |
|
| 669 | 669 | return "error"; |
| 670 | 670 | } |
| 671 | 671 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -676,9 +676,9 @@ discard block |
||
| 676 | 676 | if ($i > 0) { |
| 677 | 677 | try { |
| 678 | 678 | |
| 679 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 679 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 680 | 680 | $sth->execute(); |
| 681 | - } catch(PDOException $e) { |
|
| 681 | + } catch (PDOException $e) { |
|
| 682 | 682 | return "error"; |
| 683 | 683 | } |
| 684 | 684 | } |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | $sth = $this->db->prepare($query); |
| 693 | 693 | $sth->execute(); |
| 694 | - } catch(PDOException $e) { |
|
| 694 | + } catch (PDOException $e) { |
|
| 695 | 695 | return "error"; |
| 696 | 696 | } |
| 697 | 697 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -739,13 +739,13 @@ discard block |
||
| 739 | 739 | public function deleteLiveSpotterDataByIdent($ident) |
| 740 | 740 | { |
| 741 | 741 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 742 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 742 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 743 | 743 | |
| 744 | 744 | try { |
| 745 | 745 | |
| 746 | 746 | $sth = $this->db->prepare($query); |
| 747 | 747 | $sth->execute(array(':ident' => $ident)); |
| 748 | - } catch(PDOException $e) { |
|
| 748 | + } catch (PDOException $e) { |
|
| 749 | 749 | return "error"; |
| 750 | 750 | } |
| 751 | 751 | |
@@ -761,13 +761,13 @@ discard block |
||
| 761 | 761 | public function deleteLiveSpotterDataById($id) |
| 762 | 762 | { |
| 763 | 763 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 764 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 764 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 765 | 765 | |
| 766 | 766 | try { |
| 767 | 767 | |
| 768 | 768 | $sth = $this->db->prepare($query); |
| 769 | 769 | $sth->execute(array(':id' => $id)); |
| 770 | - } catch(PDOException $e) { |
|
| 770 | + } catch (PDOException $e) { |
|
| 771 | 771 | return "error"; |
| 772 | 772 | } |
| 773 | 773 | |
@@ -785,13 +785,13 @@ discard block |
||
| 785 | 785 | { |
| 786 | 786 | global $globalDBdriver, $globalTimezone; |
| 787 | 787 | if ($globalDBdriver == 'mysql') { |
| 788 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 788 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 789 | 789 | WHERE spotter_live.ident = :ident |
| 790 | 790 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 791 | 791 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 792 | 792 | $query_data = array(':ident' => $ident); |
| 793 | 793 | } else { |
| 794 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 794 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 795 | 795 | WHERE spotter_live.ident = :ident |
| 796 | 796 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 797 | 797 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -800,8 +800,8 @@ discard block |
||
| 800 | 800 | |
| 801 | 801 | $sth = $this->db->prepare($query); |
| 802 | 802 | $sth->execute($query_data); |
| 803 | - $ident_result=''; |
|
| 804 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 803 | + $ident_result = ''; |
|
| 804 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 805 | 805 | { |
| 806 | 806 | $ident_result = $row['ident']; |
| 807 | 807 | } |
@@ -818,13 +818,13 @@ discard block |
||
| 818 | 818 | { |
| 819 | 819 | global $globalDBdriver, $globalTimezone; |
| 820 | 820 | if ($globalDBdriver == 'mysql') { |
| 821 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 821 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 822 | 822 | WHERE spotter_live.ident = :ident |
| 823 | 823 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 824 | 824 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 825 | 825 | $query_data = array(':ident' => $ident); |
| 826 | 826 | } else { |
| 827 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 827 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 828 | 828 | WHERE spotter_live.ident = :ident |
| 829 | 829 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 830 | 830 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -833,8 +833,8 @@ discard block |
||
| 833 | 833 | |
| 834 | 834 | $sth = $this->db->prepare($query); |
| 835 | 835 | $sth->execute($query_data); |
| 836 | - $ident_result=''; |
|
| 837 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 836 | + $ident_result = ''; |
|
| 837 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 838 | 838 | { |
| 839 | 839 | $ident_result = $row['flightaware_id']; |
| 840 | 840 | } |
@@ -851,13 +851,13 @@ discard block |
||
| 851 | 851 | { |
| 852 | 852 | global $globalDBdriver, $globalTimezone; |
| 853 | 853 | if ($globalDBdriver == 'mysql') { |
| 854 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 854 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 855 | 855 | WHERE spotter_live.flightaware_id = :id |
| 856 | 856 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 857 | 857 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 858 | 858 | $query_data = array(':id' => $id); |
| 859 | 859 | } else { |
| 860 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 860 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 861 | 861 | WHERE spotter_live.flightaware_id = :id |
| 862 | 862 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 863 | 863 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -866,8 +866,8 @@ discard block |
||
| 866 | 866 | |
| 867 | 867 | $sth = $this->db->prepare($query); |
| 868 | 868 | $sth->execute($query_data); |
| 869 | - $ident_result=''; |
|
| 870 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 869 | + $ident_result = ''; |
|
| 870 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 871 | 871 | { |
| 872 | 872 | $ident_result = $row['flightaware_id']; |
| 873 | 873 | } |
@@ -884,13 +884,13 @@ discard block |
||
| 884 | 884 | { |
| 885 | 885 | global $globalDBdriver, $globalTimezone; |
| 886 | 886 | if ($globalDBdriver == 'mysql') { |
| 887 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 887 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 888 | 888 | WHERE spotter_live.ModeS = :modes |
| 889 | 889 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 890 | 890 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 891 | 891 | $query_data = array(':modes' => $modes); |
| 892 | 892 | } else { |
| 893 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 893 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 894 | 894 | WHERE spotter_live.ModeS = :modes |
| 895 | 895 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
| 896 | 896 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -899,8 +899,8 @@ discard block |
||
| 899 | 899 | |
| 900 | 900 | $sth = $this->db->prepare($query); |
| 901 | 901 | $sth->execute($query_data); |
| 902 | - $ident_result=''; |
|
| 903 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 902 | + $ident_result = ''; |
|
| 903 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 904 | 904 | { |
| 905 | 905 | //$ident_result = $row['spotter_live_id']; |
| 906 | 906 | $ident_result = $row['flightaware_id']; |
@@ -919,7 +919,7 @@ discard block |
||
| 919 | 919 | * @return String success or false |
| 920 | 920 | * |
| 921 | 921 | */ |
| 922 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 922 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 923 | 923 | { |
| 924 | 924 | global $globalURL, $globalArchive, $globalDebug; |
| 925 | 925 | $Common = new Common(); |
@@ -1012,26 +1012,26 @@ discard block |
||
| 1012 | 1012 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 1013 | 1013 | |
| 1014 | 1014 | |
| 1015 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 1016 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1017 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 1018 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1019 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1020 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1021 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1022 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 1023 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1024 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1025 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1026 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 1027 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 1028 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 1029 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 1030 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 1031 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1032 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 1033 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 1034 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 1015 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 1016 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1017 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 1018 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1019 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1020 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1021 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1022 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 1023 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1024 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1025 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1026 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 1027 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 1028 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 1029 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 1030 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 1031 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1032 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 1033 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 1034 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 1035 | 1035 | |
| 1036 | 1036 | $airline_name = ''; |
| 1037 | 1037 | $airline_icao = ''; |
@@ -1053,26 +1053,26 @@ discard block |
||
| 1053 | 1053 | $arrival_airport_country = ''; |
| 1054 | 1054 | |
| 1055 | 1055 | |
| 1056 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1057 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1058 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1059 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1056 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 1057 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 1058 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 1059 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1060 | 1060 | |
| 1061 | - $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
|
| 1061 | + $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
|
| 1062 | 1062 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
| 1063 | 1063 | |
| 1064 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
| 1064 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
| 1065 | 1065 | try { |
| 1066 | 1066 | |
| 1067 | 1067 | $sth = $this->db->prepare($query); |
| 1068 | 1068 | $sth->execute($query_values); |
| 1069 | - } catch(PDOException $e) { |
|
| 1069 | + } catch (PDOException $e) { |
|
| 1070 | 1070 | return "error : ".$e->getMessage(); |
| 1071 | 1071 | } |
| 1072 | 1072 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1073 | 1073 | if ($globalDebug) echo '(Add to SBS archive : '; |
| 1074 | 1074 | $SpotterArchive = new SpotterArchive($this->db); |
| 1075 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1075 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
| 1076 | 1076 | if ($globalDebug) echo $result.')'; |
| 1077 | 1077 | } |
| 1078 | 1078 | return "success"; |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | |
| 1082 | 1082 | public function getOrderBy() |
| 1083 | 1083 | { |
| 1084 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1084 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1085 | 1085 | return $orderby; |
| 1086 | 1086 | } |
| 1087 | 1087 | |
@@ -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) { |
@@ -118,8 +120,11 @@ discard block |
||
| 118 | 120 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 119 | 121 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 120 | 122 | } |
| 121 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 122 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 123 | + if ($filter_query_where == '' && $where) { |
|
| 124 | + $filter_query_where = ' WHERE'; |
|
| 125 | + } elseif ($filter_query_where != '' && $and) { |
|
| 126 | + $filter_query_where .= ' AND'; |
|
| 127 | + } |
|
| 123 | 128 | if ($filter_query_where != '') { |
| 124 | 129 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 125 | 130 | } |
@@ -161,7 +166,9 @@ discard block |
||
| 161 | 166 | } |
| 162 | 167 | } |
| 163 | 168 | |
| 164 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 169 | + if (!isset($globalLiveInterval)) { |
|
| 170 | + $globalLiveInterval = '200'; |
|
| 171 | + } |
|
| 165 | 172 | if ($globalDBdriver == 'mysql') { |
| 166 | 173 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
| 167 | 174 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -186,7 +193,9 @@ discard block |
||
| 186 | 193 | |
| 187 | 194 | $filter_query = $this->getFilter($filter,true,true); |
| 188 | 195 | |
| 189 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 196 | + if (!isset($globalLiveInterval)) { |
|
| 197 | + $globalLiveInterval = '200'; |
|
| 198 | + } |
|
| 190 | 199 | if ($globalDBdriver == 'mysql') { |
| 191 | 200 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
| 192 | 201 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -243,7 +252,9 @@ discard block |
||
| 243 | 252 | |
| 244 | 253 | $filter_query = $this->getFilter($filter,true,true); |
| 245 | 254 | |
| 246 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 255 | + if (!isset($globalLiveInterval)) { |
|
| 256 | + $globalLiveInterval = '200'; |
|
| 257 | + } |
|
| 247 | 258 | if ($globalDBdriver == 'mysql') { |
| 248 | 259 | /* |
| 249 | 260 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -287,7 +298,9 @@ discard block |
||
| 287 | 298 | global $globalDBdriver, $globalLiveInterval; |
| 288 | 299 | $filter_query = $this->getFilter($filter,true,true); |
| 289 | 300 | |
| 290 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 301 | + if (!isset($globalLiveInterval)) { |
|
| 302 | + $globalLiveInterval = '200'; |
|
| 303 | + } |
|
| 291 | 304 | if ($globalDBdriver == 'mysql') { |
| 292 | 305 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
| 293 | 306 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -317,7 +330,9 @@ discard block |
||
| 317 | 330 | { |
| 318 | 331 | global $globalDBdriver, $globalLiveInterval; |
| 319 | 332 | $Spotter = new Spotter($this->db); |
| 320 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 333 | + if (!isset($globalLiveInterval)) { |
|
| 334 | + $globalLiveInterval = '200'; |
|
| 335 | + } |
|
| 321 | 336 | $filter_query = $this->getFilter($filter); |
| 322 | 337 | |
| 323 | 338 | if (is_array($coord)) { |
@@ -325,7 +340,9 @@ discard block |
||
| 325 | 340 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 326 | 341 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 327 | 342 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 328 | - } else return array(); |
|
| 343 | + } else { |
|
| 344 | + return array(); |
|
| 345 | + } |
|
| 329 | 346 | if ($globalDBdriver == 'mysql') { |
| 330 | 347 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
| 331 | 348 | } else { |
@@ -346,7 +363,9 @@ discard block |
||
| 346 | 363 | { |
| 347 | 364 | global $globalDBdriver, $globalLiveInterval; |
| 348 | 365 | $Spotter = new Spotter($this->db); |
| 349 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 366 | + if (!isset($globalLiveInterval)) { |
|
| 367 | + $globalLiveInterval = '200'; |
|
| 368 | + } |
|
| 350 | 369 | $filter_query = $this->getFilter($filter,true,true); |
| 351 | 370 | |
| 352 | 371 | if (is_array($coord)) { |
@@ -354,7 +373,9 @@ discard block |
||
| 354 | 373 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 355 | 374 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 356 | 375 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 357 | - } else return array(); |
|
| 376 | + } else { |
|
| 377 | + return array(); |
|
| 378 | + } |
|
| 358 | 379 | if ($globalDBdriver == 'mysql') { |
| 359 | 380 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 360 | 381 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.' spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.''; |
@@ -561,11 +582,15 @@ discard block |
||
| 561 | 582 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 562 | 583 | if ($globalDBdriver == 'mysql') { |
| 563 | 584 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 564 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 585 | + if ($liveinterval) { |
|
| 586 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 587 | + } |
|
| 565 | 588 | $query .= ' ORDER BY date'; |
| 566 | 589 | } else { |
| 567 | 590 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 568 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 591 | + if ($liveinterval) { |
|
| 592 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 593 | + } |
|
| 569 | 594 | $query .= ' ORDER BY date'; |
| 570 | 595 | } |
| 571 | 596 | |
@@ -660,7 +685,9 @@ discard block |
||
| 660 | 685 | $i++; |
| 661 | 686 | $j++; |
| 662 | 687 | if ($j == 30) { |
| 663 | - if ($globalDebug) echo "."; |
|
| 688 | + if ($globalDebug) { |
|
| 689 | + echo "."; |
|
| 690 | + } |
|
| 664 | 691 | try { |
| 665 | 692 | |
| 666 | 693 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -967,7 +994,9 @@ discard block |
||
| 967 | 994 | { |
| 968 | 995 | return false; |
| 969 | 996 | } |
| 970 | - } else return ''; |
|
| 997 | + } else { |
|
| 998 | + return ''; |
|
| 999 | + } |
|
| 971 | 1000 | |
| 972 | 1001 | if ($longitude != '') |
| 973 | 1002 | { |
@@ -975,7 +1004,9 @@ discard block |
||
| 975 | 1004 | { |
| 976 | 1005 | return false; |
| 977 | 1006 | } |
| 978 | - } else return ''; |
|
| 1007 | + } else { |
|
| 1008 | + return ''; |
|
| 1009 | + } |
|
| 979 | 1010 | |
| 980 | 1011 | if ($waypoints != '') |
| 981 | 1012 | { |
@@ -991,7 +1022,9 @@ discard block |
||
| 991 | 1022 | { |
| 992 | 1023 | return false; |
| 993 | 1024 | } |
| 994 | - } else $altitude = 0; |
|
| 1025 | + } else { |
|
| 1026 | + $altitude = 0; |
|
| 1027 | + } |
|
| 995 | 1028 | |
| 996 | 1029 | if ($heading != '') |
| 997 | 1030 | { |
@@ -999,7 +1032,9 @@ discard block |
||
| 999 | 1032 | { |
| 1000 | 1033 | return false; |
| 1001 | 1034 | } |
| 1002 | - } else $heading = 0; |
|
| 1035 | + } else { |
|
| 1036 | + $heading = 0; |
|
| 1037 | + } |
|
| 1003 | 1038 | |
| 1004 | 1039 | if ($groundspeed != '') |
| 1005 | 1040 | { |
@@ -1007,9 +1042,13 @@ discard block |
||
| 1007 | 1042 | { |
| 1008 | 1043 | return false; |
| 1009 | 1044 | } |
| 1010 | - } else $groundspeed = 0; |
|
| 1045 | + } else { |
|
| 1046 | + $groundspeed = 0; |
|
| 1047 | + } |
|
| 1011 | 1048 | date_default_timezone_set('UTC'); |
| 1012 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1049 | + if ($date == '') { |
|
| 1050 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1051 | + } |
|
| 1013 | 1052 | |
| 1014 | 1053 | |
| 1015 | 1054 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1053,10 +1092,18 @@ discard block |
||
| 1053 | 1092 | $arrival_airport_country = ''; |
| 1054 | 1093 | |
| 1055 | 1094 | |
| 1056 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1057 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1058 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1059 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1095 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1096 | + $squawk = NULL; |
|
| 1097 | + } |
|
| 1098 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1099 | + $verticalrate = NULL; |
|
| 1100 | + } |
|
| 1101 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1102 | + $groundspeed = 0; |
|
| 1103 | + } |
|
| 1104 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1105 | + $heading = 0; |
|
| 1106 | + } |
|
| 1060 | 1107 | |
| 1061 | 1108 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
| 1062 | 1109 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -1070,10 +1117,14 @@ discard block |
||
| 1070 | 1117 | return "error : ".$e->getMessage(); |
| 1071 | 1118 | } |
| 1072 | 1119 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1073 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1120 | + if ($globalDebug) { |
|
| 1121 | + echo '(Add to SBS archive : '; |
|
| 1122 | + } |
|
| 1074 | 1123 | $SpotterArchive = new SpotterArchive($this->db); |
| 1075 | 1124 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1076 | - if ($globalDebug) echo $result.')'; |
|
| 1125 | + if ($globalDebug) { |
|
| 1126 | + echo $result.')'; |
|
| 1127 | + } |
|
| 1077 | 1128 | } |
| 1078 | 1129 | return "success"; |
| 1079 | 1130 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | date_default_timezone_set('UTC'); |
| 28 | 28 | //waypoint plotting |
| 29 | 29 | $output .= '{"type": "Feature",'; |
| 30 | - $output .= '"properties": {'; |
|
| 30 | + $output .= '"properties": {'; |
|
| 31 | 31 | $output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",'; |
| 32 | 32 | $output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",'; |
| 33 | 33 | $output .= '"country": "'.$spotter_item['country'].'",'; |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | $output .= '"homepage": "'.$spotter_item['home_link'].'",'; |
| 51 | 51 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
| 52 | 52 | // $output .= '"photo": "'.$spotter_item['image_thumbnail'].'",'; |
| 53 | - $output .= '},'; |
|
| 54 | - $output .= '"geometry": {'; |
|
| 53 | + $output .= '},'; |
|
| 54 | + $output .= '"geometry": {'; |
|
| 55 | 55 | $output .= '"type": "Point",'; |
| 56 | 56 | $output .= '"coordinates": ['; |
| 57 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
| 57 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
| 58 | 58 | $output .= ']'; |
| 59 | - $output .= '}'; |
|
| 59 | + $output .= '}'; |
|
| 60 | 60 | $output .= '},'; |
| 61 | 61 | } |
| 62 | 62 | $output = substr($output, 0, -1); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | if (isset($_GET['coord'])) |
| 13 | 13 | { |
| 14 | - $coords = explode(',',$_GET['coord']); |
|
| 14 | + $coords = explode(',', $_GET['coord']); |
|
| 15 | 15 | $spotter_array = $Spotter->getAllAirportInfobyCoord($coords); |
| 16 | 16 | } else { |
| 17 | 17 | $spotter_array = $Spotter->getAllAirportInfo(); |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | if (!empty($spotter_array)) |
| 24 | 24 | { |
| 25 | - foreach($spotter_array as $spotter_item) |
|
| 25 | + foreach ($spotter_array as $spotter_item) |
|
| 26 | 26 | { |
| 27 | 27 | date_default_timezone_set('UTC'); |
| 28 | 28 | //waypoint plotting |
| 29 | 29 | $output .= '{"type": "Feature",'; |
| 30 | 30 | $output .= '"properties": {'; |
| 31 | - $output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",'; |
|
| 32 | - $output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",'; |
|
| 31 | + $output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",'; |
|
| 32 | + $output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",'; |
|
| 33 | 33 | $output .= '"country": "'.$spotter_item['country'].'",'; |
| 34 | 34 | $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
| 35 | - $output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
| 35 | + $output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
| 36 | 36 | if ($spotter_item['type'] == 'large_airport') { |
| 37 | 37 | $output .= '"icon": "'.$globalURL.'/images/airport.png",'; |
| 38 | 38 | } elseif ($spotter_item['type'] == 'heliport') { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $output .= '}'; |
| 60 | 60 | $output .= '},'; |
| 61 | 61 | } |
| 62 | - $output = substr($output, 0, -1); |
|
| 62 | + $output = substr($output, 0, -1); |
|
| 63 | 63 | } |
| 64 | 64 | $output .= ']}'; |
| 65 | 65 | print $output; |