本文整理汇总了PHP中OperationsData::GetAircraftByReg方法的典型用法代码示例。如果您正苦于以下问题:PHP OperationsData::GetAircraftByReg方法的具体用法?PHP OperationsData::GetAircraftByReg怎么用?PHP OperationsData::GetAircraftByReg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationsData
的用法示例。
在下文中一共展示了OperationsData::GetAircraftByReg方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$postText = file_get_contents('php://input');
$rec_xml = trim(utf8_encode(file_get_contents('php://input')));
$xml = simplexml_load_string($rec_xml);
if (!$xml) {
#$this->log("Invalid XML Sent: \n".$rec_xml, 'kacars');
return;
}
#$this->log(print_r($xml->asXML(), true), 'kacars');
$case = strtolower($xml->switch->data);
switch ($case) {
case 'verify':
$results = Auth::ProcessLogin($xml->verify->pilotID, $xml->verify->password);
if ($results) {
$params = array('loginStatus' => '1');
//echo 1;
} else {
$params = array('loginStatus' => '0');
//echo 0;
}
$send = self::sendXML($params);
break;
case 'getbid':
$pilotid = PilotData::parsePilotID($xml->verify->pilotID);
$pilotinfo = PilotData::getPilotData($pilotid);
$biddata = SchedulesData::getLatestBid($pilotid);
$aircraftinfo = OperationsData::getAircraftByReg($biddata->registration);
if (count($biddata) == 1) {
if ($aircraftinfo->enabled == 1) {
$params = array('flightStatus' => '1', 'flightNumber' => $biddata->code . $biddata->flightnum, 'aircraftReg' => $biddata->registration, 'aircraftICAO' => $aircraftinfo->icao, 'aircraftFullName' => $aircraftinfo->fullname, 'flightLevel' => $biddata->flightlevel, 'aircraftMaxPax' => $aircraftinfo->maxpax, 'aircraftCargo' => $aircraftinfo->maxcargo, 'depICAO' => $biddata->depicao, 'arrICAO' => $biddata->arricao, 'route' => $biddata->route, 'depTime' => $biddata->deptime, 'arrTime' => $biddata->arrtime, 'flightTime' => $biddata->flighttime, 'flightType' => $biddata->flighttype, 'aircraftName' => $aircraftinfo->name, 'aircraftRange' => $aircraftinfo->range, 'aircraftWeight' => $aircraftinfo->weight, 'aircraftCruise' => $aircraftinfo->cruise);
} else {
$params = array('flightStatus' => '3');
// Aircraft Out of Service.
}
} else {
$params = array('flightStatus' => '2');
// You have no bids!
}
$send = $this->sendXML($params);
break;
case 'getflight':
$flightinfo = SchedulesData::getProperFlightNum($xml->pirep->flightNumber);
$params = array('s.code' => $flightinfo['code'], 's.flightnum' => $flightinfo['flightnum'], 's.enabled' => 1);
$biddata = SchedulesData::findSchedules($params, 1);
$aircraftinfo = OperationsData::getAircraftByReg($biddata[0]->registration);
if (count($biddata) == 1) {
$params = array('flightStatus' => '1', 'flightNumber' => $biddata[0]->code . $biddata[0]->flightnum, 'aircraftReg' => $biddata[0]->registration, 'aircraftICAO' => $aircraftinfo->icao, 'aircraftFullName' => $aircraftinfo->fullname, 'flightLevel' => $biddata[0]->flightlevel, 'aircraftMaxPax' => $aircraftinfo->maxpax, 'aircraftCargo' => $aircraftinfo->maxcargo, 'depICAO' => $biddata[0]->depicao, 'arrICAO' => $biddata[0]->arricao, 'route' => $biddata[0]->route, 'depTime' => $biddata[0]->deptime, 'arrTime' => $biddata[0]->arrtime, 'flightTime' => $biddata[0]->flighttime, 'flightType' => $biddata[0]->flighttype, 'aircraftName' => $aircraftinfo->name, 'aircraftRange' => $aircraftinfo->range, 'aircraftWeight' => $aircraftinfo->weight, 'aircraftCruise' => $aircraftinfo->cruise);
} else {
$params = array('flightStatus' => '2');
}
$send = $this->sendXML($params);
break;
case 'liveupdate':
$pilotid = PilotData::parsePilotID($xml->verify->pilotID);
# Get the distance remaining
$depapt = OperationsData::GetAirportInfo($xml->liveupdate->depICAO);
$arrapt = OperationsData::GetAirportInfo($xml->liveupdate->arrICAO);
$dist_remain = round(SchedulesData::distanceBetweenPoints($xml->liveupdate->latitude, $xml->liveupdate->longitude, $arrapt->lat, $arrapt->lng));
# Estimate the time remaining
if ($xml->liveupdate->groundSpeed > 0) {
$Minutes = round($dist_remain / $xml->liveupdate->groundSpeed * 60);
$time_remain = self::ConvertMinutes2Hours($Minutes);
} else {
$time_remain = '00:00';
}
$lat = str_replace(",", ".", $xml->liveupdate->latitude);
$lon = str_replace(",", ".", $xml->liveupdate->longitude);
$fields = array('pilotid' => $pilotid, 'flightnum' => $xml->liveupdate->flightNumber, 'pilotname' => '', 'aircraft' => $xml->liveupdate->registration, 'lat' => $lat, 'lng' => $lon, 'heading' => $xml->liveupdate->heading, 'alt' => $xml->liveupdate->altitude, 'gs' => $xml->liveupdate->groundSpeed, 'depicao' => $xml->liveupdate->depICAO, 'arricao' => $xml->liveupdate->arrICAO, 'deptime' => $xml->liveupdate->depTime, 'arrtime' => '', 'route' => $xml->liveupdate->route, 'distremain' => $dist_remain, 'timeremaining' => $time_remain, 'phasedetail' => $xml->liveupdate->status, 'online' => '', 'client' => 'kACARS');
#$this->log("UpdateFlightData: \n".print_r($fields, true), 'kacars');
ACARSData::UpdateFlightData($pilotid, $fields);
break;
case 'pirep':
$flightinfo = SchedulesData::getProperFlightNum($xml->pirep->flightNumber);
$code = $flightinfo['code'];
$flightnum = $flightinfo['flightnum'];
$pilotid = PilotData::parsePilotID($xml->verify->pilotID);
# Make sure airports exist:
# If not, add them.
if (!OperationsData::GetAirportInfo($xml->pirep->depICAO)) {
OperationsData::RetrieveAirportInfo($xml->pirep->depICAO);
}
if (!OperationsData::GetAirportInfo($xml->pirep->arrICAO)) {
OperationsData::RetrieveAirportInfo($xml->pirep->arrICAO);
}
# Get aircraft information
$reg = trim($xml->pirep->registration);
$ac = OperationsData::GetAircraftByReg($reg);
# Load info
/* If no passengers set, then set it to the cargo */
$load = $xml->pirep->pax;
if (empty($load)) {
$load = $xml->pirep->cargo;
}
/* Fuel conversion - kAcars only reports in lbs */
$fuelused = $xml->pirep->fuelUsed;
if (Config::Get('LiquidUnit') == '0') {
# Convert to KGs, divide by density since d = mass * volume
$fuelused = $fuelused * 0.45359237 / 0.8075;
//.........这里部分代码省略.........
示例2: acars
/**
* 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
//.........这里部分代码省略.........
示例3: find_in_fsacars_log
# Find where flight IATA is
$pos = find_in_fsacars_log('PAX', $log);
$load = str_replace('PAX:', '', $log[$pos]);
$pos = find_in_fsacars_log('TouchDown:Rate', $log);
$landingrate = str_replace('TouchDown:Rate', '', $log[$pos]);
$pos = find_in_fsacars_log('Route', $log);
$route = str_replace('Route:', '', $log[$pos]);
$count = preg_match('/([0-9]*:[0-9]*).*([-+]\\d*).*/i', $landingrate, $matches);
if ($count > 0) {
$landingrate = $matches[2];
} else {
$landingrate = 0;
}
# Get our aircraft
$reg = trim($_GET['reg']);
$ac = OperationsData::GetAircraftByReg($reg);
# Do some cleanup
$_GET['origin'] = DB::escape($_GET['origin']);
$_GET['dest'] = DB::escape($_GET['dest']);
# Get schedule info, using minimal information
# Check if they forgot the flight code
if ($code == '') {
# Find a flight using just the flight code
$sched = SchedulesData::FindFlight($flightnum);
# Can't do it. They completely fucked this up
if (!$sched) {
return;
}
$code = $sched->code;
$flightnum = $sched->flightnum;
if ($_GET['origin'] != $sched->depicao || $_GET['dest'] != $sched->arricao) {
示例4: add_aircraft_post
protected function add_aircraft_post()
{
if ($this->post->icao == '' || $this->post->name == '' || $this->post->fullname == '' || $this->post->registration == '') {
$this->set('message', 'You must enter the ICAO, name, full name and the registration.');
$this->render('core_error.tpl');
return;
}
if ($this->post->enabled == '1') {
$this->post->enabled = true;
} else {
$this->post->enabled = false;
}
# Check aircraft registration, make sure it's not a duplicate
$ac = OperationsData::GetAircraftByReg($this->post->registration);
if ($ac) {
$this->set('message', 'The aircraft registration must be unique');
$this->render('core_error.tpl');
return;
}
$data = array('icao' => $this->post->icao, 'name' => $this->post->name, 'fullname' => $this->post->fullname, 'registration' => $this->post->registration, 'downloadlink' => $this->post->downloadlink, 'imagelink' => $this->post->imagelink, 'range' => $this->post->range, 'weight' => $this->post->weight, 'cruise' => $this->post->cruise, 'maxpax' => $this->post->maxpax, 'maxcargo' => $this->post->maxcargo, 'minrank' => $this->post->minrank, 'enabled' => $this->post->enabled);
OperationsData::AddAircaft($data);
if (DB::errno() != 0) {
if (DB::$errno == 1062) {
// Duplicate entry
$this->set('message', 'This aircraft already exists');
} else {
$this->set('message', 'There was an error adding the aircraft');
}
$this->render('core_error.tpl');
return false;
}
$this->set('message', 'The aircraft has been added');
$this->render('core_success.tpl');
LogData::addLog(Auth::$userinfo->pilotid, 'Added the aircraft "' . $this->post->name . ' - ' . $this->post->registration . '"');
}
示例5: processimport
public function processimport()
{
echo '<h3>Processing Import</h3>';
if (!file_exists($_FILES['uploadedfile']['tmp_name'])) {
$this->set('message', 'File upload failed!');
$this->render('core_error.tpl');
return;
}
echo '<p><strong>DO NOT REFRESH OR STOP THIS PAGE</strong></p>';
set_time_limit(270);
$errs = array();
$skip = false;
# Fix for bug VMS-325
$temp_name = $_FILES['uploadedfile']['tmp_name'];
$new_name = CACHE_PATH . $_FILES['uploadedfile']['name'];
move_uploaded_file($temp_name, $new_name);
$fp = fopen($new_name, 'r');
if (isset($_POST['header'])) {
$skip = true;
}
/* Delete all schedules before doing an import */
if (isset($_POST['erase_routes'])) {
SchedulesData::deleteAllSchedules();
}
$added = 0;
$updated = 0;
$total = 0;
echo '<div style="overflow: auto; height: 400px; border: 1px solid #666; margin-bottom: 20px; padding: 5px; padding-top: 0px; padding-bottom: 20px;">';
while ($fields = fgetcsv($fp, 1000, ',')) {
// Skip the first line
if ($skip == true) {
$skip = false;
continue;
}
// list fields:
$code = $fields[0];
$flightnum = $fields[1];
$depicao = $fields[2];
$arricao = $fields[3];
$route = $fields[4];
$aircraft = $fields[5];
$flightlevel = $fields[6];
$distance = $fields[7];
$deptime = $fields[8];
$arrtime = $fields[9];
$flighttime = $fields[10];
$notes = $fields[11];
$price = $fields[12];
$flighttype = $fields[13];
$daysofweek = $fields[14];
$enabled = $fields[15];
$week1 = $fields[16];
$week2 = $fields[17];
$week3 = $fields[18];
$week4 = $fields[19];
if ($code == '') {
continue;
}
// Check the code:
if (!OperationsData::GetAirlineByCode($code)) {
echo "Airline with code {$code} does not exist! Skipping...<br />";
continue;
}
// Make sure airports exist:
if (!($depapt = OperationsData::GetAirportInfo($depicao))) {
$this->get_airport_info($depicao);
}
if (!($arrapt = OperationsData::GetAirportInfo($arricao))) {
$this->get_airport_info($arricao);
}
# Check the aircraft
$aircraft = trim($aircraft);
$ac_info = OperationsData::GetAircraftByReg($aircraft);
# If the aircraft doesn't exist, skip it
if (!$ac_info) {
echo 'Aircraft "' . $aircraft . '" does not exist! Skipping<br />';
continue;
}
$ac = $ac_info->id;
if ($flighttype == '') {
$flighttype = 'P';
}
if ($daysofweek == '') {
$daysofweek = '0123456';
}
// Replace a 7 (Sunday) with 0 (since PHP thinks 0 is Sunday)
$daysofweek = str_replace('7', '0', $daysofweek);
# Check the distance
if ($distance == 0 || $distance == '') {
$distance = OperationsData::getAirportDistance($depicao, $arricao);
}
$flighttype = strtoupper($flighttype);
if ($enabled == '0') {
$enabled = false;
} else {
$enabled = true;
}
# This is our 'struct' we're passing into the schedule function
# to add or edit it
$data = array('code' => $code, 'flightnum' => $flightnum, 'depicao' => $depicao, 'arricao' => $arricao, 'route' => $route, 'aircraft' => $ac, 'flightlevel' => $flightlevel, 'distance' => $distance, 'deptime' => $deptime, 'arrtime' => $arrtime, 'flighttime' => $flighttime, 'daysofweek' => $daysofweek, 'notes' => $notes, 'enabled' => $enabled, 'price' => $price, 'flighttype' => $flighttype, 'week1' => $week1, 'week2' => $week2, 'week3' => $week3, 'week4' => $week4);
//.........这里部分代码省略.........
示例6: pirep
/**
* File PIREP
*
*/
public function pirep()
{
$data = "<?xml version=\"1.0\" encoding='UTF-8'?>" . trim(utf8_encode($_REQUEST['DATA2']));
$xml = simplexml_load_string($data);
$this->log($data, 'fsfk');
$this->log(print_r($xml, true), 'fsfk');
#$this->log(serialize($xml), 'fsfk');
$pilotid = PilotData::parsePilotID($xml->PilotID);
$flightinfo = SchedulesData::getProperFlightNum($xml->FlightNumber);
$code = $flightinfo['code'];
$flightnum = $flightinfo['flightnum'];
# Extract the ICAO of the airport
$depicao = strtoupper(substr($xml->OriginICAO, 0, 4));
$arricao = strtoupper(substr($xml->DestinationICAO, 0, 4));
if (!OperationsData::GetAirportInfo($depicao)) {
OperationsData::RetrieveAirportInfo($depicao);
}
if (!OperationsData::GetAirportInfo($arricao)) {
OperationsData::RetrieveAirportInfo($arricao);
}
$load = (string) $xml->Passenger;
if ($load == '' || $load == 0) {
$load = (string) $xml->Cargo;
}
$flighttime = str_replace(':', '.', (string) $xml->BlockTime);
# Get the proper aircraft
$ac = OperationsData::GetAircraftByReg((string) $xml->AircraftTailNumber);
if (!$ac) {
$aircraft = 0;
} else {
$aircraft = $ac->id;
unset($ac);
}
/* Process the report, to put into the log */
$log = '';
$images = '';
$rawdata = array();
# Setup the base things
$rawdata['FLIGHTMAPS'] = array();
$rawdata['FLIGHTDATA'] = array();
foreach ($xml as $key => $value) {
/* Add the map images in */
if ($key == 'FLIGHTMAPS') {
$img = (string) $xml->FLIGHTMAPS->FlightMapWeatherJPG;
if ($img) {
$rawdata['FLIGHTMAPS']['FlightMapWeather'] = $img;
}
$img = (string) $xml->FLIGHTMAPS->FlightMapLandingProfileJPG;
if ($img) {
$rawdata['FLIGHTMAPS']['FlightMapLandingProfile'] = $img;
}
$img = (string) $xml->FLIGHTMAPS->FlightMapTaxiInJPG;
if ($img) {
$rawdata['FLIGHTMAPS']['FlightMapTaxiIn'] = $img;
}
$img = (string) $xml->FLIGHTMAPS->FlightMapTaxiOutJPG;
if ($img) {
$rawdata['FLIGHTMAPS']['FlightMapTaxiOut'] = $img;
}
$img = (string) $xml->FLIGHTMAPS->FlightMapVerticalProfileJPG;
if ($img) {
$rawdata['FLIGHTMAPS']['FlightMapVerticalProfile'] = $img;
}
$img = (string) $xml->FLIGHTMAPS->FlightMapJPG;
if ($img) {
$rawdata['FLIGHTMAPS']['FlightMap'] = $img;
}
continue;
} elseif ($key == 'FLIGHTPLAN') {
$rawdata['FLIGHTPLAN'] = (string) $value;
continue;
} elseif ($key == 'FLIGHTCRITIQUE') {
$value = trim((string) $value);
$rawdata['FLIGHTCRITIQUE'] = $value;
continue;
} else {
$key = trim($key);
$value = (string) $value;
$value = str_replace('��', '', $value);
$rawdata['FLIGHTDATA'][$key] = $value;
}
}
/* Fuel conversion - kAcars only reports in lbs */
$fuelused = (string) $xml->BlockFuel;
if (intval(Config::Get('LiquidUnit')) == 0) {
# Convert to KGs, divide by density since d = mass * volume
$fuelused = $fuelused * 0.45359237 / 0.8075;
} elseif (intval(Config::Get('LiquidUnit')) == 1) {
# Convert lbs to gallons
$fuelused = $fuelused * 6.84;
} elseif (intval(Config::Get('LiquidUnit')) == 2) {
# Convert lbs to kgs
$fuelused = $fuelused * 0.45359237;
}
/* Our data to send to the submit PIREP function */
$data = array('pilotid' => $pilotid, 'code' => $code, 'flightnum' => $flightnum, 'depicao' => $depicao, 'arricao' => $arricao, 'aircraft' => $aircraft, 'registration' => (string) $xml->AircraftTailNumber, 'flighttime' => $flighttime, 'landingrate' => (string) $xml->ONVS, 'submitdate' => 'NOW()', 'comment' => trim((string) $xml->COMMENT), 'fuelused' => $fuelused, 'source' => 'fsfk', 'load' => $load, 'log' => $log, 'rawdata' => $rawdata);
//.........这里部分代码省略.........