示例#1
0
 /**
  * Account activation - set password part
  *
  * @author dekarma
  */
 function action_activatesetpwd()
 {
     $key = postVar('key');
     // clean up old activation keys
     MEMBER::cleanupActivationTable();
     // get activation info
     $info = MEMBER::getActivationInfo($key);
     if (!$info || $info->type == 'addresschange') {
         return $this->_showActivationPage($key, _ERROR_ACTIVATE);
     }
     $mem = MEMBER::createFromId($info->vmember);
     if (!$mem) {
         return $this->_showActivationPage($key, _ERROR_ACTIVATE);
     }
     $password = postVar('password');
     $repeatpassword = postVar('repeatpassword');
     if (!$password) {
         return $this->_showActivationPage($key, _ERROR_PASSWORDMISSING);
     }
     if ($password != $repeatpassword) {
         return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
     }
     if (strlen($password) < 6) {
         return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
     }
     $pwdvalid = true;
     $pwderror = '';
     global $manager;
     $manager->notify('PrePasswordSet', array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
     if (!$pwdvalid) {
         return $this->_showActivationPage($key, $pwderror);
     }
     $error = '';
     $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
     if ($error != '') {
         return $this->_showActivationPage($key, $error);
     }
     // set password
     $mem->setPassword($password);
     $mem->write();
     // do the activation
     MEMBER::activate($key);
     $this->pagehead();
     echo '<h2>', _ACTIVATE_SUCCESS_TITLE, '</h2>';
     echo '<p>', _ACTIVATE_SUCCESS_TEXT, '</p>';
     $this->pagefoot();
 }