예제 #1
0
 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');
     }
 }
예제 #2
0
파일: UserTest.php 프로젝트: Galihom/phpVMS
 /**
  * UserTest::testRegisterUser()
  * 
  * @return void
  */
 public function testRegisterUser()
 {
     $data = RegistrationData::addUser($this->registrationData);
     $this->assertTrue($data, 'Reported error: ' . RegistrationData::$error);
     $this->pilotid = RegistrationData::$pilotid;
     $this->assertGreaterThan(0, $this->pilotid, 'Valid pilot ID');
     $this->assertEquals(0, DB::errno(), 'User Registration');
     # See if it was written
     $this->pilot_data = PilotData::getPilotData($this->pilotid);
     $this->assertObjectHasAttribute('pilotid', $this->pilot_data, 'Retrieve user data');
 }
예제 #3
0
 function testRegisterUser()
 {
     $firstname = 'Nabeel';
     $lastname = 'Shahzad';
     $email = '*****@*****.**';
     $code = 'VMS';
     $location = 'US';
     $hub = 'KJFK';
     $password = '******';
     $data = RegistrationData::AddUser($firstname, $lastname, $email, $code, $location, $hub, $password);
     $this->pilotid = DB::$insert_id;
     # See if it was written
     $this->pilot_data = PilotData::GetPilotData($this->pilotid);
     $this->assertTrue($this->pilot_data);
     echo '<br />';
     unset($data);
 }
예제 #4
0
파일: Login.php 프로젝트: Galihom/phpVMS
 public function ResetPassword()
 {
     $email = $this->post->email;
     if (!$email) {
         return false;
     } else {
         $pilot = PilotData::GetPilotByEmail($email);
         if (!$pilot) {
             $this->render('login_notfound.tpl');
             return;
         }
         $newpw = substr(md5(date('mdYhs')), 0, 6);
         RegistrationData::ChangePassword($pilot->pilotid, $newpw);
         $this->set('firstname', $pilot->firstname);
         $this->set('lastname', $pilot->lastname);
         $this->set('newpw', $newpw);
         $message = Template::GetTemplate('email_lostpassword.tpl', true);
         Util::SendEmail($pilot->email, 'Password Reset', $message);
         $this->render('login_passwordreset.tpl');
     }
 }
예제 #5
0
 /**
  * Installer::SiteSetup()
  * 
  * @return
  */
 public static function SiteSetup()
 {
     /*$_POST['SITE_NAME'] == '' || $_POST['firstname'] == '' || $_POST['lastname'] == ''
     		|| $_POST['email'] == '' ||  $_POST['password'] == '' || $_POST['vaname'] == ''
     		|| $_POST['vacode'] == ''*/
     // first add the airline
     $_POST['vacode'] = strtoupper($_POST['vacode']);
     if (!OperationsData::addAirline($_POST['vacode'], $_POST['vaname'])) {
         self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error;
         return false;
     }
     // Add the user
     $data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email'], l, 'password' => $_POST['password'], 'code' => $_POST['vacode'], 'location' => 'US', 'hub' => 'KJFK', 'confirm' => true);
     if (!RegistrationData::addUser($data)) {
         self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error;
         return false;
     }
     RanksData::calculatePilotRanks();
     # Add to admin group
     $pilotdata = PilotData::getPilotByEmail($_POST['email']);
     if (!PilotGroups::addUsertoGroup($pilotdata->pilotid, 'Administrators')) {
         self::$error = __FILE__ . ' ' . __LINE__ . ' ' . DB::$error;
         return false;
     }
     # Add the final settings in
     SettingsData::SaveSetting('SITE_NAME', $_POST['SITE_NAME']);
     SettingsData::SaveSetting('ADMIN_EMAIL', $_POST['email']);
     SettingsData::SaveSetting('GOOGLE_KEY', $_POST['googlekey']);
     return true;
 }
예제 #6
0
    /**
     * This saves all of the custom fields attributed to pilot
     * Pass an associated array (fieldname NOT title) to value
     *
     * @param int $pilotid Pilot ID
     * @param array $list fieldname=>fieldvalue associated array
     * @return bool Success value
     *
     */
    public static function saveFields($pilotid, $list)
    {
        $allfields = RegistrationData::getCustomFields(true);
        if (!$allfields) {
            return true;
        }
        foreach ($allfields as $field) {
            $sql = 'SELECT id FROM ' . TABLE_PREFIX . 'fieldvalues 
					WHERE fieldid=' . $field->fieldid . ' 
						AND pilotid=' . $pilotid;
            $res = DB::get_row($sql);
            $fieldname = str_replace(' ', '_', $field->fieldname);
            if (!isset($list[$fieldname])) {
                continue;
            }
            $value = $list[$fieldname];
            // if it exists
            if ($res) {
                $sql = 'UPDATE ' . TABLE_PREFIX . 'fieldvalues
						SET value="' . $value . '" 
						WHERE fieldid=' . $field->fieldid . ' AND pilotid=' . $pilotid;
            } else {
                $sql = "INSERT INTO " . TABLE_PREFIX . "fieldvalues\n\t\t\t\t\t\t(fieldid, pilotid, value) VALUES ({$field->fieldid}, {$pilotid}, '{$value}')";
            }
            DB::query($sql);
        }
        return true;
    }
 public function GetRegistrationList($regIdFilterRegex, $courseIdFilterRegex)
 {
     $request = new ServiceRequest($this->_configuration);
     $params = array();
     if (isset($regIdFilterRegex)) {
         $params['filter'] = $regIdFilterRegex;
     }
     if (isset($courseIdFilterRegex)) {
         $params['coursefilter'] = $courseIdFilterRegex;
     }
     $request->setMethodParams($params);
     $response = $request->CallService("rustici.registration.getRegistrationList");
     //echo $response;
     $regData = new RegistrationData(null);
     // Return the subset of the xml starting with the top <summary>
     $regArray = $regData->ConvertToRegistrationDataList($response);
     return $regArray;
 }
