本文整理汇总了PHP中OperationsData::getAircraftByReg方法的典型用法代码示例。如果您正苦于以下问题:PHP OperationsData::getAircraftByReg方法的具体用法?PHP OperationsData::getAircraftByReg怎么用?PHP OperationsData::getAircraftByReg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationsData
的用法示例。
在下文中一共展示了OperationsData::getAircraftByReg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importaircraft
public function importaircraft()
{
if (!file_exists($_FILES['uploadedfile']['tmp_name'])) {
$this->render('import_aircraftform.tpl');
return;
}
echo '<h3>Processing Import</h3>';
# Get the column headers
$allaircraft = OperationsData::getAllAircraft(false);
$headers = array();
$dbcolumns = DB::get_cols();
foreach ($dbcolumns as $col) {
if ($col->name == 'id' || $col->name == 'minrank' || $col->name == 'ranklevel') {
continue;
}
$headers[] = $col->name;
}
# Open the import file
# 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;
}
$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;
}
# Map the read in values to the columns
$aircraft = array();
$aircraft = @array_combine($headers, $fields);
if (empty($aircraft)) {
continue;
}
# Enabled or not
if ($aircraft['enabled'] == '1') {
$aircraft['enabled'] = true;
} else {
$aircraft['enabled'] = false;
}
# Get the rank ID
$rank = RanksData::getRankByName($aircraft['rank']);
$aircraft['minrank'] = $rank->rankid;
unset($aircraft['rank']);
# Does this aircraft exist?
$ac_info = OperationsData::getAircraftByReg($aircraft['registration']);
if ($ac_info) {
echo "Editing {$aircraft['name']} - {$aircraft['registration']}<br>";
$aircraft['id'] = $ac_info->id;
OperationsData::editAircraft($aircraft);
$updated++;
} else {
echo "Adding {$aircraft['name']} - {$aircraft['registration']}<br>";
OperationsData::addAircraft($aircraft);
$added++;
}
$total++;
}
unlink($new_name);
echo "The import process is complete, added {$added} aircraft, updated {$updated}, for a total of {$total}<br />";
}
示例2: 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;
//.........这里部分代码省略.........
示例3: fileReport
/**
* PIREPData::fileReport()
*
* @param mixed $pirepdata
* @return
*/
public static function fileReport($pirepdata)
{
/*$pirepdata = array('pilotid'=>'',
'code'=>'',
'flightnum'=>'',
'depicao'=>'',
'arricao'=>'',
'aircraft'=>'',
'flighttime'=>'',
'submitdate'=>'',
'comment'=>'',
'fuelused'=>'',
'source'=>''
'log'=>''
);*/
if (!is_array($pirepdata)) {
return false;
}
$pirepdata['code'] = strtoupper($pirepdata['code']);
$pirepdata['flightnum'] = strtoupper($pirepdata['flightnum']);
$pirepdata['depicao'] = strtoupper($pirepdata['depicao']);
$pirepdata['arricao'] = strtoupper($pirepdata['arricao']);
/* Check if this PIREP was just submitted, check the last 10 minutes
*/
if (Config::Get('PIREP_CHECK_DUPLICATE') == true) {
$time_limit = Config::Get('PIREP_TIME_CHECK');
if (empty($time_limit)) {
$time_limit = 1;
}
$sql = "SELECT `pirepid` FROM " . TABLE_PREFIX . "pireps\n\t\t\t\t\tWHERE `pilotid` = {$pirepdata['pilotid']} \n\t\t\t\t\t\tAND `code` = '{$pirepdata['code']}'\n\t\t\t\t\t\tAND `flightnum` = '{$pirepdata['flightnum']}' \n\t\t\t\t\t\tAND DATE_SUB(NOW(), INTERVAL {$time_limit} MINUTE) <= `submitdate`";
$res = DB::get_row($sql);
if ($res) {
self::$lasterror = 'This PIREP was just submitted!';
return $res->pirepid;
}
}
if ($pirepdata['depicao'] == '' || $pirepdata['arricao'] == '') {
self::$lasterror = 'The departure or arrival airports are blank';
return false;
}
# Check the aircraft
if (!is_numeric($pirepdata['aircraft'])) {
// Check by registration
$ac = OperationsData::getAircraftByReg($pirepdata['aircraft']);
if ($ac) {
$pirepdata['aircraft'] = $ac->id;
} else {
// Check by name
$ac = OperationsData::getAircraftByName($pirepdata['aircraft']);
if ($ac) {
$pirepdata['aircraft'] = $ac->id;
} else {
$pirepdata['aircraft'] = '0';
}
}
}
# Check the airports, add to database if they don't exist
$depapt = OperationsData::getAirportInfo($pirepdata['depicao']);
if (!$depapt) {
$depapt = OperationsData::RetrieveAirportInfo($pirepdata['depicao']);
}
$arrapt = OperationsData::getAirportInfo($pirepdata['arricao']);
if (!$arrapt) {
$arrapt = OperationsData::RetrieveAirportInfo($pirepdata['arricao']);
}
# Look up the schedule
$sched = SchedulesData::getScheduleByFlight($pirepdata['code'], $pirepdata['flightnum']);
/* Get route information, and also the detailed layout of the route
Store it cached, in case the schedule changes later, then the route
information remains intact. Also, if the nav data changes, then
the route is saved as it was
*/
if (!empty($pirepdata['route'])) {
/* They supplied some route information, so build up the data
based on that. It needs a certain structure passed, so build that */
$pirepdata['route'] = str_replace('SID', '', $pirepdata['route']);
$pirepdata['route'] = str_replace('STAR', '', $pirepdata['route']);
$pirepdata['route'] = str_replace('DCT', '', $pirepdata['route']);
$pirepdata['route'] = trim($pirepdata['route']);
$tmp = new stdClass();
$tmp->deplat = $depapt->lat;
$tmp->deplng = $depapt->lng;
$tmp->route = $pirepdata['route'];
$pirepdata['route_details'] = NavData::parseRoute($tmp);
$pirepdata['route_details'] = serialize($pirepdata['route_details']);
unset($tmp);
}
if (empty($pirepdata['route']) && !empty($sched->route)) {
$pirepdata['route'] = $sched->route;
$pirepdata['route'] = str_replace('SID', '', $pirepdata['route']);
$pirepdata['route'] = str_replace('STAR', '', $pirepdata['route']);
$pirepdata['route'] = str_replace('DCT', '', $pirepdata['route']);
$pirepdata['route'] = trim($pirepdata['route']);
/* The schedule doesn't have any route_details, so let's populate
//.........这里部分代码省略.........