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');
     }
 }
 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 />";
 }
Exemple #3
0
 /**
  * Start the "auth engine", see if anyone is logged in and grab their info
  *
  * @return mixed This is the return value description
  *
  */
 public static function StartAuth()
 {
     self::$init = true;
     self::$session_id = SessionManager::Get('session_id');
     $assign_id = false;
     if (self::$session_id == '') {
         if ($_COOKIE[VMS_AUTH_COOKIE] != '') {
             $data = explode('|', $_COOKIE[VMS_AUTH_COOKIE]);
             $session_id = $data[0];
             $pilot_id = $data[1];
             $ip_address = $data[2];
             // TODO: Determine data reliability from IP addresses marked
             $session_info = self::get_session($session_id, $pilot_id, $ip_address);
             if ($session_info) {
                 /* Populate session info */
                 $userinfo = PilotData::GetPilotData($pilot_id);
                 if (!$userinfo) {
                     self::$loggedin = false;
                     return false;
                 }
                 self::$loggedin = true;
                 self::$userinfo = $userinfo;
                 self::$pilot = $userinfo;
                 self::$pilotid = self::$userinfo->pilotid;
                 self::$usergroups = SessionManager::Get('usergroups');
                 self::$session_id = $session_id;
                 if (self::$usergroups == '') {
                     self::$usergroups = PilotGroups::GetUserGroups($userinfo->pilotid);
                 }
                 SessionManager::Set('loggedin', true);
                 SessionManager::Set('userinfo', $userinfo);
                 SessionManager::Set('usergroups', self::$usergroups);
                 PilotData::UpdateLogin($userinfo->pilotid);
                 self::update_session(self::$session_id, self::$userinfo->pilotid);
                 return true;
             }
         }
         // Look for an existing session based on ID
         // No session ID was found anywhere so assign one
         $assign_id = true;
         self::$session_id = self::start_session(0);
         SessionManager::Set('session_id', self::$session_id);
     } else {
         // There's a session ID, so double check that they're logged in
         if (SessionManager::Get('loggedin') == true) {
             self::$loggedin = true;
             self::$userinfo = SessionManager::Get('userinfo');
             self::$pilot = self::$userinfo;
             self::$usergroups = PilotGroups::GetUserGroups(self::$userinfo->pilotid);
             self::$pilotid = self::$userinfo->pilotid;
             # Bugfix, in case user updates their profile info, grab the latest
             self::$userinfo = PilotData::GetPilotData(self::$pilotid);
             self::$pilot = self::$userinfo;
             self::update_session(self::$session_id, self::$userinfo->pilotid);
             return true;
         } else {
             // Already been assigned a session ID, and not signed in...
             self::$loggedin = false;
             self::update_session(self::$session_id, 0);
             $assign_id = false;
         }
     }
     // Empty session so start one up, and they're not logged in
     if ($assign_id == true) {
     }
     return true;
 }
Exemple #4
0
 /**
  * UserTest::testDeleteUser()
  * 
  * @return void
  */
 public function testDeleteUser()
 {
     $pilot = PilotData::getPilotByEmail('*****@*****.**');
     $this->assertObjectHasAttribute('pilotid', $pilot, 'PilotData::getPilotByEmail');
     $result = PilotData::deletePilot($pilot->pilotid);
     $data = PilotData::GetPilotData($pilot->pilotid);
     $this->assertFalse($data, "Pilot still exists");
 }
Exemple #5
0
 case 'pirep':
     Debug::log('PIREP FILE', 'fsacars');
     Debug::log(serialize($_GET), 'fsacars');
     $pilotid = PilotData::parsePilotID($_GET['pilot']);
     /*if(is_numeric($_GET['pilot']))
     		{
     			$pilotid = $_GET['pilot'];
     		}
     		else
     		{
     			# see if they are a valid pilot:
     			preg_match('/^([A-Za-z]*)(\d*)/', $_GET['pilot'], $matches);
     			$code = $matches[1];
     			$pilotid = intval($matches[2]) - Config::Get('PILOTID_OFFSET');
     		}*/
     if (!($pilot = PilotData::GetPilotData($pilotid))) {
         echo 'Invalid Pilot!';
         return;
     }
     #
     # Check if anything was in the log
     #	If not, then it probably wasn't a multi-chunk, so
     #	 just pull it straight from the query string
     #	Otherwise, pull the full-text from the session
     #
     if ($_GET['more'] == '1') {
         #
         # We have more coming to the log
         #
         $report = PIREPData::GetLastReports($pilotid, 1);
         /* Check for any other data which might be in the other
 public static function calculateUpdatePilotRank($pilotid)
 {
     /* Don't calculate a pilot's rank if this is set */
     if (Config::Get('RANKS_AUTOCALCULATE') == false) {
         return;
     }
     $pilotid = intval($pilotid);
     $allranks = self::GetAllRanks();
     $pilot = PilotData::GetPilotData($pilotid);
     $pilothours = $pilot->totalhours;
     if (Config::Get('TRANSFER_HOURS_IN_RANKS') == true) {
         $pilothours += $pilot->transferhours;
     }
     $i = 0;
     foreach ($allranks as $rank) {
         $i++;
         if ($pilothours >= intval($rank->minhours)) {
             $rank_level = $i;
             $last_rank = $rank->rank;
             $last_rankid = $rank->rankid;
         }
     }
     $update = array('rankid' => $last_rankid, 'rank' => $last_rank, 'ranklevel' => $rank_level);
     PilotData::updateProfile($pilot->pilotid, $update);
 }
Exemple #7
0
    	else
    	{
    		$pilotid = $pilotid = PilotData::parsePilotID($_POST['UserName']);
    		# Check if they entered as XXX###
    		if(preg_match('/^([A-Za-z]*)(.*)(\d*)/', $_POST['UserName'], $matches)>0)
    		{
    			$pilotid = intval(intval(trim($matches[2]))) - Config::Get('PILOTID_OFFSET');
    		}
    		else
    		{
    			# Invalid Pilot
    			echo '#Answer# Error - Invalid pilot ID format;';
    			return;
    		}
    	}*/
    $pilotdata = PilotData::GetPilotData($pilotid);
    if (!$pilotdata) {
        echo '#Answer# Error - Username don\'t exist or wrong password;';
        return;
    }
    # Give it what it wants
    # Derive the config from the main config settings
    echo "#Answer# Ok - connected;";
    echo 'Weight=' . Config::Get('WeightUnit') . ' Dist=' . Config::Get('DistanceUnit') . ' Speed=' . Config::Get('SpeedUnit') . ' Alt=' . Config::Get('AltUnit') . ' Liqu=' . Config::Get('LiquidUnit');
    echo '#welcome#' . Config::Get('WelcomeMessage') . '#endwelcome#';
}
if ($_POST['FsPAskToRegister'] == 'yes') {
    $comment = '';
    # Get the pilot id:
    $pilotid = PilotData::parsePilotID($_POST['UserName']);
    /*if(is_numeric($_POST['UserName']))
Exemple #8
0
 public function unassign_exam()
 {
     $pilot_id = $_GET['pilot_id'];
     $exam_id = $_GET['exam_id'];
     ExamsData::unassign_exam($pilot_id, $exam_id);
     $this->set('pilot', PilotData::GetPilotData($pilot_id));
     $this->set('exams', ExamsData::get_exams());
     $this->set('assigned', ExamsData::get_assigned_exams($pilot_id));
     $this->show('exams/exam_assign_list');
 }
Exemple #9
0
 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);
 }
Exemple #10
0
 /**
  * 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);
 }