コード例 #1
0
ファイル: XML.php プロジェクト: ryanunderwood/phpVMS
 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
0
 /**
  * Dispatch an event to the modules, will call the
  *  modules with the EventListener() function.
  *
  * @see http://www.nsslive.net/codon/docs/events
  * @param string $eventname
  * @param string $origin
  * @param list $params list additional parameters after $origin
  * @return boolean true by default
  */
 public static function Dispatch($eventname, $origin)
 {
     // if there are parameters added, then call the function
     //	using those additional params
     $params = array();
     $params[0] = $eventname;
     $params[1] = $origin;
     $args = func_num_args();
     if ($args > 2) {
         for ($i = 2; $i < $args; $i++) {
             $tmp = func_get_arg($i);
             array_push($params, $tmp);
         }
     }
     # Load each module and call the EventListen function
     if (!self::$listeners) {
         self::$listeners = array();
     }
     foreach (self::$listeners as $ModuleName => $Events) {
         $ModuleName = strtoupper($ModuleName);
         global ${$ModuleName};
         # Run if no specific events specified, or if the eventname is there
         if (!$Events || in_array($eventname, $Events)) {
             self::$lastevent = $eventname;
             MainController::Run($ModuleName, 'EventListener', $params);
             if (isset(self::$stopList[$eventname]) && self::$stopList[$eventname] == true) {
                 unset(self::$stopList[$eventname]);
                 return false;
             }
         }
     }
     return true;
 }
コード例 #3
0
ファイル: Profile.php プロジェクト: ryanunderwood/phpVMS
 public function index()
 {
     if (!Auth::LoggedIn()) {
         $this->set('message', 'You must be logged in to access this feature!');
         $this->render('core_error.tpl');
         return;
     }
     /*
      * This is from /profile/editprofile
      */
     if (isset($this->post->action)) {
         if ($this->post->action == 'saveprofile') {
             $this->save_profile_post();
         }
         /* this comes from /profile/changepassword
          */
         if ($this->post->action == 'changepassword') {
             $this->change_password_post();
         }
     }
     if (Config::Get('TRANSFER_HOURS_IN_RANKS') == true) {
         $totalhours = intval(Auth::$userinfo->totalhours) + intval(Auth::$userinfo->transferhours);
     } else {
         $totalhours = Auth::$userinfo->totalhours;
     }
     $this->set('pilotcode', PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid));
     $this->set('report', PIREPData::GetLastReports(Auth::$userinfo->pilotid));
     $this->set('nextrank', RanksData::GetNextRank($totalhours));
     $this->set('allawards', AwardsData::GetPilotAwards(Auth::$userinfo->pilotid));
     $this->set('userinfo', Auth::$userinfo);
     $this->set('pilot_hours', $totalhours);
     $this->render('profile_main.tpl');
     CodonEvent::Dispatch('profile_viewed', 'Profile');
 }
