@@ -65,18 +65,18 @@ discard block |
||
| 65 | 65 | $min = true; |
| 66 | 66 | $allhistory = false; |
| 67 | 67 | $filter['source'] = array(); |
| 68 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 69 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 70 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 71 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
| 72 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 73 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
| 74 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
| 75 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
| 76 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
| 77 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
| 78 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
| 79 | -if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT); |
|
| 68 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
| 69 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
| 70 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
| 71 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
| 72 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
| 73 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
| 74 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING); |
|
| 75 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
| 76 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
| 77 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
| 78 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
| 79 | +if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'], FILTER_SANITIZE_NUMBER_INT); |
|
| 80 | 80 | if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') $filter['blocked'] = true; |
| 81 | 81 | |
| 82 | 82 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | if (isset($_COOKIE['map_2d_limit'])) { |
| 88 | - $limit = filter_var($_COOKIE['map_2d_limit'],FILTER_SANITIZE_NUMBER_INT); |
|
| 88 | + $limit = filter_var($_COOKIE['map_2d_limit'], FILTER_SANITIZE_NUMBER_INT); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $spotter_array = array(); |
| 92 | 92 | |
| 93 | 93 | if (isset($_GET['ident'])) { |
| 94 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
| 94 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
| 95 | 95 | if ($tracker) { |
| 96 | 96 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
| 97 | 97 | } elseif ($marine) { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | $allhistory = true; |
| 107 | 107 | } elseif (isset($_GET['flightaware_id'])) { |
| 108 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
| 108 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
| 109 | 109 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
| 110 | 110 | if (empty($spotter_array)) { |
| 111 | 111 | $from_archive = true; |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | $allhistory = true; |
| 115 | 115 | } elseif (isset($_GET['famtrack_id'])) { |
| 116 | - $famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING)); |
|
| 116 | + $famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING)); |
|
| 117 | 117 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
| 118 | 118 | $allhistory = true; |
| 119 | 119 | } elseif (isset($_GET['fammarine_id'])) { |
| 120 | - $fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING)); |
|
| 120 | + $fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING)); |
|
| 121 | 121 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
| 122 | 122 | $allhistory = true; |
| 123 | 123 | /* |
@@ -137,15 +137,15 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min && !isset($_GET['archive'])) { |
| 139 | 139 | $usecoord = true; |
| 140 | - $coord = explode(',',$_GET['coord']); |
|
| 141 | - if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
| 140 | + $coord = explode(',', $_GET['coord']); |
|
| 141 | + if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
| 142 | 142 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) { |
| 143 | 143 | if ($tracker) { |
| 144 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
|
| 144 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter); |
|
| 145 | 145 | } elseif ($marine) { |
| 146 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
|
| 146 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter); |
|
| 147 | 147 | } else { |
| 148 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$limit,$filter); |
|
| 148 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $limit, $filter); |
|
| 149 | 149 | } |
| 150 | 150 | } else { |
| 151 | 151 | if ($tracker) { |
@@ -153,41 +153,41 @@ discard block |
||
| 153 | 153 | } elseif ($marine) { |
| 154 | 154 | $spotter_array = $MarineLive->getMinLiveMarineData($filter); |
| 155 | 155 | } else { |
| 156 | - $spotter_array = $SpotterLive->getMinLiveSpotterData($limit,$filter); |
|
| 156 | + $spotter_array = $SpotterLive->getMinLiveSpotterData($limit, $filter); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { |
| 160 | 160 | $from_archive = true; |
| 161 | 161 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 162 | 162 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
| 163 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
| 164 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
| 165 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
| 166 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
| 167 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
| 168 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
| 163 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
| 164 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
| 165 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
| 166 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
| 167 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
| 168 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
| 169 | 169 | } elseif ($min) { |
| 170 | 170 | if ($tracker) { |
| 171 | 171 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
| 172 | 172 | } elseif ($marine) { |
| 173 | 173 | $spotter_array = $MarineLive->getMinLiveMarineData($filter); |
| 174 | 174 | } else { |
| 175 | - $spotter_array = $SpotterLive->getMinLiveSpotterData($limit,$filter); |
|
| 175 | + $spotter_array = $SpotterLive->getMinLiveSpotterData($limit, $filter); |
|
| 176 | 176 | } |
| 177 | 177 | # $min = true; |
| 178 | 178 | } else { |
| 179 | 179 | if ($tracker) { |
| 180 | - $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
|
| 180 | + $spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); |
|
| 181 | 181 | } elseif ($marine) { |
| 182 | - $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
|
| 182 | + $spotter_array = $marineLive->getLiveMarineData('', '', $filter); |
|
| 183 | 183 | } else { |
| 184 | - $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
|
| 184 | + $spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | if ($usecoord) { |
| 189 | 189 | if (isset($_GET['archive'])) { |
| 190 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
| 190 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
| 191 | 191 | } else { |
| 192 | 192 | if ($tracker) { |
| 193 | 193 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
@@ -200,9 +200,9 @@ discard block |
||
| 200 | 200 | if ($flightcnt == '') $flightcnt = 0; |
| 201 | 201 | } else $flightcnt = 0; |
| 202 | 202 | |
| 203 | -$sqltime = round(microtime(true)-$begintime,2); |
|
| 203 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
| 204 | 204 | |
| 205 | -$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
| 205 | +$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
| 206 | 206 | if ($currenttime != '') $currenttime = round($currenttime/1000); |
| 207 | 207 | |
| 208 | 208 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation === FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | if (!empty($spotter_array) && is_array($spotter_array)) |
| 222 | 222 | { |
| 223 | 223 | $output .= '"features": ['; |
| 224 | - foreach($spotter_array as $spotter_item) |
|
| 224 | + foreach ($spotter_array as $spotter_item) |
|
| 225 | 225 | { |
| 226 | 226 | $j++; |
| 227 | 227 | unset($idistance); |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
| 280 | 280 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
| 281 | - if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).','; |
|
| 282 | - else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).','; |
|
| 281 | + if ($compress) $output .= '"c": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).','; |
|
| 282 | + else $output .= '"callsign": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).','; |
|
| 283 | 283 | //' |
| 284 | 284 | } else { |
| 285 | 285 | if ($compress) $output .= '"c": "NA",'; |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 293 | 293 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
| 294 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
| 294 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
| 295 | 295 | } elseif (isset($spotter_item['aircraft_type'])) { |
| 296 | 296 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
| 297 | 297 | } elseif (!$min) { |
@@ -377,25 +377,25 @@ discard block |
||
| 377 | 377 | else $output .= '"aircraft_shadow": "car.png",'; |
| 378 | 378 | } |
| 379 | 379 | } elseif ($marine) { |
| 380 | - if (isset($spotter_item['type']) && ($spotter_item['type'] == '50' Performance Cruiser' || $spotter_item['type'] == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) { |
|
| 380 | + if (isset($spotter_item['type']) && ($spotter_item['type'] == '50' Performance Cruiser' || $spotter_item['type'] == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) { |
|
| 381 | 381 | if ($compress) $output .= '"as": "50perfcruiser.png",'; |
| 382 | 382 | else $output .= '"aircraft_shadow": "50perfcruiser.png",'; |
| 383 | - } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Sailaway Cruiser 38') { |
|
| 383 | + } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Sailaway Cruiser 38') { |
|
| 384 | 384 | if ($compress) $output .= '"as": "cruiser38.png",'; |
| 385 | 385 | else $output .= '"aircraft_shadow": "cruiser38.png",'; |
| 386 | - } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Mini Transat') { |
|
| 386 | + } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Mini Transat') { |
|
| 387 | 387 | if ($compress) $output .= '"as": "transat.png",'; |
| 388 | 388 | else $output .= '"aircraft_shadow": "transat.png",'; |
| 389 | - } elseif (isset($spotter_item['type']) && $spotter_item['type'] == '52' Cruising Cat') { |
|
| 389 | + } elseif (isset($spotter_item['type']) && $spotter_item['type'] == '52' Cruising Cat') { |
|
| 390 | 390 | if ($compress) $output .= '"as": "catamaran.png",'; |
| 391 | 391 | else $output .= '"aircraft_shadow": "catamaran.png",'; |
| 392 | - } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Caribbean Rose') { |
|
| 392 | + } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Caribbean Rose') { |
|
| 393 | 393 | if ($compress) $output .= '"as": "carib.png",'; |
| 394 | 394 | else $output .= '"aircraft_shadow": "carib.png",'; |
| 395 | - } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Nordic Folkboat') { |
|
| 395 | + } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Nordic Folkboat') { |
|
| 396 | 396 | if ($compress) $output .= '"as": "nordic.png",'; |
| 397 | 397 | else $output .= '"aircraft_shadow": "nordic.png",'; |
| 398 | - } elseif (isset($spotter_item['type']) && $spotter_item['type'] == '32' Offshore Racer') { |
|
| 398 | + } elseif (isset($spotter_item['type']) && $spotter_item['type'] == '32' Offshore Racer') { |
|
| 399 | 399 | if ($compress) $output .= '"as": "nordic.png",'; |
| 400 | 400 | else $output .= '"aircraft_shadow": "50perfcruiser.png",'; |
| 401 | 401 | } else { |
@@ -461,15 +461,15 @@ discard block |
||
| 461 | 461 | if (isset($archivespeed) || $usenextlatlon) { |
| 462 | 462 | if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
| 463 | 463 | if (isset($spotter_item['arrival_airport_latitude'])) { |
| 464 | - $cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']); |
|
| 465 | - $idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']); |
|
| 464 | + $cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']); |
|
| 465 | + $idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']); |
|
| 466 | 466 | $farr_lat = $spotter_item['arrival_airport_latitude']; |
| 467 | 467 | $farr_lon = $spotter_item['arrival_airport_longitude']; |
| 468 | 468 | } else { |
| 469 | 469 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
| 470 | 470 | if (isset($aairport[0]['latitude'])) { |
| 471 | - $cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']); |
|
| 472 | - $idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']); |
|
| 471 | + $cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']); |
|
| 472 | + $idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']); |
|
| 473 | 473 | $farr_lat = $aairport[0]['latitude']; |
| 474 | 474 | $farr_lon = $aairport[0]['longitude']; |
| 475 | 475 | } |
@@ -482,59 +482,59 @@ discard block |
||
| 482 | 482 | if ($currenttime != '') { |
| 483 | 483 | if (strtotime($spotter_item['date']) < $currenttime) { |
| 484 | 484 | if (isset($archivespeed)) { |
| 485 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
| 486 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 485 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
| 486 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 487 | 487 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 488 | 488 | else { |
| 489 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
| 490 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 489 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
| 490 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 491 | 491 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 492 | 492 | else { |
| 493 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
|
| 493 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed); |
|
| 494 | 494 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 495 | 495 | } |
| 496 | 496 | } |
| 497 | 497 | } elseif ($usenextlatlon) { |
| 498 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
| 499 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 498 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
| 499 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 500 | 500 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 501 | 501 | else { |
| 502 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
|
| 503 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 502 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh)); |
|
| 503 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 504 | 504 | if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 505 | 505 | else { |
| 506 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
|
| 506 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading); |
|
| 507 | 507 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 508 | 508 | } |
| 509 | 509 | } |
| 510 | 510 | } |
| 511 | 511 | } else { |
| 512 | 512 | if (isset($archivespeed)) { |
| 513 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
|
| 513 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed); |
|
| 514 | 514 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 515 | 515 | } elseif ($usenextlatlon) { |
| 516 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
|
| 516 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading); |
|
| 517 | 517 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 518 | 518 | } |
| 519 | 519 | } |
| 520 | 520 | } else { |
| 521 | 521 | if (isset($archivespeed)) { |
| 522 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
|
| 523 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 522 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed); |
|
| 523 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 524 | 524 | if (!isset($idistance) || $fdistance < $idistance) { |
| 525 | 525 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 526 | 526 | } else { |
| 527 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed); |
|
| 527 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed); |
|
| 528 | 528 | //$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
| 529 | 529 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 530 | 530 | } |
| 531 | 531 | } elseif ($usenextlatlon) { |
| 532 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
|
| 533 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 532 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading); |
|
| 533 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 534 | 534 | if (!isset($idistance) || $fdistance < $idistance) { |
| 535 | 535 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 536 | 536 | } else { |
| 537 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading); |
|
| 537 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading); |
|
| 538 | 538 | //$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
| 539 | 539 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 540 | 540 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | if (!$min) $output .= '"image": "'.$image.'",'; |
| 545 | 545 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 546 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
| 546 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
| 547 | 547 | } |
| 548 | 548 | if (isset($spotter_item['image_source_website'])) { |
| 549 | 549 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
| 578 | 578 | } |
| 579 | 579 | if (isset($spotter_item['acars'])) { |
| 580 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
| 580 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
| 581 | 581 | } |
| 582 | 582 | // type when not aircraft ? |
| 583 | 583 | if (isset($spotter_item['type'])) { |
@@ -597,12 +597,12 @@ discard block |
||
| 597 | 597 | if ($currenttime != '') { |
| 598 | 598 | if (strtotime($spotter_item['date']) < $currenttime) { |
| 599 | 599 | if (!isset($archivespeed)) $archivespeed = 1; |
| 600 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
|
| 601 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 600 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']))); |
|
| 601 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 602 | 602 | if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
| 603 | 603 | else { |
| 604 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
|
| 605 | - $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
|
| 604 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']))); |
|
| 605 | + $fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']); |
|
| 606 | 606 | if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
| 607 | 607 | else { |
| 608 | 608 | $output .= $spotter_item['longitude'].', '; |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | |
| 682 | 682 | } |
| 683 | 683 | */ |
| 684 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
| 684 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
| 685 | 685 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
| 686 | 686 | |
| 687 | 687 | if ( |
@@ -689,11 +689,11 @@ discard block |
||
| 689 | 689 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
| 690 | 690 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
| 691 | 691 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
| 692 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 692 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
| 693 | 693 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
| 694 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
| 694 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
| 695 | 695 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
| 696 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
| 696 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
| 697 | 697 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
| 698 | 698 | ) { |
| 699 | 699 | if ($tracker) { |
@@ -722,9 +722,9 @@ discard block |
||
| 722 | 722 | require(dirname(__FILE__).'/require/class.MapMatching.php'); |
| 723 | 723 | $MapMatching = new MapMatching(); |
| 724 | 724 | if (isset($spotter_item['date_iso_8601'])) { |
| 725 | - $spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date_iso_8601']))))); |
|
| 725 | + $spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date_iso_8601']))))); |
|
| 726 | 726 | } else { |
| 727 | - $spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date']))))); |
|
| 727 | + $spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date']))))); |
|
| 728 | 728 | } |
| 729 | 729 | $spotter_history_array = $MapMatching->match($spotter_history_array_mm); |
| 730 | 730 | } |
@@ -757,9 +757,9 @@ discard block |
||
| 757 | 757 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
| 758 | 758 | } |
| 759 | 759 | $output_history .= '['; |
| 760 | - $output_history .= $spotter_history['longitude'].', '; |
|
| 761 | - $output_history .= $spotter_history['latitude'].', '; |
|
| 762 | - $output_history .= $spotter_history['altitude']*30.48; |
|
| 760 | + $output_history .= $spotter_history['longitude'].', '; |
|
| 761 | + $output_history .= $spotter_history['latitude'].', '; |
|
| 762 | + $output_history .= $spotter_history['altitude']*30.48; |
|
| 763 | 763 | $output_history .= '],'; |
| 764 | 764 | /* |
| 765 | 765 | if ($from_archive === false) { |
@@ -782,8 +782,8 @@ discard block |
||
| 782 | 782 | $d = true; |
| 783 | 783 | } |
| 784 | 784 | $output_history .= '['; |
| 785 | - $output_history .= $spotter_history['longitude'].', '; |
|
| 786 | - $output_history .= $spotter_history['latitude']; |
|
| 785 | + $output_history .= $spotter_history['longitude'].', '; |
|
| 786 | + $output_history .= $spotter_history['latitude']; |
|
| 787 | 787 | $output_history .= '],'; |
| 788 | 788 | /* |
| 789 | 789 | if ($from_archive === false) { |
@@ -799,9 +799,9 @@ discard block |
||
| 799 | 799 | //echo $output_history; |
| 800 | 800 | if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) { |
| 801 | 801 | $output_historyd = '['; |
| 802 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
| 803 | - $output_historyd .= $spotter_item['latitude']; |
|
| 804 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
| 802 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
| 803 | + $output_historyd .= $spotter_item['latitude']; |
|
| 804 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
| 805 | 805 | $output_historyd .= '],'; |
| 806 | 806 | //$output_history = $output_historyd.$output_history; |
| 807 | 807 | $output_history = $output_history.$output_historyd; |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | $last = array_pop($spotter_history_array); |
| 810 | 810 | $latitude = $last['latitude']; |
| 811 | 811 | $longitude = $last['longitude']; |
| 812 | - $output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output); |
|
| 812 | + $output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | $output_history = substr($output_history, 0, -1); |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 824 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
| 825 | 825 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
| 826 | 826 | && (isset($spotter_item['departure_airport']) |
| 827 | 827 | && $spotter_item['departure_airport'] != 'NA' |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | |
| 856 | 856 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
| 857 | 857 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
| 858 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
| 858 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
| 859 | 859 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
| 860 | 860 | && (isset($spotter_item['arrival_airport']) |
| 861 | 861 | && $spotter_item['arrival_airport'] != 'NA' |
@@ -882,11 +882,11 @@ discard block |
||
| 882 | 882 | } |
| 883 | 883 | } |
| 884 | 884 | if ($havedata) { |
| 885 | - $line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon); |
|
| 885 | + $line = $Common->greatCircle($spotter_item['latitude'], $spotter_item['longitude'], $end_lat, $end_lon); |
|
| 886 | 886 | foreach ($line[0] as $coord) { |
| 887 | 887 | $output_dest .= '['.$coord[0].','.$coord[1].'],'; |
| 888 | 888 | } |
| 889 | - $output_dest = substr($output_dest, 0, -1); |
|
| 889 | + $output_dest = substr($output_dest, 0, -1); |
|
| 890 | 890 | } |
| 891 | 891 | $output_dest .= ']}},'; |
| 892 | 892 | if ($havedata) $output .= $output_dest; |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | $output = substr($output, 0, -1); |
| 897 | 897 | $output .= ']'; |
| 898 | 898 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 899 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
| 899 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
| 900 | 900 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
| 901 | 901 | $output .= '"fc": "'.$j.'"'; |
| 902 | 902 | } else { |
@@ -59,20 +59,20 @@ discard block |
||
| 59 | 59 | die; |
| 60 | 60 | } |
| 61 | 61 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 62 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
| 62 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
|
| 66 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); |
|
| 67 | 67 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 68 | 68 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 69 | 69 | if (isset($options['s'])) { |
| 70 | 70 | $globalSources = array(); |
| 71 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
| 71 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
| 72 | 72 | else $globalSources[] = array('host' => $options['s']); |
| 73 | 73 | } elseif (isset($options['source'])) { |
| 74 | 74 | $globalSources = array(); |
| 75 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
| 75 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
| 76 | 76 | else $globalSources[] = array('host' => $options['source']); |
| 77 | 77 | } |
| 78 | 78 | if (isset($options['aprsserverhost'])) { |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | else $id_source = 1; |
| 114 | 114 | if (isset($globalServer) && $globalServer) { |
| 115 | 115 | if ($globalDebug) echo "Using Server Mode\n"; |
| 116 | - $SI=new SpotterServer(); |
|
| 116 | + $SI = new SpotterServer(); |
|
| 117 | 117 | /* |
| 118 | 118 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 119 | 119 | $SI = new adsb2aprs(); |
| 120 | 120 | $SI->connect(); |
| 121 | 121 | */ |
| 122 | -} else $SI=new SpotterImport($Connection->db); |
|
| 122 | +} else $SI = new SpotterImport($Connection->db); |
|
| 123 | 123 | |
| 124 | 124 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
| 125 | 125 | if (isset($globalMarine) && $globalMarine) { |
@@ -133,17 +133,17 @@ discard block |
||
| 133 | 133 | $MI = new MarineImport($Connection->db); |
| 134 | 134 | } |
| 135 | 135 | //$APRS=new APRS($Connection->db); |
| 136 | -$SBS=new SBS(); |
|
| 136 | +$SBS = new SBS(); |
|
| 137 | 137 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 138 | - $ACARS=new ACARS($Connection->db,true); |
|
| 139 | - $Source=new Source($Connection->db); |
|
| 138 | + $ACARS = new ACARS($Connection->db, true); |
|
| 139 | + $Source = new Source($Connection->db); |
|
| 140 | 140 | } |
| 141 | -$Common=new Common(); |
|
| 141 | +$Common = new Common(); |
|
| 142 | 142 | date_default_timezone_set('UTC'); |
| 143 | 143 | //$servertz = system('date +%Z'); |
| 144 | 144 | // signal handler - playing nice with sockets and dump1090 |
| 145 | 145 | if (function_exists('pcntl_fork')) { |
| 146 | - pcntl_signal(SIGINT, function() { |
|
| 146 | + pcntl_signal(SIGINT, function() { |
|
| 147 | 147 | global $sockets; |
| 148 | 148 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 149 | 149 | die("Bye!\n"); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | function connect_all($hosts) { |
| 161 | 161 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 162 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
| 162 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
| 163 | 163 | $reset++; |
| 164 | 164 | if ($globalDebug) echo 'Connect to all...'."\n"; |
| 165 | 165 | foreach ($hosts as $id => $value) { |
@@ -167,33 +167,33 @@ discard block |
||
| 167 | 167 | $udp = false; |
| 168 | 168 | $globalSources[$id]['last_exec'] = 0; |
| 169 | 169 | // Here we check type of source(s) |
| 170 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 171 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 170 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 171 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 172 | 172 | //$formats[$id] = 'deltadbtxt'; |
| 173 | 173 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 174 | 174 | //$last_exec['deltadbtxt'] = 0; |
| 175 | 175 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 176 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 176 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 177 | 177 | //$formats[$id] = 'vatsimtxt'; |
| 178 | 178 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 179 | 179 | //$last_exec['vatsimtxt'] = 0; |
| 180 | 180 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 181 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 181 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 182 | 182 | //$formats[$id] = 'aircraftlistjson'; |
| 183 | 183 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 184 | 184 | //$last_exec['aircraftlistjson'] = 0; |
| 185 | 185 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 186 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
| 186 | + } else if (preg_match('/aircraft.json$/i', $host)) { |
|
| 187 | 187 | //$formats[$id] = 'aircraftjson'; |
| 188 | 188 | $globalSources[$id]['format'] = 'aircraftjson'; |
| 189 | 189 | //$last_exec['aircraftlistjson'] = 0; |
| 190 | 190 | if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
| 191 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
| 191 | + } else if (preg_match('/aircraft$/i', $host)) { |
|
| 192 | 192 | //$formats[$id] = 'planefinderclient'; |
| 193 | 193 | $globalSources[$id]['format'] = 'planefinderclient'; |
| 194 | 194 | //$last_exec['aircraftlistjson'] = 0; |
| 195 | 195 | if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
| 196 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 196 | + } else if (preg_match('/opensky/i', $host)) { |
|
| 197 | 197 | //$formats[$id] = 'aircraftlistjson'; |
| 198 | 198 | $globalSources[$id]['format'] = 'opensky'; |
| 199 | 199 | //$last_exec['aircraftlistjson'] = 0; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | exit(0); |
| 211 | 211 | } |
| 212 | 212 | */ |
| 213 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 213 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 214 | 214 | //$formats[$id] = 'planeupdatefaa'; |
| 215 | 215 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 216 | 216 | //$last_exec['planeupdatefaa'] = 0; |
@@ -219,37 +219,37 @@ discard block |
||
| 219 | 219 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 220 | 220 | exit(0); |
| 221 | 221 | } |
| 222 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 222 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 223 | 223 | //$formats[$id] = 'phpvmacars'; |
| 224 | 224 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 225 | 225 | //$last_exec['phpvmacars'] = 0; |
| 226 | 226 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 227 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
| 227 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { |
|
| 228 | 228 | //$formats[$id] = 'phpvmacars'; |
| 229 | 229 | $globalSources[$id]['format'] = 'vaos'; |
| 230 | 230 | //$last_exec['phpvmacars'] = 0; |
| 231 | 231 | if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
| 232 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 232 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
| 233 | 233 | //$formats[$id] = 'phpvmacars'; |
| 234 | 234 | $globalSources[$id]['format'] = 'vam'; |
| 235 | 235 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
| 236 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 236 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 237 | 237 | //$formats[$id] = 'whazzup'; |
| 238 | 238 | $globalSources[$id]['format'] = 'whazzup'; |
| 239 | 239 | //$last_exec['whazzup'] = 0; |
| 240 | 240 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 241 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
| 241 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
| 242 | 242 | $globalSources[$id]['format'] = 'blitzortung'; |
| 243 | 243 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
| 244 | - } else if (preg_match('/airwhere/i',$host)) { |
|
| 244 | + } else if (preg_match('/airwhere/i', $host)) { |
|
| 245 | 245 | $globalSources[$id]['format'] = 'airwhere'; |
| 246 | 246 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
| 247 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 247 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 248 | 248 | //$formats[$id] = 'pirepsjson'; |
| 249 | 249 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 250 | 250 | //$last_exec['pirepsjson'] = 0; |
| 251 | 251 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 252 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 252 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 253 | 253 | //$formats[$id] = 'fr24json'; |
| 254 | 254 | $globalSources[$id]['format'] = 'fr24json'; |
| 255 | 255 | //$last_exec['fr24json'] = 0; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 259 | 259 | exit(0); |
| 260 | 260 | } |
| 261 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
| 261 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
| 262 | 262 | //$formats[$id] = 'fr24json'; |
| 263 | 263 | $globalSources[$id]['format'] = 'myshiptracking'; |
| 264 | 264 | //$last_exec['fr24json'] = 0; |
@@ -268,14 +268,14 @@ discard block |
||
| 268 | 268 | exit(0); |
| 269 | 269 | } |
| 270 | 270 | //} else if (preg_match('/10001/',$host)) { |
| 271 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 271 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 272 | 272 | //$formats[$id] = 'tsv'; |
| 273 | 273 | $globalSources[$id]['format'] = 'tsv'; |
| 274 | 274 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 275 | 275 | } |
| 276 | - } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
| 276 | + } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) { |
|
| 277 | 277 | if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') { |
| 278 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
| 278 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
| 279 | 279 | if ($idf !== false) { |
| 280 | 280 | $httpfeeds[$id] = $idf; |
| 281 | 281 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | } elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n"; |
| 284 | 284 | elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailawayfull') echo "Connect to ".$globalSources[$id]['format']." source (sailawayfull)...\n"; |
| 285 | 285 | elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 286 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 287 | - $hostport = explode(':',$host); |
|
| 286 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 287 | + $hostport = explode(':', $host); |
|
| 288 | 288 | if (isset($hostport[1])) { |
| 289 | 289 | $port = $hostport[1]; |
| 290 | 290 | $hostn = $hostport[0]; |
@@ -294,20 +294,20 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | $Common = new Common(); |
| 296 | 296 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
| 297 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
| 297 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
| 298 | 298 | } else { |
| 299 | 299 | $udp = true; |
| 300 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 300 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
| 301 | 301 | } |
| 302 | 302 | if ($s) { |
| 303 | 303 | $sockets[$id] = $s; |
| 304 | 304 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 305 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
| 305 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
| 306 | 306 | //$formats[$id] = 'aprs'; |
| 307 | 307 | $globalSources[$id]['format'] = 'aprs'; |
| 308 | 308 | //$aprs_connect = 0; |
| 309 | 309 | //$use_aprs = true; |
| 310 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 310 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
| 311 | 311 | $globalSources[$id]['format'] = 'vrstcp'; |
| 312 | 312 | } elseif ($port == '10001') { |
| 313 | 313 | //$formats[$id] = 'tsv'; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 350 | 350 | else $timeout = 20; |
| 351 | 351 | $errno = ''; |
| 352 | -$errstr=''; |
|
| 352 | +$errstr = ''; |
|
| 353 | 353 | |
| 354 | 354 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 355 | 355 | /* Initiate connections to all the hosts simultaneously */ |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | //connect_all($globalSources); |
| 358 | 358 | |
| 359 | 359 | if (isset($globalProxy) && $globalProxy) { |
| 360 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
| 360 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
| 361 | 361 | } else { |
| 362 | 362 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
| 363 | 363 | } |
@@ -387,16 +387,16 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | if ($use_aprs) { |
| 389 | 389 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 390 | - $APRS=new APRS(); |
|
| 390 | + $APRS = new APRS(); |
|
| 391 | 391 | $aprs_connect = 0; |
| 392 | 392 | $aprs_keep = 120; |
| 393 | 393 | $aprs_last_tx = time(); |
| 394 | 394 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 395 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 395 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 396 | 396 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
| 397 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 397 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 398 | 398 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 399 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 399 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 400 | 400 | if ($aprs_full) $aprs_filter = ''; |
| 401 | 401 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
| 402 | 402 | else $aprs_pass = '-1'; |
@@ -410,12 +410,12 @@ discard block |
||
| 410 | 410 | sleep(1); |
| 411 | 411 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 412 | 412 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 413 | -$endtime = time()+$globalCronEnd; |
|
| 413 | +$endtime = time() + $globalCronEnd; |
|
| 414 | 414 | $i = 1; |
| 415 | 415 | $tt = array(); |
| 416 | 416 | // Delete all ATC |
| 417 | 417 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 418 | - $ATC=new ATC($Connection->db); |
|
| 418 | + $ATC = new ATC($Connection->db); |
|
| 419 | 419 | } |
| 420 | 420 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 421 | 421 | $ATC->deleteAll(); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | while ($i > 0) { |
| 426 | 426 | if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 427 | 427 | |
| 428 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 428 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 429 | 429 | // Delete old ATC |
| 430 | 430 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 431 | 431 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | if ($max < $globalMinFetch) { |
| 441 | 441 | if ($globalDebug) echo 'Sleeping...'."\n"; |
| 442 | - sleep($globalMinFetch-$max+2); |
|
| 442 | + sleep($globalMinFetch - $max + 2); |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
@@ -494,10 +494,10 @@ discard block |
||
| 494 | 494 | //$buffer = $Common->getData($hosts[$id]); |
| 495 | 495 | $buffer = $Common->getData($value['host']); |
| 496 | 496 | if ($buffer != '') { |
| 497 | - $all_data = json_decode($buffer,true); |
|
| 497 | + $all_data = json_decode($buffer, true); |
|
| 498 | 498 | foreach ($all_data as $line) { |
| 499 | 499 | $data = array(); |
| 500 | - $data['datetime'] = date('Y-m-d H:i:s',$line['uti']); |
|
| 500 | + $data['datetime'] = date('Y-m-d H:i:s', $line['uti']); |
|
| 501 | 501 | $data['hex'] = $line['hex']; // hex |
| 502 | 502 | $data['ident'] = $line['fli']; // ident |
| 503 | 503 | $data['altitude'] = $line['alt']; // altitude |
@@ -532,11 +532,11 @@ discard block |
||
| 532 | 532 | ) |
| 533 | 533 | ) { |
| 534 | 534 | date_default_timezone_set('CET'); |
| 535 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
| 535 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
| 536 | 536 | date_default_timezone_set('UTC'); |
| 537 | 537 | if ($buffer != '') $reset = 0; |
| 538 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 539 | - $buffer = explode('\n',$buffer); |
|
| 538 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 539 | + $buffer = explode('\n', $buffer); |
|
| 540 | 540 | foreach ($buffer as $line) { |
| 541 | 541 | if ($line != '') { |
| 542 | 542 | //echo "'".$line."'\n"; |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | $ais_data = $AIS->parse_line(trim($line)); |
| 545 | 545 | $data = array(); |
| 546 | 546 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
| 547 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 547 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
| 548 | 548 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
| 549 | 549 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
| 550 | 550 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 557 | 557 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 558 | 558 | if (isset($ais_data['timestamp'])) { |
| 559 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 559 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 560 | 560 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
| 561 | 561 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
| 562 | 562 | $add = true; |
@@ -579,21 +579,21 @@ discard block |
||
| 579 | 579 | $w = $e = null; |
| 580 | 580 | |
| 581 | 581 | if (isset($arr[$id])) { |
| 582 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 582 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 583 | 583 | if ($nn > 0) { |
| 584 | 584 | foreach ($httpfeeds as $feed) { |
| 585 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 585 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 586 | 586 | if ($buffer === FALSE) { |
| 587 | 587 | connect_all($globalSources); |
| 588 | 588 | } |
| 589 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 590 | - $buffer = explode('\n',$buffer); |
|
| 589 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 590 | + $buffer = explode('\n', $buffer); |
|
| 591 | 591 | foreach ($buffer as $line) { |
| 592 | 592 | if ($line != '') { |
| 593 | 593 | $ais_data = $AIS->parse_line(trim($line)); |
| 594 | 594 | $data = array(); |
| 595 | 595 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
| 596 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 596 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
| 597 | 597 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
| 598 | 598 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
| 599 | 599 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -605,9 +605,9 @@ discard block |
||
| 605 | 605 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 606 | 606 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 607 | 607 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 608 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 608 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 609 | 609 | if (isset($ais_data['timestamp'])) { |
| 610 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 610 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 611 | 611 | } else { |
| 612 | 612 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 613 | 613 | } |
@@ -639,10 +639,10 @@ discard block |
||
| 639 | 639 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 640 | 640 | ) |
| 641 | 641 | ) { |
| 642 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 642 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 643 | 643 | if ($buffer != '') { |
| 644 | 644 | //echo $buffer; |
| 645 | - $all_data = json_decode($buffer,true); |
|
| 645 | + $all_data = json_decode($buffer, true); |
|
| 646 | 646 | //print_r($all_data); |
| 647 | 647 | if (isset($all_data[0]['DATA'])) { |
| 648 | 648 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | $data['ident'] = $line['NAME']; |
| 652 | 652 | $data['mmsi'] = $line['MMSI']; |
| 653 | 653 | if (strlen($data['mmsi']) > 9) { |
| 654 | - $data['mmsi'] = substr($data['mmsi'],-9); |
|
| 654 | + $data['mmsi'] = substr($data['mmsi'], -9); |
|
| 655 | 655 | } |
| 656 | 656 | $data['speed'] = $line['SOG']; |
| 657 | 657 | $data['heading'] = $line['COG']; |
@@ -661,8 +661,8 @@ discard block |
||
| 661 | 661 | //$data['type_id'] = $line['TYPE']; |
| 662 | 662 | $data['imo'] = $line['IMO']; |
| 663 | 663 | if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
| 664 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
| 665 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
| 664 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV'])); |
|
| 665 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
| 666 | 666 | $data['format_source'] = 'myshiptracking'; |
| 667 | 667 | $data['id_source'] = $id_source; |
| 668 | 668 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -679,16 +679,16 @@ discard block |
||
| 679 | 679 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
| 680 | 680 | ) |
| 681 | 681 | ) { |
| 682 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
| 682 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
| 683 | 683 | if ($buffer != '') { |
| 684 | - $all_data = json_decode($buffer,true); |
|
| 684 | + $all_data = json_decode($buffer, true); |
|
| 685 | 685 | if (isset($all_data[0]['mmsi'])) { |
| 686 | 686 | foreach ($all_data as $line) { |
| 687 | 687 | if ($line != '') { |
| 688 | 688 | $data = array(); |
| 689 | 689 | $data['ident'] = $line['shipname']; |
| 690 | 690 | $data['callsign'] = $line['callsign']; |
| 691 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
| 691 | + $data['mmsi'] = substr($line['mmsi'], -9); |
|
| 692 | 692 | $data['speed'] = $line['sog']; |
| 693 | 693 | if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
| 694 | 694 | $data['latitude'] = $line['latitude']; |
@@ -715,14 +715,14 @@ discard block |
||
| 715 | 715 | ) { |
| 716 | 716 | $buffer = $Common->getData($value['host']); |
| 717 | 717 | if ($buffer != '') { |
| 718 | - $all_data = json_decode($buffer,true); |
|
| 718 | + $all_data = json_decode($buffer, true); |
|
| 719 | 719 | if (isset($all_data['features'][0]['id'])) { |
| 720 | 720 | foreach ($all_data['features'] as $line) { |
| 721 | 721 | print_r($line); |
| 722 | 722 | $data = array(); |
| 723 | 723 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
| 724 | 724 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
| 725 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
| 725 | + if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9); |
|
| 726 | 726 | if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
| 727 | 727 | if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
| 728 | 728 | if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
@@ -749,31 +749,31 @@ discard block |
||
| 749 | 749 | ) |
| 750 | 750 | ) { |
| 751 | 751 | if ($globalDebug) echo 'download...'; |
| 752 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
| 752 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
| 753 | 753 | if ($globalDebug) echo 'done !'."\n"; |
| 754 | 754 | // FIXME: Need more work |
| 755 | 755 | if ($buffer != '') $reset = 0; |
| 756 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 757 | - $buffer = explode('\n',$buffer); |
|
| 756 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 757 | + $buffer = explode('\n', $buffer); |
|
| 758 | 758 | foreach ($buffer as $line) { |
| 759 | 759 | if ($line != '') { |
| 760 | 760 | $data = array(); |
| 761 | 761 | //echo $line."\n"; |
| 762 | - $data['mmsi'] = (int)substr($line,0,9); |
|
| 763 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
| 764 | - $data['status_id'] = substr($line,21,2); |
|
| 765 | - $data['type_id'] = substr($line,24,3); |
|
| 766 | - $data['latitude'] = substr($line,29,9); |
|
| 767 | - $data['longitude'] = substr($line,41,9); |
|
| 768 | - $data['speed'] = round(substr($line,51,5)); |
|
| 762 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
| 763 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
| 764 | + $data['status_id'] = substr($line, 21, 2); |
|
| 765 | + $data['type_id'] = substr($line, 24, 3); |
|
| 766 | + $data['latitude'] = substr($line, 29, 9); |
|
| 767 | + $data['longitude'] = substr($line, 41, 9); |
|
| 768 | + $data['speed'] = round(substr($line, 51, 5)); |
|
| 769 | 769 | //$data['course'] = substr($line,57,5); |
| 770 | - $data['heading'] = round(substr($line,63,3)); |
|
| 770 | + $data['heading'] = round(substr($line, 63, 3)); |
|
| 771 | 771 | //$data['draft'] = substr($line,67,4); |
| 772 | 772 | //$data['length'] = substr($line,72,3); |
| 773 | 773 | //$data['beam'] = substr($line,76,2); |
| 774 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
| 774 | + $data['ident'] = trim(utf8_encode(substr($line, 78, 20))); |
|
| 775 | 775 | //$data['callsign'] = trim(substr($line,100,7); |
| 776 | - $data['arrival_code'] = substr($line,108,20); |
|
| 776 | + $data['arrival_code'] = substr($line, 108, 20); |
|
| 777 | 777 | //$data['etaDate'] = substr($line,129,5); |
| 778 | 778 | //$data['etaTime'] = substr($line,135,5); |
| 779 | 779 | $data['format_source'] = 'shipplotter'; |
@@ -796,28 +796,28 @@ discard block |
||
| 796 | 796 | exit(0); |
| 797 | 797 | } |
| 798 | 798 | $sailawayoption = array('key' => $globalSailaway['key']); |
| 799 | - if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
| 800 | - if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 799 | + if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr'])); |
|
| 800 | + if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 801 | 801 | |
| 802 | 802 | for ($i = 0; $i <= 1; $i++) { |
| 803 | 803 | if ($globalDebug) echo '! Download... '; |
| 804 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2','get','','','','',30); |
|
| 804 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?'.http_build_query($sailawayoption).'&race='.$i.'&tutorial=0&hist=1&racetype=2&challengetype=2', 'get', '', '', '', '', 30); |
|
| 805 | 805 | if ($globalDebug) echo 'done'."\n"; |
| 806 | 806 | if ($buffer != '') { |
| 807 | - $all_data = json_decode($buffer,true); |
|
| 807 | + $all_data = json_decode($buffer, true); |
|
| 808 | 808 | if (isset($all_data['missions'])) { |
| 809 | 809 | foreach ($all_data['missions'] as $mission) { |
| 810 | 810 | $mission_user = $mission['usrname']; |
| 811 | - $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle'])); |
|
| 812 | - if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) { |
|
| 811 | + $mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle'])); |
|
| 812 | + if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) { |
|
| 813 | 813 | //print_r($mission); |
| 814 | 814 | $datar = array(); |
| 815 | 815 | $datar['id'] = $mission['misnr']; |
| 816 | 816 | $datar['desc'] = $mission['misdescr']; |
| 817 | 817 | //$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['usrname']))); |
| 818 | 818 | $datar['creator'] = ''; |
| 819 | - $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']))); |
|
| 820 | - if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s',strtotime($mission['misstart'])); |
|
| 819 | + $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']))); |
|
| 820 | + if (isset($mission['misstart'])) $datar['startdate'] = date('Y-m-d H:i:s', strtotime($mission['misstart'])); |
|
| 821 | 821 | else $datar['startdate'] = '1970-01-01 00:00:00'; |
| 822 | 822 | /* |
| 823 | 823 | $markers = array(); |
@@ -837,9 +837,9 @@ discard block |
||
| 837 | 837 | if ($globalDebug) echo '=== Wait... ==='; |
| 838 | 838 | sleep(10*60); |
| 839 | 839 | } |
| 840 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
|
| 840 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30); |
|
| 841 | 841 | if ($buffer != '') { |
| 842 | - $data = json_decode($buffer,true); |
|
| 842 | + $data = json_decode($buffer, true); |
|
| 843 | 843 | //print_r($data); |
| 844 | 844 | if (isset($data['boats'])) { |
| 845 | 845 | foreach ($data['boats'] as $sail) { |
@@ -851,12 +851,12 @@ discard block |
||
| 851 | 851 | $data['longitude'] = $sail['ubtlon']; |
| 852 | 852 | $data['type_id'] = 36; |
| 853 | 853 | $data['heading'] = $sail['ubtheading']; |
| 854 | - $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); |
|
| 854 | + $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); |
|
| 855 | 855 | $data['captain_name'] = $sail['usrname']; |
| 856 | - $allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat','32' Offshore Racer'); |
|
| 856 | + $allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52' Cruising Cat', '50' Performance Cruiser', 'Nordic Folkboat', '32' Offshore Racer'); |
|
| 857 | 857 | $boattype = $sail['ubtbtpnr']; |
| 858 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; |
|
| 859 | - $data['speed'] = round($sail['ubtspeed']*3.6,2); |
|
| 858 | + if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1]; |
|
| 859 | + $data['speed'] = round($sail['ubtspeed']*3.6, 2); |
|
| 860 | 860 | $data['format_source'] = 'sailaway'; |
| 861 | 861 | $data['id_source'] = $id_source; |
| 862 | 862 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -889,11 +889,11 @@ discard block |
||
| 889 | 889 | } |
| 890 | 890 | if ($globalDebug) echo '! Download... '; |
| 891 | 891 | $sailawayoption = array('key' => $globalSailaway['key']); |
| 892 | - if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption,array('usrnr' => $globalSailaway['usrnr'])); |
|
| 893 | - if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption,array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 894 | - $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption),'get','','','','',30); |
|
| 892 | + if (isset($globalSailaway['usrnr'])) $sailawayoption = array_merge($sailawayoption, array('usrnr' => $globalSailaway['usrnr'])); |
|
| 893 | + if (isset($globalSailaway['ubtnr'])) $sailawayoption = array_merge($sailawayoption, array('ubtnr' => $globalSailaway['ubtnr'])); |
|
| 894 | + $buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/TrackAllBoats.pl?'.http_build_query($sailawayoption), 'get', '', '', '', '', 30); |
|
| 895 | 895 | if ($buffer != '') { |
| 896 | - $data = json_decode($buffer,true); |
|
| 896 | + $data = json_decode($buffer, true); |
|
| 897 | 897 | //print_r($data); |
| 898 | 898 | if (isset($data['boats'])) { |
| 899 | 899 | foreach ($data['boats'] as $sail) { |
@@ -905,12 +905,12 @@ discard block |
||
| 905 | 905 | $data['longitude'] = $sail['ubtlon']; |
| 906 | 906 | $data['type_id'] = 36; |
| 907 | 907 | $data['heading'] = $sail['ubtheading']; |
| 908 | - $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname']))); |
|
| 908 | + $data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname']))); |
|
| 909 | 909 | $data['captain_name'] = $sail['usrname']; |
| 910 | - $allboats = array('Sailaway Cruiser 38','Mini Transat','Caribbean Rose','52' Cruising Cat','50' Performance Cruiser','Nordic Folkboat','32' Offshore Racer'); |
|
| 910 | + $allboats = array('Sailaway Cruiser 38', 'Mini Transat', 'Caribbean Rose', '52' Cruising Cat', '50' Performance Cruiser', 'Nordic Folkboat', '32' Offshore Racer'); |
|
| 911 | 911 | $boattype = $sail['ubtbtpnr']; |
| 912 | - if (isset($allboats[$boattype-1])) $data['type'] = $allboats[$boattype-1]; |
|
| 913 | - $data['speed'] = round($sail['ubtspeed']*3.6,2); |
|
| 912 | + if (isset($allboats[$boattype - 1])) $data['type'] = $allboats[$boattype - 1]; |
|
| 913 | + $data['speed'] = round($sail['ubtspeed']*3.6, 2); |
|
| 914 | 914 | $data['format_source'] = 'sailaway'; |
| 915 | 915 | $data['id_source'] = $id_source; |
| 916 | 916 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -938,8 +938,8 @@ discard block |
||
| 938 | 938 | ) { |
| 939 | 939 | //$buffer = $Common->getData($hosts[$id]); |
| 940 | 940 | $buffer = $Common->getData($value['host']); |
| 941 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 942 | - $buffer = explode('\n',$buffer); |
|
| 941 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 942 | + $buffer = explode('\n', $buffer); |
|
| 943 | 943 | $reset = 0; |
| 944 | 944 | foreach ($buffer as $line) { |
| 945 | 945 | if ($line != '') { |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 951 | 951 | $data['pilot_id'] = $line[1]; |
| 952 | 952 | $data['pilot_name'] = $line[2]; |
| 953 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
| 953 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
| 954 | 954 | $data['ident'] = $line[0]; // ident |
| 955 | 955 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 956 | 956 | $data['speed'] = $line[8]; // speed |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 967 | 967 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 968 | 968 | $data['departure_airport_icao'] = $line[11]; |
| 969 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 969 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 970 | 970 | $data['arrival_airport_icao'] = $line[13]; |
| 971 | 971 | $data['frequency'] = $line[4]; |
| 972 | 972 | $data['type'] = $line[18]; |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | $data['id_source'] = $id_source; |
| 976 | 976 | //$data['arrival_airport_time'] = ; |
| 977 | 977 | if ($line[9] != '') { |
| 978 | - $aircraft_data = explode('/',$line[9]); |
|
| 978 | + $aircraft_data = explode('/', $line[9]); |
|
| 979 | 979 | if (isset($aircraft_data[1])) { |
| 980 | 980 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 981 | 981 | } |
@@ -990,9 +990,9 @@ discard block |
||
| 990 | 990 | if ($line[3] === 'PILOT') $SI->add($data); |
| 991 | 991 | elseif ($line[3] === 'ATC') { |
| 992 | 992 | //print_r($data); |
| 993 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 994 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 995 | - $typec = substr($data['ident'],-3); |
|
| 993 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 994 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 995 | + $typec = substr($data['ident'], -3); |
|
| 996 | 996 | if ($typec === 'APP') $data['type'] = 'Approach'; |
| 997 | 997 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
| 998 | 998 | elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
@@ -1004,8 +1004,8 @@ discard block |
||
| 1004 | 1004 | elseif ($data['type'] === '') $data['type'] = 'Observer'; |
| 1005 | 1005 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 1006 | 1006 | if (isset($ATC)) { |
| 1007 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1008 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
| 1007 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
| 1008 | + else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
| 1009 | 1009 | } |
| 1010 | 1010 | } |
| 1011 | 1011 | unset($data); |
@@ -1021,24 +1021,24 @@ discard block |
||
| 1021 | 1021 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1022 | 1022 | ) |
| 1023 | 1023 | ) { |
| 1024 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
| 1024 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
| 1025 | 1025 | if ($buffer != '') { |
| 1026 | 1026 | $all_data = simplexml_load_string($buffer); |
| 1027 | - foreach($all_data->children() as $childdata) { |
|
| 1027 | + foreach ($all_data->children() as $childdata) { |
|
| 1028 | 1028 | $data = array(); |
| 1029 | 1029 | $line = $childdata; |
| 1030 | 1030 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
| 1031 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
| 1032 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
| 1033 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
| 1034 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
| 1035 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
| 1036 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
| 1037 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
| 1031 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
| 1032 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
| 1033 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
| 1034 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
| 1035 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
| 1036 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
| 1037 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
| 1038 | 1038 | $data['altitude_relative'] = 'AMSL'; |
| 1039 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
| 1039 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
| 1040 | 1040 | $data['aircraft_icao'] = 'PARAGLIDER'; |
| 1041 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
| 1041 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
| 1042 | 1042 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
| 1043 | 1043 | $data['format_source'] = $value['format']; |
| 1044 | 1044 | $SI->add($data); |
@@ -1046,22 +1046,22 @@ discard block |
||
| 1046 | 1046 | } |
| 1047 | 1047 | } |
| 1048 | 1048 | $Source->deleteOldLocationByType('gs'); |
| 1049 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
| 1049 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
| 1050 | 1050 | if ($buffer != '') { |
| 1051 | 1051 | $all_data = simplexml_load_string($buffer); |
| 1052 | - foreach($all_data->children() as $childdata) { |
|
| 1052 | + foreach ($all_data->children() as $childdata) { |
|
| 1053 | 1053 | $data = array(); |
| 1054 | 1054 | $line = $childdata; |
| 1055 | - $data['id'] = (int)$line['gsID']; |
|
| 1056 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
| 1057 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
| 1058 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
| 1055 | + $data['id'] = (int) $line['gsID']; |
|
| 1056 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
| 1057 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
| 1058 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
| 1059 | 1059 | $data['altitude_relative'] = 'AMSL'; |
| 1060 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
| 1060 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
| 1061 | 1061 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
| 1062 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
| 1062 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
| 1063 | 1063 | } else { |
| 1064 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
| 1064 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
| 1065 | 1065 | } |
| 1066 | 1066 | unset($data); |
| 1067 | 1067 | } |
@@ -1079,9 +1079,9 @@ discard block |
||
| 1079 | 1079 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
| 1080 | 1080 | ) |
| 1081 | 1081 | ) { |
| 1082 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 1082 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 1083 | 1083 | if ($buffer != '') { |
| 1084 | - $all_data = json_decode($buffer,true); |
|
| 1084 | + $all_data = json_decode($buffer, true); |
|
| 1085 | 1085 | if (isset($all_data['acList'])) { |
| 1086 | 1086 | $reset = 0; |
| 1087 | 1087 | foreach ($all_data['acList'] as $line) { |
@@ -1097,7 +1097,7 @@ discard block |
||
| 1097 | 1097 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
| 1098 | 1098 | $data['emergency'] = ''; // emergency |
| 1099 | 1099 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
| 1100 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1100 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
| 1101 | 1101 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1102 | 1102 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1103 | 1103 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | $data['verticalrate'] = $line['vrt']; // verticale rate |
| 1123 | 1123 | $data['squawk'] = $line['squawk']; // squawk |
| 1124 | 1124 | $data['emergency'] = ''; // emergency |
| 1125 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
| 1125 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
| 1126 | 1126 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1127 | 1127 | $data['format_source'] = 'aircraftlistjson'; |
| 1128 | 1128 | $data['id_source'] = $id_source; |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | ) |
| 1144 | 1144 | ) { |
| 1145 | 1145 | $buffer = $Common->getData($value['host']); |
| 1146 | - $all_data = json_decode($buffer,true); |
|
| 1146 | + $all_data = json_decode($buffer, true); |
|
| 1147 | 1147 | if (isset($all_data['planes'])) { |
| 1148 | 1148 | $reset = 0; |
| 1149 | 1149 | foreach ($all_data['planes'] as $key => $line) { |
@@ -1160,12 +1160,12 @@ discard block |
||
| 1160 | 1160 | $data['emergency'] = ''; // emergency |
| 1161 | 1161 | $data['registration'] = $line[2]; |
| 1162 | 1162 | $data['aircraft_icao'] = $line[0]; |
| 1163 | - $deparr = explode('-',$line[1]); |
|
| 1163 | + $deparr = explode('-', $line[1]); |
|
| 1164 | 1164 | if (count($deparr) === 2) { |
| 1165 | 1165 | $data['departure_airport_icao'] = $deparr[0]; |
| 1166 | 1166 | $data['arrival_airport_icao'] = $deparr[1]; |
| 1167 | 1167 | } |
| 1168 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 1168 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 1169 | 1169 | $data['format_source'] = 'planeupdatefaa'; |
| 1170 | 1170 | $data['id_source'] = $id_source; |
| 1171 | 1171 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | ) |
| 1184 | 1184 | ) { |
| 1185 | 1185 | $buffer = $Common->getData($value['host']); |
| 1186 | - $all_data = json_decode($buffer,true); |
|
| 1186 | + $all_data = json_decode($buffer, true); |
|
| 1187 | 1187 | if (isset($all_data['states'])) { |
| 1188 | 1188 | $reset = 0; |
| 1189 | 1189 | foreach ($all_data['states'] as $key => $line) { |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | //$data['emergency'] = ''; // emergency |
| 1201 | 1201 | //$data['registration'] = $line[2]; |
| 1202 | 1202 | //$data['aircraft_icao'] = $line[0]; |
| 1203 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 1203 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 1204 | 1204 | $data['format_source'] = 'opensky'; |
| 1205 | 1205 | $data['id_source'] = $id_source; |
| 1206 | 1206 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1217,8 +1217,8 @@ discard block |
||
| 1217 | 1217 | ) |
| 1218 | 1218 | ) { |
| 1219 | 1219 | $buffer = $Common->getData($value['host']); |
| 1220 | - $all_data = json_decode($buffer,true); |
|
| 1221 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
| 1220 | + $all_data = json_decode($buffer, true); |
|
| 1221 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) { |
|
| 1222 | 1222 | $reset = 0; |
| 1223 | 1223 | foreach ($all_data['aircraft'] as $key => $line) { |
| 1224 | 1224 | $data = array(); |
@@ -1256,7 +1256,7 @@ discard block |
||
| 1256 | 1256 | ) |
| 1257 | 1257 | ) { |
| 1258 | 1258 | $buffer = $Common->getData($value['host']); |
| 1259 | - $all_data = json_decode($buffer,true); |
|
| 1259 | + $all_data = json_decode($buffer, true); |
|
| 1260 | 1260 | if (isset($all_data['aircraft'])) { |
| 1261 | 1261 | $reset = 0; |
| 1262 | 1262 | foreach ($all_data['aircraft'] as $key => $line) { |
@@ -1273,7 +1273,7 @@ discard block |
||
| 1273 | 1273 | //$data['emergency'] = ''; // emergency |
| 1274 | 1274 | if (isset($line['reg'])) $data['registration'] = $line['reg']; |
| 1275 | 1275 | if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
| 1276 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
| 1276 | + $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']); |
|
| 1277 | 1277 | $data['format_source'] = 'planefinderclient'; |
| 1278 | 1278 | $data['id_source'] = $id_source; |
| 1279 | 1279 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -1292,7 +1292,7 @@ discard block |
||
| 1292 | 1292 | ) { |
| 1293 | 1293 | //$buffer = $Common->getData($hosts[$id]); |
| 1294 | 1294 | $buffer = $Common->getData($value['host']); |
| 1295 | - $all_data = json_decode($buffer,true); |
|
| 1295 | + $all_data = json_decode($buffer, true); |
|
| 1296 | 1296 | if (!empty($all_data)) $reset = 0; |
| 1297 | 1297 | foreach ($all_data as $key => $line) { |
| 1298 | 1298 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1330,11 +1330,11 @@ discard block |
||
| 1330 | 1330 | ) |
| 1331 | 1331 | ) { |
| 1332 | 1332 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 1333 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 1333 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 1334 | 1334 | //echo $buffer; |
| 1335 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 1336 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 1337 | - $all_data = json_decode($buffer,true); |
|
| 1335 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 1336 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 1337 | + $all_data = json_decode($buffer, true); |
|
| 1338 | 1338 | if (json_last_error() != JSON_ERROR_NONE) { |
| 1339 | 1339 | die(json_last_error_msg()); |
| 1340 | 1340 | } |
@@ -1357,7 +1357,7 @@ discard block |
||
| 1357 | 1357 | //$data['departure_airport_iata'] = $line[11]; |
| 1358 | 1358 | //$data['arrival_airport_iata'] = $line[12]; |
| 1359 | 1359 | //$data['emergency'] = ''; // emergency |
| 1360 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 1360 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 1361 | 1361 | $data['format_source'] = 'radarvirtueljson'; |
| 1362 | 1362 | $data['id_source'] = $id_source; |
| 1363 | 1363 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1378,14 +1378,14 @@ discard block |
||
| 1378 | 1378 | ) { |
| 1379 | 1379 | //$buffer = $Common->getData($hosts[$id]); |
| 1380 | 1380 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 1381 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 1381 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 1382 | 1382 | |
| 1383 | 1383 | if (isset($all_data['pireps'])) { |
| 1384 | 1384 | $reset = 0; |
| 1385 | 1385 | foreach ($all_data['pireps'] as $line) { |
| 1386 | 1386 | $data = array(); |
| 1387 | 1387 | $data['id'] = $line['id']; |
| 1388 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1388 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1389 | 1389 | $data['ident'] = $line['callsign']; // ident |
| 1390 | 1390 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 1391 | 1391 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1415,9 +1415,9 @@ discard block |
||
| 1415 | 1415 | $SI->add($data); |
| 1416 | 1416 | // print_r($data); |
| 1417 | 1417 | } elseif ($line['icon'] === 'ct') { |
| 1418 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 1419 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 1420 | - $typec = substr($data['ident'],-3); |
|
| 1418 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 1419 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 1420 | + $typec = substr($data['ident'], -3); |
|
| 1421 | 1421 | $data['type'] = ''; |
| 1422 | 1422 | if ($typec === 'APP') $data['type'] = 'Approach'; |
| 1423 | 1423 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
@@ -1428,7 +1428,7 @@ discard block |
||
| 1428 | 1428 | elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
| 1429 | 1429 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 1430 | 1430 | else $data['type'] = 'Observer'; |
| 1431 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
| 1431 | + if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
| 1432 | 1432 | } |
| 1433 | 1433 | unset($data); |
| 1434 | 1434 | } |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | //$buffer = $Common->getData($hosts[$id]); |
| 1446 | 1446 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1447 | 1447 | $buffer = $Common->getData($value['host']); |
| 1448 | - $all_data = json_decode($buffer,true); |
|
| 1448 | + $all_data = json_decode($buffer, true); |
|
| 1449 | 1449 | if ($buffer != '' && is_array($all_data)) { |
| 1450 | 1450 | $reset = 0; |
| 1451 | 1451 | foreach ($all_data as $line) { |
@@ -1453,7 +1453,7 @@ discard block |
||
| 1453 | 1453 | //$data['id'] = $line['id']; // id not usable |
| 1454 | 1454 | if (isset($line['pilotid']) && isset($line['registration'])) $data['id'] = $line['pilotid'].$line['flightnum'].trim($line['registration']); |
| 1455 | 1455 | elseif (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 1456 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1456 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 1457 | 1457 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 1458 | 1458 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 1459 | 1459 | $data['ident'] = $line['flightnum']; // ident |
@@ -1468,7 +1468,7 @@ discard block |
||
| 1468 | 1468 | //$data['datetime'] = $line['lastupdate']; |
| 1469 | 1469 | //$data['last_update'] = $line['lastupdate']; |
| 1470 | 1470 | if (isset($value['timezone'])) { |
| 1471 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
| 1471 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
| 1472 | 1472 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1473 | 1473 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1474 | 1474 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1484,14 +1484,14 @@ discard block |
||
| 1484 | 1484 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 1485 | 1485 | if (isset($line['aircraftname'])) { |
| 1486 | 1486 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 1487 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 1488 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 1487 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 1488 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 1489 | 1489 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
| 1490 | 1490 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
| 1491 | 1491 | else { |
| 1492 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 1493 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
| 1494 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
| 1492 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 1493 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
| 1494 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
| 1495 | 1495 | } |
| 1496 | 1496 | } |
| 1497 | 1497 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1516,7 +1516,7 @@ discard block |
||
| 1516 | 1516 | //$buffer = $Common->getData($hosts[$id]); |
| 1517 | 1517 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1518 | 1518 | $buffer = $Common->getData($value['host']); |
| 1519 | - $all_data = json_decode($buffer,true); |
|
| 1519 | + $all_data = json_decode($buffer, true); |
|
| 1520 | 1520 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
| 1521 | 1521 | $reset = 0; |
| 1522 | 1522 | foreach ($all_data['ACARSData'] as $line) { |
@@ -1527,7 +1527,7 @@ discard block |
||
| 1527 | 1527 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 1528 | 1528 | if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
| 1529 | 1529 | if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
| 1530 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
| 1530 | + $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
| 1531 | 1531 | if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
| 1532 | 1532 | $data['altitude'] = $line['altitude']; // altitude |
| 1533 | 1533 | $data['speed'] = $line['groundspeed']; // speed |
@@ -1538,7 +1538,7 @@ discard block |
||
| 1538 | 1538 | //$data['squawk'] = ''; // squawk |
| 1539 | 1539 | //$data['emergency'] = ''; // emergency |
| 1540 | 1540 | if (isset($value['timezone'])) { |
| 1541 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
| 1541 | + $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
| 1542 | 1542 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
| 1543 | 1543 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 1544 | 1544 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1574,14 +1574,14 @@ discard block |
||
| 1574 | 1574 | //$buffer = $Common->getData($hosts[$id]); |
| 1575 | 1575 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1576 | 1576 | $buffer = $Common->getData($value['host']); |
| 1577 | - $all_data = json_decode($buffer,true); |
|
| 1577 | + $all_data = json_decode($buffer, true); |
|
| 1578 | 1578 | if ($buffer != '' && is_array($all_data)) { |
| 1579 | 1579 | $reset = 0; |
| 1580 | 1580 | foreach ($all_data as $line) { |
| 1581 | 1581 | $data = array(); |
| 1582 | 1582 | //$data['id'] = $line['id']; // id not usable |
| 1583 | 1583 | $data['id'] = trim($line['flight_id']); |
| 1584 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 1584 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 1585 | 1585 | $data['pilot_name'] = $line['pilot_name']; |
| 1586 | 1586 | $data['pilot_id'] = $line['pilot_id']; |
| 1587 | 1587 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1625,24 +1625,24 @@ discard block |
||
| 1625 | 1625 | //$buffer = $Common->getData($hosts[$id]); |
| 1626 | 1626 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 1627 | 1627 | $buffer = $Common->getData($value['host']); |
| 1628 | - $all_data = json_decode($buffer,true); |
|
| 1628 | + $all_data = json_decode($buffer, true); |
|
| 1629 | 1629 | if ($buffer != '') { |
| 1630 | 1630 | $Source->deleteLocationBySource('blitzortung'); |
| 1631 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1632 | - $buffer = explode('\n',$buffer); |
|
| 1631 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 1632 | + $buffer = explode('\n', $buffer); |
|
| 1633 | 1633 | foreach ($buffer as $buffer_line) { |
| 1634 | - $line = json_decode($buffer_line,true); |
|
| 1634 | + $line = json_decode($buffer_line, true); |
|
| 1635 | 1635 | if (isset($line['time'])) { |
| 1636 | 1636 | $data = array(); |
| 1637 | 1637 | $data['altitude'] = $line['alt']; // altitude |
| 1638 | 1638 | $data['latitude'] = $line['lat']; // lat |
| 1639 | 1639 | $data['longitude'] = $line['lon']; // long |
| 1640 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
| 1640 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
| 1641 | 1641 | $data['id_source'] = $id_source; |
| 1642 | 1642 | $data['format_source'] = 'blitzortung'; |
| 1643 | 1643 | $SI->add($data); |
| 1644 | 1644 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 1645 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
| 1645 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
| 1646 | 1646 | unset($data); |
| 1647 | 1647 | } |
| 1648 | 1648 | } |
@@ -1654,15 +1654,15 @@ discard block |
||
| 1654 | 1654 | $arr = $httpfeeds; |
| 1655 | 1655 | $w = $e = null; |
| 1656 | 1656 | if (isset($arr[$id])) { |
| 1657 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
| 1657 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
| 1658 | 1658 | if ($nn > 0) { |
| 1659 | 1659 | foreach ($httpfeeds as $feed) { |
| 1660 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
| 1660 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
| 1661 | 1661 | if ($buffer === FALSE) { |
| 1662 | 1662 | connect_all($globalSources); |
| 1663 | 1663 | } |
| 1664 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 1665 | - $buffer = explode('\n',$buffer); |
|
| 1664 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 1665 | + $buffer = explode('\n', $buffer); |
|
| 1666 | 1666 | foreach ($buffer as $line) { |
| 1667 | 1667 | if ($line != '') { |
| 1668 | 1668 | $line = json_decode($line, true); |
@@ -1702,11 +1702,11 @@ discard block |
||
| 1702 | 1702 | //$value = $formats[$nb]; |
| 1703 | 1703 | $format = $globalSources[$nb]['format']; |
| 1704 | 1704 | if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
| 1705 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 1705 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 1706 | 1706 | } elseif ($format === 'vrstcp') { |
| 1707 | 1707 | $buffer = @socket_read($r, 6000); |
| 1708 | 1708 | } else { |
| 1709 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 1709 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 1710 | 1710 | } |
| 1711 | 1711 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 1712 | 1712 | //echo $buffer."\n"; |
@@ -1716,8 +1716,8 @@ discard block |
||
| 1716 | 1716 | //$SI::del(); |
| 1717 | 1717 | if ($buffer !== FALSE) { |
| 1718 | 1718 | if ($format === 'vrstcp') { |
| 1719 | - $buffer = explode('},{',$buffer); |
|
| 1720 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 1719 | + $buffer = explode('},{', $buffer); |
|
| 1720 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 1721 | 1721 | } |
| 1722 | 1722 | // SBS format is CSV format |
| 1723 | 1723 | if ($buffer !== FALSE && $buffer !== '') { |
@@ -1744,7 +1744,7 @@ discard block |
||
| 1744 | 1744 | $ais_data = $AIS->parse_line(trim($buffer)); |
| 1745 | 1745 | $data = array(); |
| 1746 | 1746 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
| 1747 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
| 1747 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
| 1748 | 1748 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
| 1749 | 1749 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
| 1750 | 1750 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -1755,13 +1755,13 @@ discard block |
||
| 1755 | 1755 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
| 1756 | 1756 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
| 1757 | 1757 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
| 1758 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
| 1758 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
| 1759 | 1759 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1760 | 1760 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1761 | 1761 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
| 1762 | 1762 | |
| 1763 | 1763 | if (isset($ais_data['timestamp'])) { |
| 1764 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
| 1764 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
| 1765 | 1765 | } else { |
| 1766 | 1766 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1767 | 1767 | } |
@@ -1772,10 +1772,10 @@ discard block |
||
| 1772 | 1772 | } elseif ($format === 'flightgearsp') { |
| 1773 | 1773 | //echo $buffer."\n"; |
| 1774 | 1774 | if (strlen($buffer) > 5) { |
| 1775 | - $line = explode(',',$buffer); |
|
| 1775 | + $line = explode(',', $buffer); |
|
| 1776 | 1776 | $data = array(); |
| 1777 | 1777 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 1778 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 1778 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 1779 | 1779 | $data['ident'] = $line[6]; |
| 1780 | 1780 | $data['aircraft_name'] = $line[7]; |
| 1781 | 1781 | $data['longitude'] = $line[1]; |
@@ -1792,25 +1792,25 @@ discard block |
||
| 1792 | 1792 | } elseif ($format === 'acars') { |
| 1793 | 1793 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1794 | 1794 | $ACARS->add(trim($buffer)); |
| 1795 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1795 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1796 | 1796 | $ACARS->deleteLiveAcarsData(); |
| 1797 | 1797 | } elseif ($format === 'acarsjsonudp') { |
| 1798 | 1798 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 1799 | 1799 | $line = json_decode(trim($buffer), true); |
| 1800 | 1800 | if (!empty($line)) { |
| 1801 | - $line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line); |
|
| 1801 | + $line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line); |
|
| 1802 | 1802 | $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : ''))); |
| 1803 | 1803 | $ACARS->deleteLiveAcarsData(); |
| 1804 | 1804 | } |
| 1805 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 1805 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 1806 | 1806 | } elseif ($format === 'flightgearmp') { |
| 1807 | - if (substr($buffer,0,1) != '#') { |
|
| 1807 | + if (substr($buffer, 0, 1) != '#') { |
|
| 1808 | 1808 | $data = array(); |
| 1809 | 1809 | //echo $buffer."\n"; |
| 1810 | - $line = explode(' ',$buffer); |
|
| 1810 | + $line = explode(' ', $buffer); |
|
| 1811 | 1811 | if (count($line) === 11) { |
| 1812 | - $userserver = explode('@',$line[0]); |
|
| 1813 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 1812 | + $userserver = explode('@', $line[0]); |
|
| 1813 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 1814 | 1814 | $data['ident'] = $userserver[0]; |
| 1815 | 1815 | $data['registration'] = $userserver[0]; |
| 1816 | 1816 | $data['latitude'] = $line[4]; |
@@ -1818,8 +1818,8 @@ discard block |
||
| 1818 | 1818 | $data['altitude'] = $line[6]; |
| 1819 | 1819 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 1820 | 1820 | $aircraft_type = $line[10]; |
| 1821 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 1822 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 1821 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 1822 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 1823 | 1823 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
| 1824 | 1824 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 1825 | 1825 | } |
@@ -1828,8 +1828,8 @@ discard block |
||
| 1828 | 1828 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 1829 | 1829 | die; |
| 1830 | 1830 | } elseif ($format === 'vrstcp') { |
| 1831 | - foreach($buffer as $all_data) { |
|
| 1832 | - $line = json_decode('{'.$all_data.'}',true); |
|
| 1831 | + foreach ($buffer as $all_data) { |
|
| 1832 | + $line = json_decode('{'.$all_data.'}', true); |
|
| 1833 | 1833 | $data = array(); |
| 1834 | 1834 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
| 1835 | 1835 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1855,16 +1855,16 @@ discard block |
||
| 1855 | 1855 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
| 1856 | 1856 | unset($data); |
| 1857 | 1857 | } |
| 1858 | - } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
|
| 1858 | + } elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') { |
|
| 1859 | 1859 | $line = explode("\t", $buffer); |
| 1860 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 1860 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 1861 | 1861 | $key = $line[$k]; |
| 1862 | - $lined[$key] = $line[$k+1]; |
|
| 1862 | + $lined[$key] = $line[$k + 1]; |
|
| 1863 | 1863 | } |
| 1864 | 1864 | if (count($lined) > 3) { |
| 1865 | 1865 | $data['hex'] = $lined['hexid']; |
| 1866 | 1866 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 1867 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 1867 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 1868 | 1868 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 1869 | 1869 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 1870 | 1870 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1883,23 +1883,23 @@ discard block |
||
| 1883 | 1883 | } else $error = true; |
| 1884 | 1884 | } elseif ($format === 'aprs' && $use_aprs) { |
| 1885 | 1885 | if ($aprs_connect === 0) { |
| 1886 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 1886 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 1887 | 1887 | $aprs_connect = 1; |
| 1888 | 1888 | } |
| 1889 | 1889 | |
| 1890 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 1890 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 1891 | 1891 | $aprs_last_tx = time(); |
| 1892 | 1892 | $data_aprs = "# Keep alive"; |
| 1893 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 1893 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 1894 | 1894 | } |
| 1895 | 1895 | |
| 1896 | 1896 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 1897 | 1897 | //echo 'APRS data : '.$buffer."\n"; |
| 1898 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 1899 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 1898 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 1899 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 1900 | 1900 | //echo $buffer."\n"; |
| 1901 | 1901 | date_default_timezone_set('UTC'); |
| 1902 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 1902 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 1903 | 1903 | $line = $APRS->parse($buffer); |
| 1904 | 1904 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 1905 | 1905 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1914,7 +1914,7 @@ discard block |
||
| 1914 | 1914 | if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
| 1915 | 1915 | if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
| 1916 | 1916 | if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
| 1917 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1917 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 1918 | 1918 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 1919 | 1919 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 1920 | 1920 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -2002,29 +2002,29 @@ discard block |
||
| 2002 | 2002 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
| 2003 | 2003 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
| 2004 | 2004 | $Source->deleteOldLocationByType('gs'); |
| 2005 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
| 2006 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
| 2005 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
| 2006 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
| 2007 | 2007 | } else { |
| 2008 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
| 2008 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
| 2009 | 2009 | } |
| 2010 | 2010 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
| 2011 | 2011 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2012 | 2012 | if ($globalDebug) echo '# Weather Station added'."\n"; |
| 2013 | 2013 | $Source->deleteOldLocationByType('wx'); |
| 2014 | 2014 | $weather_data = json_encode($line); |
| 2015 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
| 2016 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
| 2015 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
| 2016 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
| 2017 | 2017 | } else { |
| 2018 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
| 2018 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
| 2019 | 2019 | } |
| 2020 | 2020 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
| 2021 | 2021 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
| 2022 | 2022 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
| 2023 | 2023 | $Source->deleteOldLocationByType('lightning'); |
| 2024 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
| 2025 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
| 2024 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
| 2025 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
| 2026 | 2026 | } else { |
| 2027 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
| 2027 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
| 2028 | 2028 | } |
| 2029 | 2029 | } elseif ($globalDebug) { |
| 2030 | 2030 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -2033,7 +2033,7 @@ discard block |
||
| 2033 | 2033 | unset($data); |
| 2034 | 2034 | } |
| 2035 | 2035 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
| 2036 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
| 2036 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
| 2037 | 2037 | } |
| 2038 | 2038 | /* |
| 2039 | 2039 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) { |
@@ -2042,7 +2042,7 @@ discard block |
||
| 2042 | 2042 | */ |
| 2043 | 2043 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 2044 | 2044 | elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 2045 | - if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
| 2045 | + if (isset($Source) && isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
| 2046 | 2046 | $Source->deleteOldLocationByType('lightning'); |
| 2047 | 2047 | $Source->deleteOldLocationByType('wx'); |
| 2048 | 2048 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -2129,7 +2129,7 @@ discard block |
||
| 2129 | 2129 | connect_all($sourceee); |
| 2130 | 2130 | $sourceee = array(); |
| 2131 | 2131 | //connect_all($globalSources); |
| 2132 | - $tt[$format]=0; |
|
| 2132 | + $tt[$format] = 0; |
|
| 2133 | 2133 | break; |
| 2134 | 2134 | } |
| 2135 | 2135 | //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
@@ -2139,14 +2139,14 @@ discard block |
||
| 2139 | 2139 | } else { |
| 2140 | 2140 | $error = socket_strerror(socket_last_error()); |
| 2141 | 2141 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
| 2142 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 2142 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 2143 | 2143 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 2144 | 2144 | // Restart the script if possible |
| 2145 | 2145 | if (is_array($sockets)) { |
| 2146 | 2146 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 2147 | 2147 | |
| 2148 | 2148 | foreach ($sockets as $sock) { |
| 2149 | - @socket_shutdown($sock,2); |
|
| 2149 | + @socket_shutdown($sock, 2); |
|
| 2150 | 2150 | @socket_close($sock); |
| 2151 | 2151 | } |
| 2152 | 2152 | |