コード例 #1
0
ファイル: FSFK.php プロジェクト: ryanunderwood/phpVMS
 /**
  * Process ACARS messages here
  * 
  */
 public function acars()
 {
     if (!isset($_REQUEST['DATA1'])) {
         die("0|Invalid Data");
     }
     if (!isset($_REQUEST['DATA1'])) {
         die("0|Invalid Data");
     }
     // TEST, BEGINFLIGHT, PAUSEFLIGHT, ENDFLIGHT and MESSAGE
     $method = strtoupper($_REQUEST['DATA2']);
     if (!isset($_REQUEST['DATA3'])) {
         $value = '';
     } else {
         $value = $_REQUEST['DATA3'];
     }
     if (!isset($_REQUEST['DATA4'])) {
         $message = '';
     } else {
         $message = $_REQUEST['DATA4'];
     }
     $this->log("Method: {$method}", 'fsfk');
     $fields = array();
     # Go through each method now
     if ($method == 'TEST') {
         $pilotid = $value;
         echo '1|30';
         return;
     } elseif ($method == 'BEGINFLIGHT') {
         $flight_data = explode('|', $value);
         if (count($flight_data) < 10) {
             echo '0|Invalid login data';
             return;
         }
         /*preg_match('/^([A-Za-z]*)(\d*)/', $flight_data[0], $matches);
         		$code = $matches[1];
         		$pilotid = intval($matches[2]) - Config::Get('PILOTID_OFFSET');*/
         $pilotid = PilotData::parsePilotID($flight_data[0]);
         $coords = $this->get_coordinates($flight_data[6]);
         $route = explode('~', $flight_data[5]);
         $depicao = $route[0];
         $arricao = $route[count($route) - 1];
         unset($route[0]);
         unset($route[count($route) - 1]);
         $route = implode(' ', $route);
         $flightinfo = SchedulesData::getProperFlightNum($flight_data[2]);
         $code = $flightinfo['code'];
         $flightnum = $flightinfo['flightnum'];
         $aircraft = $flight_data[3];
         $heading = $flight_data[12];
         $alt = $flight_data[7];
         $gs = 0;
         $dist_remain = $flight_data[16];
         $time_remain = 0;
         $deptime = time();
         $online = 0;
         $fields = array('pilotid' => $pilotid, 'flightnum' => $code . $flightnum, 'aircraft' => $aircraft, 'lat' => $coords['lat'], 'lng' => $coords['lng'], 'heading' => $heading, 'route' => $route, 'alt' => $alt, 'gs' => $gs, 'depicao' => $depicao, 'arricao' => $arricao, 'distremain' => $dist_remain, 'timeremaining' => $time_remain, 'phasedetail' => 'On the ground', 'online' => $online, 'client' => 'fsfk');
     } elseif ($method == 'MESSAGE') {
         $pilotid = $value;
         $flight_data = ACARSData::get_flight_by_pilot($pilotid);
         // Get the flight
         preg_match("/Flight ID: (.*)\n/", $message, $matches);
         $flightinfo = SchedulesData::getProperFlightNum($matches[1]);
         $code = $flightinfo['code'];
         $flightnum = $flightinfo['flightnum'];
         // Get the aircraft
         preg_match("/.*Aircraft Reg: \\.\\.(.*)\n/", $message, $matches);
         $aircraft_data = OperationsData::GetAircraftByReg(trim($matches[1]));
         $aircraft = $aircraft_data->id;
         $depicao = $flight_data->depicao;
         $arricao = $flight_data->arricao;
         // Get coordinates from ACARS message
         $count = preg_match("/POS(.*)\n/", $message, $matches);
         if ($count > 0) {
             $coords = $this->get_coordinates(trim($matches[1]));
         } else {
             $coords = array('lat' => $flight_data->lat, 'lng' => $flight_data->lng);
         }
         // Get our heading
         preg_match("/\\/HDG.(.*)\n/", $message, $matches);
         $heading = $matches[1];
         // Get our altitude
         preg_match("/\\/ALT.(.*)\n/", $message, $matches);
         $alt = $matches[1];
         // Get our speed
         preg_match("/\\/IAS.(.*)\\//", $message, $matches);
         $gs = $matches[1];
         $fields = array('pilotid' => $pilotid, 'aircraft' => $aircraft, 'lat' => $coords['lat'], 'lng' => $coords['lng'], 'heading' => $heading, 'alt' => $alt, 'gs' => $gs, 'phasedetail' => 'Enroute');
     } elseif ($method == 'UPDATEFLIGHTPLAN') {
         $flight_id = $value;
         $flight_data = explode("|", $message);
         echo '1|';
         return;
     }
     $depapt = OperationsData::GetAirportInfo($depicao);
     $dist_remain = SchedulesData::distanceBetweenPoints($coords->lat, $coords->lng, $depapt->lat, $depapt->lng);
     # Estimate the time remaining
     if ($gs != 0) {
         $time_remain = $dist_remain / $gs;
     } else {
         $time_remain = '0';
     }
     $fields['distremain'] = $dist_remain;
     $fields['timeremaining'] = $time_remain;
     if ($deptime != '') {
         $fields['deptime'] = $deptime;
     }
     if ($arrtime != '') {
         $fields['arrtime'] = $arrtime;
     }
     Debug::log(print_r($fields, true), 'fsfk');
     ACARSData::updateFlightData($pilotid, $fields);
     $id = DB::$insert_id;
     if ($method == 'BEGINFLIGHT') {
         echo '1|' . $pilotid;
         return;
     }
     echo '1|';
 }
コード例 #2
0
ファイル: fsacars.php プロジェクト: ryanunderwood/phpVMS
     			# see if they are a valid pilot:
     			preg_match('/^([A-Za-z]*)(\d*)/', $_GET['pnumber'], $matches);
     			$code = $matches[1];
     			$pilotid = intval($matches[2]) - Config::Get('PILOTID_OFFSET');
     		}*/
     $pilotid = PilotData::parsePilotID($_GET['pnumber']);
     $ac = OperationsData::GetAircraftByReg($_GET['Regist']);
     if (!$ac) {
         $aircraft = 0;
     } else {
         $aircraft = $ac->id;
         unset($ac);
     }
     $fields = array('pilotid' => $pilotid, 'flightnum' => $_GET['IATA'], 'pilotname' => '', 'aircraft' => $aircraft, 'registration' => $_GET['Regist'], 'lat' => $_GET['lat'], 'lng' => $_GET['long'], 'heading' => '', 'alt' => $_GET['Alt'], 'gs' => $_GET['GS'], 'route' => '', 'depicao' => $_GET['depaptICAO'], 'depapt' => $_GET['depapt'], 'arricao' => $_GET['destaptICAO'], 'arrapt' => $_GET['destapt'], 'deptime' => '', 'arrtime' => '', 'distremain' => $_GET['disdestapt'], 'timeremaining' => $_GET['timedestapt'], 'phasedetail' => $phase_detail[$_GET['detailph']], 'online' => $_GET['Online'], 'client' => 'FSACARS');
     Debug::log(print_r($fields, true), 'fsacars');
     ACARSData::updateFlightData($pilotid, $fields);
     Debug::log($cont, 'fsacars');
     echo 'OK';
     break;
     #
     # File the PIREP
     #
 #
 # File the PIREP
 #
 case 'pirep':
     Debug::log('PIREP FILE', 'fsacars');
     Debug::log(serialize($_GET), 'fsacars');
     $pilotid = PilotData::parsePilotID($_GET['pilot']);
     /*if(is_numeric($_GET['pilot']))
     		{