コード例 #4
0
ファイル: Registration.php プロジェクト: ryanunderwood/phpVMS
 protected function ProcessRegistration()
 {
     // Yes, there was an error
     if (!$this->VerifyData()) {
         $this->ShowForm();
     } else {
         $data = array('firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'password' => $this->post->password1, 'code' => $this->post->code, 'location' => $this->post->location, 'hub' => $this->post->hub, 'confirm' => false);
         if (CodonEvent::Dispatch('registration_precomplete', 'Registration', $_POST) == false) {
             return false;
         }
         $ret = RegistrationData::CheckUserEmail($data['email']);
         if ($ret) {
             $this->set('error', Lang::gs('email.inuse'));
             $this->render('registration_error.tpl');
             return false;
         }
         $val = RegistrationData::AddUser($data);
         if ($val == false) {
             $this->set('error', RegistrationData::$error);
             $this->render('registration_error.tpl');
             return;
         } else {
             $pilotid = RegistrationData::$pilotid;
             /* Automatically confirm them if that option is set */
             if (Config::Get('PILOT_AUTO_CONFIRM') == true) {
                 PilotData::AcceptPilot($pilotid);
                 RanksData::CalculatePilotRanks();
                 $pilot = PilotData::GetPilotData($pilotid);
                 $this->set('pilot', $pilot);
                 $this->render('registration_autoconfirm.tpl');
             } else {
                 RegistrationData::SendEmailConfirm($email, $firstname, $lastname);
                 $this->render('registration_sentconfirmation.tpl');
             }
         }
         CodonEvent::Dispatch('registration_complete', 'Registration', $_POST);
         // Registration email/show user is waiting for confirmation
         $sub = 'A user has registered';
         $message = "The user {$data['firstname']} {$data['lastname']} ({$data['email']}) has registered, and is awaiting confirmation.";
         $email = Config::Get('EMAIL_NEW_REGISTRATION');
         if (empty($email)) {
             $email = ADMIN_EMAIL;
         }
         Util::SendEmail($email, $sub, $message);
         // Send email to user
         $this->set('firstname', $data['firstname']);
         $this->set('lastname', $data['lastname']);
         $this->set('userinfo', $data);
         $message = Template::Get('email_registered.tpl', true);
         Util::SendEmail($data['email'], 'Registration at ' . SITE_NAME, $message);
         $rss = new RSSFeed('Latest Pilot Registrations', SITE_URL, 'The latest pilot registrations');
         $allpilots = PilotData::GetLatestPilots();
         foreach ($allpilots as $pilot) {
             $rss->AddItem('Pilot ' . PilotData::GetPilotCode($pilot->code, $pilot->pilotid) . ' (' . $pilot->firstname . ' ' . $pilot->lastname . ')', SITE_URL . '/admin/index.php?admin=pendingpilots', '', '');
         }
         $rss->BuildFeed(LIB_PATH . '/rss/latestpilots.rss');
     }
 }
コード例 #5
0
ファイル: Login.php プロジェクト: Galihom/phpVMS
 public function ProcessLogin()
 {
     $email = $this->post->email;
     $password = $this->post->password;
     if ($email == '' || $password == '') {
         $this->set('message', 'You must fill out both your username and password');
         $this->render('login_form.tpl');
         return false;
     }
     if (!Auth::ProcessLogin($email, $password)) {
         $this->set('message', Auth::$error_message);
         $this->render('login_form.tpl');
         return false;
     } else {
         if (Auth::$pilot->confirmed == PILOT_PENDING) {
             $this->render('login_unconfirmed.tpl');
             Auth::LogOut();
             // show error
         } elseif (Auth::$pilot->confirmed == PILOT_REJECTED) {
             $this->render('login_rejected.tpl');
             Auth::LogOut();
         } else {
             $pilotid = Auth::$pilot->pilotid;
             $session_id = Auth::$session_id;
             # If they choose to be "remembered", then assign a cookie
             if ($this->post->remember == 'on') {
                 $cookie = "{$session_id}|{$pilotid}|{$_SERVER['REMOTE_ADDR']}";
                 $res = setrawcookie(VMS_AUTH_COOKIE, $cookie, time() + Config::Get('SESSION_LOGIN_TIME'), '/');
             }
             PilotData::updateLogin($pilotid);
             CodonEvent::Dispatch('login_success', 'Login');
             $this->post->redir = str_replace('index.php/', '', $this->post->redir);
             header('Location: ' . url('/' . $this->post->redir));
         }
         return;
     }
 }
コード例 #6
0
ファイル: ACARS.php プロジェクト: BogusCurry/phpvms_5.5.x
 public function data()
 {
     $flights = ACARSData::GetACARSData();
     if (!$flights) {
         $flights = array();
     }
     $this->acarsflights = array();
     foreach ($flights as $flight) {
         if ($flight->route == '') {
             $flight->route_details = array();
         } else {
             #declare stClass (php 5.5)
             $params = new stdClass();
             # Jeff's fix for ACARS
             $params->deplat = $flight->deplat;
             $params->deplng = $flight->deplng;
             $params->route = $flight->route;
             $flight->route_details = NavData::parseRoute($params);
         }
         $c = (array) $flight;
         // Convert the object to an array
         $c['pilotid'] = PilotData::GetPilotCode($c['code'], $c['pilotid']);
         // Normalize the data
         if ($c['timeremaining'] == '') {
             $c['timeremaining'] == '-';
         }
         if (trim($c['phasedetail']) == '') {
             $c['phasedetail'] = 'Enroute';
         }
         /* If no heading was passed via ACARS app then calculate it
         			This should probably move to inside the ACARSData function, so then
         			 the heading is always there for no matter what the calcuation is
         			*/
         if ($flight->heading == '') {
             /* Calculate an angle based on current coords and the
             			destination coordinates */
             $flight->heading = intval(atan2($flight->lat - $flight->arrlat, $flight->lng - $flight->arrlng) * 180 / 3.14);
             //$flight->heading *= intval(180/3.14159);
             if ($flight->lng - $flight->arrlng < 0) {
                 $flight->heading += 180;
             }
             if ($flight->heading < 0) {
                 $flight->heading += 360;
             }
         }
         // Little one-off fixes to normalize data
         $c['distremaining'] = $c['distremain'];
         $c['pilotname'] = $c['firstname'] . ' ' . $c['lastname'];
         unset($c['messagelog']);
         $this->acarsflights[] = $c;
         continue;
     }
     CodonEvent::Dispatch('refresh_acars', 'ACARS');
     echo json_encode($this->acarsflights);
 }
コード例 #7
0
 /**
  * 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;
 }
コード例 #8
0
ファイル: PIREPAdmin.php プロジェクト: ryanunderwood/phpVMS
 /**
  * Reject the report, and then send them the comment
  * that was entered into the report
  */
 protected function reject_pirep_post()
 {
     $pirepid = $this->post->pirepid;
     $comment = $this->post->comment;
     if ($pirepid == '' || $comment == '') {
         return;
     }
     PIREPData::ChangePIREPStatus($pirepid, PIREP_REJECTED);
     // 2 is rejected
     $pirep_details = PIREPData::GetReportDetails($pirepid);
     // If it was previously accepted, subtract the flight data
     if (intval($pirep_details->accepted) == PIREP_ACCEPTED) {
         PilotData::UpdateFlightData($pirep_details->pilotid, -1 * floatval($pirep->flighttime), -1);
     }
     //PilotData::UpdatePilotStats($pirep_details->pilotid);
     RanksData::CalculateUpdatePilotRank($pirep_details->pilotid);
     PilotData::resetPilotPay($pirep_details->pilotid);
     StatsData::UpdateTotalHours();
     // Send comment for rejection
     if ($comment != '') {
         $commenter = Auth::$userinfo->pilotid;
         // The person logged in commented
         PIREPData::AddComment($pirepid, $commenter, $comment);
         // Send them an email
         $this->set('firstname', $pirep_details->firstname);
         $this->set('lastname', $pirep_details->lastname);
         $this->set('pirepid', $pirepid);
         $message = Template::GetTemplate('email_commentadded.tpl', true);
         Util::SendEmail($pirep_details->email, 'Comment Added', $message);
     }
     LogData::addLog(Auth::$userinfo->pilotid, 'Rejected PIREP #' . $pirepid);
     # Call the event
     CodonEvent::Dispatch('pirep_rejected', 'PIREPAdmin', $pirep_details);
 }
コード例 #9
0
ファイル: Schedules.php プロジェクト: rallin/phpVMS
 public function addbid()
 {
     if (!Auth::LoggedIn()) {
         return;
     }
     $routeid = $this->get->id;
     if ($routeid == '') {
         echo 'No route passed';
         return;
     }
     // See if this is a valid route
     $route = SchedulesData::findSchedules(array('s.id' => $routeid));
     if (!is_array($route) && !isset($route[0])) {
         echo 'Invalid Route';
         return;
     }
     CodonEvent::Dispatch('bid_preadd', 'Schedules', $routeid);
     /* Block any other bids if they've already made a bid
      */
     if (Config::Get('DISABLE_BIDS_ON_BID') == true) {
         $bids = SchedulesData::getBids(Auth::$userinfo->pilotid);
         # They've got somethin goin on
         if (count($bids) > 0) {
             echo 'Bid exists!';
             return;
         }
     }
     $ret = SchedulesData::AddBid(Auth::$userinfo->pilotid, $routeid);
     CodonEvent::Dispatch('bid_added', 'Schedules', $routeid);
     if ($ret == true) {
         echo 'Bid added';
     } else {
         echo 'Already in bids!';
     }
 }
コード例 #10
0
ファイル: Maintenance.php プロジェクト: ryanunderwood/phpVMS
 public function changepilotid()
 {
     echo '<h3>Change Pilot ID</h3>';
     if (isset($this->post->submit)) {
         $error = false;
         if (!is_numeric($this->post->new_pilotid)) {
             $error = true;
             $this->set('message', 'The pilot ID isn\'t numeric!');
             $this->render('core_error.tpl');
             return;
         }
         if ($this->post->new_pilotid < 1) {
             $error = true;
             $this->set('message', 'You cannot have an ID less than 1');
             $this->render('core_error.tpl');
             return;
         }
         if (empty($this->post->new_pilotid)) {
             $error = true;
             $this->set('message', 'The pilot ID is blank!');
             $this->render('core_error.tpl');
             return;
         }
         if (empty($this->post->old_pilotid) || $this->post->old_pilotid == 0) {
             $error = true;
             $this->set('message', 'No pilot selected');
             $this->render('core_error.tpl');
             return;
         }
         $pilot = PilotData::getPilotData($this->post->new_pilotid);
         if (is_object($pilot)) {
             $error = true;
             $this->set('message', 'This ID is already used!');
             $this->render('core_error.tpl');
             return;
         }
         if ($error === false) {
             PilotData::changePilotID($this->post->old_pilotid, $this->post->new_pilotid);
             CodonEvent::Dispatch('pilotid_changed', 'Maintenance', array('old_pilotid' => $this->post->old_pilotid, 'new_pilotid' => $this->post->new_pilotid));
             $this->set('message', "Pilot ID changed from {$this->post->old_pilotid} to {$this->post->new_pilotid}");
             $this->render('core_success.tpl');
         }
     }
     $this->set('allpilots', PilotData::findPilots(array()));
     $this->render('maintenance_changepilotid.tpl');
 }
コード例 #11
0
ファイル: PIREPAdmin.php プロジェクト: Galihom/phpVMS
 /**
  * Reject the report, and then send them the comment
  * that was entered into the report
  */
 protected function reject_pirep_post()
 {
     $pirepid = $this->post->pirepid;
     $comment = $this->post->comment;
     if ($pirepid == '' || $comment == '') {
         return;
     }
     PIREPData::changePIREPStatus($pirepid, PIREP_REJECTED);
     // 2 is rejected
     $pirep_details = PIREPData::getReportDetails($pirepid);
     // Send comment for rejection
     if ($comment != '') {
         $commenter = Auth::$userinfo->pilotid;
         // The person logged in commented
         PIREPData::AddComment($pirepid, $commenter, $comment);
         // Send them an email
         $this->set('firstname', $pirep_details->firstname);
         $this->set('lastname', $pirep_details->lastname);
         $this->set('pirepid', $pirepid);
         $message = Template::GetTemplate('email_commentadded.tpl', true);
         Util::SendEmail($pirep_details->email, 'Comment Added', $message);
     }
     LogData::addLog(Auth::$userinfo->pilotid, 'Rejected PIREP #' . $pirepid);
     # Call the event
     CodonEvent::Dispatch('pirep_rejected', 'PIREPAdmin', $pirep_details);
 }
コード例 #12
0
ファイル: PIREPS.php プロジェクト: rallin/phpVMS
 protected function SubmitPIREP()
 {
     $pilotid = Auth::$userinfo->pilotid;
     if ($pilotid == '' || Auth::LoggedIn() == false) {
         $this->set('message', 'You must be logged in to access this feature!!');
         //$this->render('core_error.tpl');
         return false;
     }
     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!');
         return false;
     }
     # Only allow for valid routes to be filed
     $sched_data = SchedulesData::GetScheduleByFlight($this->post->code, $this->post->flightnum);
     if (!$sched_data) {
         $this->set('message', 'The flight code and number you entered is not a valid route!');
         return false;
     }
     # See if they entered more than 59 in the minutes part of the flight time
     $this->post->flighttime = str_replace(':', '.', $this->post->flighttime);
     $parts = explode('.', $this->post->flighttime);
     if ($parts[1] > 59) {
         $this->set('message', 'You entered more than 60 minutes in the minutes');
         return false;
     }
     /* Check the schedule and see if it's been bidded on */
     if (Config::Get('DISABLE_SCHED_ON_BID') == true) {
         $biddata = SchedulesData::GetBid($sched_data->bidid);
         if ($biddata) {
             if ($biddata->pilotid != $pilotid) {
                 $this->set('message', 'You are not the bidding pilot');
                 //$this->render('core_error.tpl');
                 return false;
             }
         }
     }
     /* Removed this check since maybe it's a training flight or something, who knows
        if($this->post->depicao == $this->post->arricao)
        {
        $this->set('message', 'The departure airport is the same as the arrival airport!');
        $this->render('core_error.tpl');
        return false;
        }*/
     $this->post->flighttime = str_replace(':', '.', $this->post->flighttime);
     if (!is_numeric($this->post->flighttime)) {
         $this->set('message', 'The flight time has to be a number!');
         return false;
     }
     # form the fields to submit
     $this->pirepdata = array('pilotid' => $pilotid, 'code' => $this->post->code, 'flightnum' => $this->post->flightnum, 'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'aircraft' => $this->post->aircraft, 'flighttime' => $this->post->flighttime, 'route' => $this->post->route, 'submitdate' => 'NOW()', 'fuelused' => $this->post->fuelused, 'source' => 'manual', 'comment' => $this->post->comment);
     CodonEvent::Dispatch('pirep_prefile', 'PIREPS');
     if (CodonEvent::hasStop('pirepfile')) {
         return false;
     }
     if (!PIREPData::FileReport($this->pirepdata)) {
         $this->set('message', 'There was an error adding your PIREP : ' . PIREPData::$lasterror);
         return false;
     }
     $pirepid = DB::$insert_id;
     PIREPData::SaveFields($pirepid, $_POST);
     # Remove the bid
     $bidid = SchedulesData::GetBidWithRoute($pilotid, $this->post->code, $this->post->flightnum);
     if ($bidid) {
         SchedulesData::RemoveBid($bidid->bidid);
     }
     # Call the event
     CodonEvent::Dispatch('pirep_filed', 'PIREPS');
     # Set them as non-retired
     PilotData::setPilotRetired($pilotid, 0);
     # Delete the bid, if the value for it is set
     if ($this->post->bid != '') {
         SchedulesData::RemoveBid($this->post->bid);
     }
     return true;
 }
コード例 #13
0
ファイル: PilotAdmin.php プロジェクト: rallin/phpVMS
 protected function RejectPilot()
 {
     $pilot = PilotData::GetPilotData($this->post->id);
     # Send pilot notification
     $subject = Lang::gs('email.register.rejected.subject');
     $this->set('pilot', $pilot);
     $message = Template::Get('email_registrationdenied.tpl', true, true, true);
     Util::SendEmail($pilot->email, $subject, $message);
     # Reject in the end, since it's delted
     PilotData::RejectPilot($this->post->id);
     CodonEvent::Dispatch('pilot_rejected', 'PilotAdmin', $pilot);
     LogData::addLog(Auth::$userinfo->pilotid, 'Approved ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' - ' . $pilot->firstname . ' ' . $pilot->lastname);
 }
コード例 #14
0
ファイル: PilotAdmin.php プロジェクト: phpmods/phpvms_5.5.x
 /**
  * PilotAdmin::RejectPilot()
  * 
  * @return
  */
 protected function RejectPilot()
 {
     $this->checkPermission(MODERATE_REGISTRATIONS);
     $pilot = PilotData::GetPilotData($this->post->id);
     # Send pilot notification
     $subject = Lang::gs('email.register.rejected.subject');
     $this->set('pilot', $pilot);
     $oldPath = Template::setTemplatePath(TEMPLATES_PATH);
     $oldSkinPath = Template::setSkinPath(ACTIVE_SKIN_PATH);
     $message = Template::Get('email_registrationdenied.php', true, true, true);
     Template::setTemplatePath($oldPath);
     Template::setSkinPath($oldSkinPath);
     Util::SendEmail($pilot->email, $subject, $message);
     # Reject in the end, since it's delted
     PilotData::RejectPilot($this->post->id);
     CodonEvent::Dispatch('pilot_rejected', 'PilotAdmin', $pilot);
     LogData::addLog(Auth::$userinfo->pilotid, 'Approved ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' - ' . $pilot->firstname . ' ' . $pilot->lastname);
 }