예제 #8
0
 protected function change_password_post()
 {
     if (!Auth::LoggedIn()) {
         $this->set('message', 'You must be logged in to access this feature!');
         $this->render('core_error.tpl');
         return;
     }
     // Verify
     if ($this->post->oldpassword == '') {
         $this->set('message', 'You must enter your current password');
         $this->render('core_error.tpl');
         return;
     }
     if ($this->post->password1 != $this->post->password2) {
         $this->set('message', 'Your passwords do not match');
         $this->render('core_error.tpl');
         return;
     }
     // Change
     $hash = md5($this->post->oldpassword . Auth::$userinfo->salt);
     if ($hash == Auth::$userinfo->password) {
         RegistrationData::ChangePassword(Auth::$pilotid, $_POST['password1']);
         $this->set('message', 'Your password has been reset');
     } else {
         $this->set('message', 'You entered an invalid password');
     }
     $this->render('core_success.tpl');
 }
예제 #9
0
 public static function ChangePassword($pilotid, $newpassword)
 {
     $salt = md5(date('His'));
     $password = md5($newpassword . $salt);
     self::$salt = $salt;
     //, confirmed='y'
     $sql = "UPDATE " . TABLE_PREFIX . "pilots \n\t\t\t\t\tSET password='******', \n\t\t\t\t\t\tsalt='{$salt}'\n\t\t\t\t\tWHERE pilotid={$pilotid}";
     $res = DB::query($sql);
     if (DB::errno() != 0) {
         return false;
     }
     return true;
 }
예제 #10
0
 public static function SiteSetup()
 {
     /*$_POST['SITE_NAME'] == '' || $_POST['firstname'] == '' || $_POST['lastname'] == ''
     		|| $_POST['email'] == '' ||  $_POST['password'] == '' || $_POST['vaname'] == ''
     		|| $_POST['vacode'] == ''*/
     // first add the airline
     $_POST['vacode'] = strtoupper($_POST['vacode']);
     if (!OperationsData::AddAirline($_POST['vacode'], $_POST['vaname'])) {
         self::$error = DB::$error;
         return false;
     }
     // Add an initial airport/hub, because I love KJFK so much
     $data = array('icao' => 'KJFK', 'name' => 'Kennedy International', 'country' => 'USA', 'lat' => '40.6398', 'lng' => '-73.7787', 'hub' => false, 'fuelprice' => 0);
     $ret = OperationsData::AddAirport($data);
     // Add the user
     $data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email'], l, 'password' => $_POST['password'], 'code' => $_POST['vacode'], 'location' => 'US', 'hub' => 'KJFK', 'confirm' => true);
     if (!RegistrationData::AddUser($data)) {
         self::$error = DB::$error;
         return false;
     }
     // Add a rank
     RanksData::updateRank(1, 'New Hire', 0, fileurl('/lib/images/ranks/newhire.jpg'), 18.0);
     # Add to admin group
     $pilotdata = PilotData::GetPilotByEmail($_POST['email']);
     if (!PilotGroups::AddUsertoGroup($pilotdata->pilotid, 'Administrators')) {
         self::$error = DB::$error;
         return false;
     }
     # Add the final settings in
     SettingsData::SaveSetting('SITE_NAME', $_POST['SITE_NAME']);
     SettingsData::SaveSetting('ADMIN_EMAIL', $_POST['email']);
     SettingsData::SaveSetting('GOOGLE_KEY', $_POST['googlekey']);
     return true;
 }
예제 #11
0
 protected function ChangePassword()
 {
     $password1 = $this->post->password1;
     $password2 = $this->post->password2;
     // Check password length
     if (strlen($password1) <= 5) {
         $this->set('message', Lang::gs('password.wrong.length'));
         $this->render('core_message.tpl');
         return;
     }
     // Check is passwords are the same
     if ($password1 != $password2) {
         $this->set('message', Lang::gs('password.no.match'));
         $this->render('core_message.tpl');
         return;
     }
     RegistrationData::ChangePassword($this->post->pilotid, $password1);
     if (DB::errno() != 0) {
         $this->set('message', 'There was an error, administrator has been notified');
         $this->render('core_error.tpl');
     } else {
         $this->set('message', Lang::gs('password.changed'));
         $this->render('core_success.tpl');
     }
     $pilot = PilotData::getPilotData($this->post->pilotid);
     LogData::addLog(Auth::$userinfo->pilotid, 'Changed the password for ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' - ' . $pilot->firstname . ' ' . $pilot->lastname);
 }