本文整理汇总了PHP中PilotData类的典型用法代码示例。如果您正苦于以下问题:PHP PilotData类的具体用法?PHP PilotData怎么用?PHP PilotData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PilotData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: acarsdata
public function acarsdata()
{
$output = '';
CodonEvent::Dispatch('refresh_acars', 'XML');
$flights = ACARSData::GetACARSData();
$xml = new SimpleXMLElement('<livemap/>');
if (!$flights) {
$flights = array();
}
foreach ($flights as $flight) {
$pilot = $xml->addChild('aircraft');
$pilot->addAttribute('flightnum', $flight->flightnum);
$pilot->addAttribute('lat', $flight->lat);
$pilot->addAttribute('lng', $flight->lng);
$pilot->addChild('pilotid', PilotData::GetPilotCode($flight->code, $flight->pilotid));
$pilot->addChild('pilotname', $flight->firstname . ' ' . $flight->lastname);
$pilot->addChild('flightnum', $flight->flightnum);
$pilot->addChild('lat', $flight->lat);
$pilot->addChild('lng', $flight->lng);
$pilot->addChild('depicao', $flight->depicao);
$pilot->addChild('arricao', $flight->arricao);
$pilot->addChild('phase', $flight->phasedetail);
$pilot->addChild('alt', $flight->alt);
$pilot->addChild('gs', $flight->gs);
$pilot->addChild('distremain', $flight->distremain);
$pilot->addChild('timeremain', $flight->timeremain);
}
header('Content-type: text/xml');
echo $xml->asXML();
}
示例2: testTimesAdded
public function testTimesAdded()
{
echo '<h3>Checking Times</h3>';
$sql = 'SELECT `flighttime`
FROM ' . TABLE_PREFIX . 'pireps
WHERE `accepted`=' . PIREP_ACCEPTED;
$results = DB::get_results($sql);
$this->added_time = 0;
foreach ($results as $row) {
$this->added_time = Util::AddTime($this->added_time, $row->flighttime);
}
heading('Time added, all PIREPS at once');
$this->assertNotEqual(0, $this->added_time);
heading('Time added, pilot by pilot');
// Now calculate by PIREP
$allpilots = PilotData::GetAllPilots();
$total = 0;
foreach ($allpilots as $pilot) {
$p_hours = PilotData::getPilotHours($pilot->pilotid);
$total = Util::AddTime($total, $p_hours);
}
$this->assertNotEqual(0, $total);
heading('Comparing pilot to pilot vs all PIREPS');
$this->assertEqual($total, $this->added_time);
heading('Compare to STAT total hours');
StatsData::UpdateTotalHours();
$this->assertEqual($total, StatsData::TotalHours());
echo '<br />';
}
示例3: pushToTwitter
/**
* ActivityData::pushToTwitter()
*
* @param mixed $params
* @return void
*/
public static function pushToTwitter($params)
{
require_once CORE_LIB_PATH . '/twitteroauth/twitteroauth.php';
$params = array_merge(array('pilotid' => '', 'type' => '', 'refid' => '', 'message' => ''), $params);
$message = '';
# These defaults will be ignored
$lat = -120;
$long = -120;
if (!empty($params['pilotid'])) {
$pilot = PilotData::getPilotData($params['pilotid']);
$message .= PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' ' . $pilot->firstname . ' ' . $pilot->lastname . ' ';
}
$message .= $params['message'] . ' ';
# Show a new PIREP, also get the airport information
if ($params['type'] == ACTIVITY_NEW_PIREP) {
$message .= url('/pireps/view/' . $params['refid']);
$pirep = PIREPData::findPIREPS(array('pirepid' => $params['refid']), 1);
$pirep = $pirep[0];
$airport = OperationsData::getAirportInfo($pirep->arricao);
$lat = $airport->lat;
$long = $airport->lng;
} elseif ($params['type'] == ACTIVITY_NEW_PILOT) {
$message .= url('/profile/view/' . $params['pilotid']);
$airport = OperationsData::getAirportInfo($pilot->hub);
$lat = $airport->lat;
$long = $airport->lng;
}
$tweet = new TwitterOAuth(Config::get('TWITTER_CONSUMER_KEY'), Config::get('TWITTER_CONSUMER_SECRET'), Config::get('TWITTER_OAUTH_TOKEN'), Config::get('TWITTER_OAUTH_SECRET'));
$status = $tweet->post('statuses/update', array('status' => $message, 'lat' => $lat, 'long' => $long, 'trim_user' => true));
return $status;
}
示例4: testTimesAdded
public function testTimesAdded()
{
$sql = 'SELECT `flighttime`
FROM ' . TABLE_PREFIX . 'pireps
WHERE `accepted`=' . PIREP_ACCEPTED;
$results = DB::get_results($sql);
if (!$results) {
$this->markTestSkipped('No PIREPs to test against');
}
$this->added_time = 0;
foreach ($results as $row) {
$this->added_time = Util::AddTime($this->added_time, $row->flighttime);
}
$this->assertNotEqual(0, $this->added_time);
// Now calculate by PIREP
$allpilots = PilotData::GetAllPilots();
$total = 0;
foreach ($allpilots as $pilot) {
$p_hours = PilotData::getPilotHours($pilot->pilotid);
$total = Util::AddTime($total, $p_hours);
}
$this->assertNotEqual(0, $total);
$this->assertEqual($total, $this->added_time);
StatsData::UpdateTotalHours();
$this->assertEqual($total, StatsData::TotalHours());
}
示例5: savepro
public function savepro()
{
if ($this->post->firstname == '' || $this->post->lastname == '') {
$this->set('message', 'The first or lastname cannot be blank!');
$this->render('core_error.tpl');
return;
}
$params = array('firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'hub' => $this->post->hub, 'retired' => $this->post->retired, 'totalflights' => $this->post->totalflights, 'totalpay' => floatval($this->post->totalpay), 'transferhours' => $this->post->transferhours);
PilotData::updateProfile($this->post->pilotid, $params);
PilotData::SaveFields($this->post->pilotid, $_POST);
/* Don't calculate a pilot's rank if this is set */
if (Config::Get('RANKS_AUTOCALCULATE') == false) {
PilotData::changePilotRank($this->post->pilotid, $this->post->rank);
} else {
RanksData::calculateUpdatePilotRank($this->post->pilotid);
}
StatsData::UpdateTotalHours();
$this->set('message', 'Profile updated successfully');
$this->render('core_success.tpl');
$this->set('pilots', PilotData::getAllPilots());
$this->render('/pm/pilot_manager.php');
if ($this->post->resend_email == 'true') {
$this->post->id = $this->post->pilotid;
$this->resendemail(false);
}
$pilot = PilotData::getPilotData($this->post->pilotid);
LogData::addLog(Auth::$userinfo->pilotid, 'Updated profile for ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' ' . $pilot->firstname . ' ' . $pilot->lastname);
return;
break;
}
示例6: testDeleteUser
function testDeleteUser()
{
$result = PilotData::DeletePilot($this->pilotid);
$this->assertTrue($result, 'Deleting pilot');
# Verify deletion
$data = PilotData::GetPilotData($this->pilotid);
$this->assertFalse($data, "Pilot still exists");
# Last test, add a line break
echo "<br />";
}
示例7: sendmail
public function sendmail()
{
$this->checkPermission(EMAIL_PILOTS);
echo '<h3>Sending email</h3>';
if ($this->post->subject == '' || trim($this->post->message) == '') {
$this->set('message', 'You must enter a subject and message!');
$this->render('core_error.php');
return;
}
if (count($this->post->groups) == 0) {
$this->set('message', 'You must select groups to send to!');
$this->render('core_error.php');
return;
}
echo 'Sending email...<br />';
$pilotarray = array();
//Begin the nice long assembly of e-mail addresses
foreach ($this->post->groups as $groupid) {
if ($groupid == 'all') {
$all_pilots = PilotData::findPilots(array());
foreach ($all_pilots as $pilot) {
$pilotarray[$pilot->pilotid] = $pilot;
}
break;
} else {
$tmp = PilotGroups::getUsersInGroup($groupid);
if (count($tmp) == 0 || !is_array($tmp)) {
continue;
}
foreach ($tmp as $pilot) {
$pilotarray[$pilot->pilotid] = $pilot;
}
}
}
$subject = DB::escape($this->post->subject);
$message = stripslashes($this->post->message) . PHP_EOL . PHP_EOL;
# Do some quick fixing of obvious formatting errors
$message = str_replace('<br>', '<br />', $message);
foreach ($pilotarray as $pilot) {
echo 'Sending for ' . $pilot->firstname . ' ' . $pilot->lastname . '<br />';
# Variable replacements
$send_message = str_replace('{PILOT_FNAME}', $pilot->firstname, $message);
$send_message = str_replace('{PILOT_LNAME}', $pilot->lastname, $send_message);
$send_message = str_replace('{PILOT_ID}', PilotData::GetPilotCode($pilot->code, $pilot->pilotid), $send_message);
$send_message = utf8_encode($send_message);
Util::SendEmail($pilot->email, $subject, $send_message);
}
echo 'Complete!';
LogData::addLog(Auth::$userinfo->pilotid, 'Sent pass mail');
return;
}
示例8: post_module_load
function post_module_load()
{
/* Misc tasks which need to get done */
/* If the setting to auto-retired pilots is on, then do that
and only check every 24 hours
*/
if (Config::Get('USE_CRON') == false) {
if (Config::Get('PILOT_AUTO_RETIRE') == true) {
$within_timelimit = CronData::check_hoursdiff('find_retired_pilots', '24');
if ($within_timelimit === false) {
PilotData::findRetiredPilots();
CronData::set_lastupdate('find_retired_pilots');
}
}
if (Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === false) {
$within_timelimit = CronData::check_hoursdiff('check_expired_bids', '24');
if ($within_timelimit === false) {
SchedulesData::deleteExpiredBids();
CronData::set_lastupdate('check_expired_bids');
}
}
/* Expenses, make sure they're all populated */
$within_timelimit = CronData::check_hoursdiff('populate_expenses', 18);
if ($within_timelimit === false) {
FinanceData::updateAllExpenses();
CronData::set_lastupdate('populate_expenses');
}
/* And finally, clear expired sessions */
Auth::clearExpiredSessions();
}
if (Config::Get('TWITTER_AIRLINE_ACCOUNT') != '') {
$within_timelimit = CronData::check_hoursdiff('twitter_update', '3');
if ($within_timelimit === false) {
ActivityData::readTwitter();
CronData::set_lastupdate('twitter_update');
}
}
// @TODO: Clean ACARS records older than one month
if (Config::Get('MAINTENANCE_MODE') == true && !Auth::LoggedIn() && !PilotGroups::group_has_perm(Auth::$usergroups, FULL_ADMIN)) {
Template::Show('maintenance.tpl');
die;
}
return true;
}
示例9: post_module_load
function post_module_load()
{
/* Misc tasks which need to get done */
/* If the setting to auto-retired pilots is on, then do that
and only check every 24 hours
*/
if (Config::Get('USE_CRON') === true) {
if (Config::Get('PILOT_AUTO_RETIRE') == true) {
$within_timelimit = CronData::check_hoursdiff('find_retired_pilots', '24');
if ($within_timelimit == false) {
PilotData::findRetiredPilots();
CronData::set_lastupdate('find_retired_pilots');
}
}
if (Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === false) {
$within_timelimit = CronData::check_hoursdiff('check_expired_bids', '24');
if ($within_timelimit == false) {
SchedulesData::deleteExpiredBids();
CronData::set_lastupdate('check_expired_bids');
}
}
/* Expenses, make sure they're all populated */
$within_timelimit = CronData::check_hoursdiff('populate_expenses', '18');
if ($within_timelimit == false) {
FinanceData::updateAllExpenses();
CronData::set_lastupdate('populate_expenses');
}
/* And finally, clear expired sessions */
Auth::clearExpiredSessions();
}
// @TODO: Clean ACARS records older than one month
if (Config::Get('MAINTENANCE_MODE') == true && !Auth::LoggedIn() && !PilotGroups::group_has_perm(Auth::$usergroups, FULL_ADMIN)) {
echo '<html><head><title>Down for maintenance - ' . SITE_NAME . '</title></head><body>';
Debug::showCritical(Config::Get('MAINTENANCE_MESSAGE'), 'Down for maintenance');
echo '</body></html>';
die;
}
return true;
}
示例10: FilePIREP
/**
* File a PIREP from an ACARS program
*
* @param mixed $pilotid The pilot ID of the pilot filing the PIREP
* @param mixed $data This is the data structure with the PIREP info
* @return bool true/false
*
*/
public static function FilePIREP($pilotid, $data)
{
if (!is_array($data)) {
self::$lasterror = 'PIREP data must be array';
return false;
}
# Call the pre-file event
#
if (CodonEvent::Dispatch('pirep_prefile', 'PIREPS', $_POST) == false) {
return false;
}
# File the PIREP report
#
$ret = PIREPData::FileReport($data);
# Set them as non-retired
PilotData::setPilotRetired($pilotid, 0);
if (!$ret) {
return false;
}
self::$pirepid = DB::$insert_id;
# Call the event
#
CodonEvent::Dispatch('pirep_filed', 'PIREPS', $_POST);
# Close out a bid if it exists
#
$bidid = SchedulesData::GetBidWithRoute($pilotid, $data['code'], $data['flightnum']);
if ($bidid) {
SchedulesData::RemoveBid($bidid->bidid);
}
return true;
}
示例11: testDeleteUser
/**
* UserTest::testDeleteUser()
*
* @return void
*/
public function testDeleteUser()
{
$pilot = PilotData::getPilotByEmail('unittest2@email.com');
$this->assertObjectHasAttribute('pilotid', $pilot, 'PilotData::getPilotByEmail');
$result = PilotData::deletePilot($pilot->pilotid);
$data = PilotData::GetPilotData($pilot->pilotid);
$this->assertFalse($data, "Pilot still exists");
}
示例12: write_template
protected function write_template($name, $save_as)
{
$this->set('pilotcode', PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid));
$this->set('userinfo', Auth::$userinfo);
$acars_config = Template::GetTemplate($name, true);
$acars_config = str_replace("\n", "\r\n", $acars_config);
Util::downloadFile($acars_config, $save_as);
return;
# Set the headers so the browser things a file is being sent
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="' . $save_as . '"');
header('Content-Length: ' . strlen($acars_config));
echo $acars_config;
}
示例13: define
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/
/* This is the maintenance cron file, which can run nightly.
You should either point to this file directly in your web-host's control panel
Or add an entry into the crontab file. I recommend running this maybe 2-3am,
*/
define('ADMIN_PANEL', true);
include dirname(dirname(__FILE__)) . '/core/codon.config.php';
Auth::$userinfo->pilotid = 0;
error_reporting(E_ALL);
ini_set('display_errors', 'on');
/* Clear expired sessions */
Auth::clearExpiredSessions();
/* Update any expenses */
FinanceData::updateAllExpenses();
if (Config::Get('PILOT_AUTO_RETIRE') == true) {
/* Find any retired pilots and set them to retired */
PilotData::findRetiredPilots();
CronData::set_lastupdate('find_retired_pilots');
}
if (Config::Get('CLOSE_BIDS_AFTER_EXPIRE') === false) {
SchedulesData::deleteExpiredBids();
CronData::set_lastupdate('check_expired_bids');
}
MaintenanceData::optimizeTables();
MainController::Run('Maintenance', 'resetpirepcount');
MainController::Run('Maintenance', 'resethours');
示例14: addUser
/**
* Add a User
*
* $data = array(
* 'firstname' => '',
* 'lastname' => '',
* 'email' => '',
* 'password' => '',
* 'code' => '',
* 'location' => '',
* 'hub' => '',
* 'confirm' => false);
*/
public static function addUser($data)
{
/*$data = array(
'firstname' => '',
'lastname' => '',
'email' => '',
'password' => '',
'code' => '',
'location' => '',
'hub' => '',
'confirm' => false);*/
$exists = self::CheckUserEmail($data['email']);
if (is_object($exists)) {
self::$error = 'Email already exists';
return false;
}
//Set the password, add some salt
$salt = md5(date('His'));
$password = md5($data['password'] . $salt);
//Stuff it into here, the confirmation email will use it.
self::$salt = $salt;
$code = DB::escape(strtoupper($data['code']));
$firstname = DB::escape(ucwords($data['firstname']));
$lastname = DB::escape(ucwords($data['lastname']));
$location = DB::escape(strtoupper($data['location']));
//Add this stuff in
if ($data['confirm'] === true) {
$confirm = 1;
} else {
$confirm = 0;
}
$sql = "INSERT INTO " . TABLE_PREFIX . "pilots (firstname, lastname, email,\n\t\t\t\t\tcode, location, hub, password, salt, confirmed, joindate, lastip)\n\t\t\t\t VALUES ('{$firstname}', '{$lastname}', '{$data['email']}', '{$code}',\n\t\t\t\t\t\t\t'{$location}', '{$data['hub']}', '{$password}', '{$salt}', {$confirm}, NOW(), '{$_SERVER['REMOTE_ADDR']}')";
$res = DB::query($sql);
if (DB::errno() != 0) {
if (DB::errno() == 1062) {
self::$error = 'This email address is already registered';
return false;
}
self::$error = DB::error();
return false;
}
//Grab the new pilotid, we need it to insert those "custom fields"
$pilotid = DB::$insert_id;
RanksData::CalculateUpdatePilotRank($pilotid);
PilotData::GenerateSignature($pilotid);
/* Add them to the default group */
$defaultGroup = SettingsData::getSettingValue('DEFAULT_GROUP');
PilotGroups::addUsertoGroup($pilotid, $defaultGroup);
// For later
self::$pilotid = $pilotid;
//Get customs fields
$fields = self::GetCustomFields();
if (!$fields) {
return true;
}
foreach ($fields as $field) {
$value = Vars::POST($field->fieldname);
$value = DB::escape($value);
if ($value != '') {
$sql = "INSERT INTO " . TABLE_PREFIX . "fieldvalues (fieldid, pilotid, value)\n\t\t\t\t\t\t\tVALUES ({$field->fieldid}, {$pilotid}, '{$value}')";
DB::query($sql);
}
}
return true;
}
示例15: edit_pirep_post
protected function edit_pirep_post()
{
if ($this->post->code == '' || $this->post->flightnum == '' || $this->post->depicao == '' || $this->post->arricao == '' || $this->post->aircraft == '' || $this->post->flighttime == '') {
$this->set('message', 'You must fill out all of the required fields!');
$this->render('core_error.tpl');
return false;
}
$pirepInfo = PIREPData::getReportDetails($this->post_action->pirepid);
if (!$pirepInfo) {
$this->set('message', 'Invalid PIREP!');
$this->render('core_error.tpl');
return false;
}
$this->post->fuelused = str_replace(' ', '', $this->post->fuelused);
$this->post->fuelused = str_replace(',', '', $this->post->fuelused);
$fuelcost = $this->post->fuelused * $this->post->fuelunitcost;
# form the fields to submit
$data = array('pirepid' => $this->post->pirepid, 'code' => $this->post->code, 'flightnum' => $this->post->flightnum, 'leg' => $this->post->leg, 'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'aircraft' => $this->post->aircraft, 'flighttime' => $this->post->flighttime, 'load' => $this->post->load, 'price' => $this->post->price, 'pilotpay' => $this->post->pilotpay, 'fuelused' => $this->post->fuelused, 'fuelunitcost' => $this->post->fuelunitcost, 'fuelprice' => $fuelcost, 'expenses' => $this->post->expenses);
if (!PIREPData::UpdateFlightReport($this->post->pirepid, $data)) {
$this->set('message', 'There was an error editing your PIREP');
$this->render('core_error.tpl');
return false;
}
PIREPData::SaveFields($this->post->pirepid, $_POST);
//Accept or reject?
$this->post->id = $this->post->pirepid;
$submit = strtolower($this->post->submit_pirep);
// Add a comment
if (trim($this->post->comment) != '' && $submit != 'reject pirep') {
PIREPData::AddComment($this->post->pirepid, Auth::$userinfo->pilotid, $this->post->comment);
}
if ($submit == 'accept pirep') {
$this->approve_pirep_post();
} elseif ($submit == 'reject pirep') {
$this->reject_pirep_post();
}
StatsData::UpdateTotalHours();
# Update a pilot's stats
PilotData::updatePilotStats($pirepInfo->pilotid);
LogData::addLog(Auth::$userinfo->pilotid, 'Edited PIREP #' . $this->post->id);
return true;
}