/**
  * Validates given password.
  * 
  * @return	array
  */
 public function validatePassword()
 {
     if (!UserRegistrationUtil::isSecurePassword($this->parameters['password'])) {
         return array('isValid' => false, 'error' => 'notSecure');
     }
     return array('isValid' => true);
 }
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     AbstractForm::save();
     // generate activation code
     $activationCode = UserRegistrationUtil::getActivationCode();
     // save user
     $this->objectAction = new UserAction(array($this->user), 'update', array('data' => array_merge($this->additionalFields, array('reactivationCode' => $activationCode))));
     $this->objectAction->executeAction();
     // send activation mail
     $messageData = array('username' => $this->user->username, 'userID' => $this->user->userID, 'activationCode' => $activationCode);
     $mail = new Mail(array($this->user->username => $this->user->newEmail), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail', $messageData));
     $mail->send();
     $this->saved();
     // forward to index page
     HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation'), 10);
     exit;
 }
Beispiel #3
0
 /**
  * Disables users.
  */
 public function disable()
 {
     if (empty($this->objects)) {
         $this->readObjects();
     }
     $action = new UserAction($this->objects, 'update', array('data' => array('activationCode' => UserRegistrationUtil::getActivationCode()), 'removeGroups' => UserGroup::getGroupIDsByType(array(UserGroup::USERS))));
     $action->executeAction();
     $action = new UserAction($this->objects, 'addToGroups', array('groups' => UserGroup::getGroupIDsByType(array(UserGroup::GUESTS)), 'deleteOldGroups' => false, 'addDefaultGroups' => false));
     $action->executeAction();
     $this->unmarkItems();
 }
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     parent::save();
     $success = array();
     $updateParameters = array();
     // quit
     if (WCF::getSession()->getPermission('user.profile.canQuit')) {
         if (!WCF::getUser()->quitStarted && $this->quit == 1) {
             $updateParameters['quitStarted'] = TIME_NOW;
             $this->quitStarted = TIME_NOW;
             $success[] = 'wcf.user.quit.success';
         } else {
             if (WCF::getUser()->quitStarted && $this->cancelQuit == 1) {
                 $updateParameters['quitStarted'] = 0;
                 $this->quitStarted = 0;
                 $success[] = 'wcf.user.quit.cancel.success';
             }
         }
     }
     // user name
     if (WCF::getSession()->getPermission('user.profile.canRename') && $this->username != WCF::getUser()->username) {
         if (mb_strtolower($this->username) != mb_strtolower(WCF::getUser()->username)) {
             $updateParameters['lastUsernameChange'] = TIME_NOW;
             $updateParameters['oldUsername'] = WCF::getUser()->username;
         }
         $updateParameters['username'] = $this->username;
         $success[] = 'wcf.user.changeUsername.success';
     }
     // email
     if (WCF::getSession()->getPermission('user.profile.canChangeEmail') && $this->email != WCF::getUser()->email && $this->email != WCF::getUser()->newEmail) {
         if (REGISTER_ACTIVATION_METHOD == 0 || REGISTER_ACTIVATION_METHOD == 2 || mb_strtolower($this->email) == mb_strtolower(WCF::getUser()->email)) {
             // update email
             $updateParameters['email'] = $this->email;
             $success[] = 'wcf.user.changeEmail.success';
         } else {
             if (REGISTER_ACTIVATION_METHOD == 1) {
                 // get reactivation code
                 $activationCode = UserRegistrationUtil::getActivationCode();
                 // save as new email
                 $updateParameters['reactivationCode'] = $activationCode;
                 $updateParameters['newEmail'] = $this->email;
                 $messageData = array('username' => WCF::getUser()->username, 'userID' => WCF::getUser()->userID, 'activationCode' => $activationCode);
                 $mail = new Mail(array(WCF::getUser()->username => $this->email), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail', $messageData));
                 $mail->send();
                 $success[] = 'wcf.user.changeEmail.needReactivation';
             }
         }
     }
     // password
     if (!WCF::getUser()->authData) {
         if (!empty($this->newPassword) || !empty($this->confirmNewPassword)) {
             $updateParameters['password'] = $this->newPassword;
             $success[] = 'wcf.user.changePassword.success';
         }
     }
     // 3rdParty
     if (GITHUB_PUBLIC_KEY !== '' && GITHUB_PRIVATE_KEY !== '') {
         if ($this->githubConnect && WCF::getSession()->getVar('__githubToken')) {
             $updateParameters['authData'] = 'github:' . WCF::getSession()->getVar('__githubToken');
             $success[] = 'wcf.user.3rdparty.github.connect.success';
             WCF::getSession()->unregister('__githubToken');
             WCF::getSession()->unregister('__githubUsername');
         }
     }
     if ($this->githubDisconnect && StringUtil::startsWith(WCF::getUser()->authData, 'github:')) {
         $updateParameters['authData'] = '';
         $success[] = 'wcf.user.3rdparty.github.disconnect.success';
     }
     if (TWITTER_PUBLIC_KEY !== '' && TWITTER_PRIVATE_KEY !== '') {
         if ($this->twitterConnect && WCF::getSession()->getVar('__twitterData')) {
             $twitterData = WCF::getSession()->getVar('__twitterData');
             $updateParameters['authData'] = 'twitter:' . $twitterData['user_id'];
             $success[] = 'wcf.user.3rdparty.twitter.connect.success';
             WCF::getSession()->unregister('__twitterData');
             WCF::getSession()->unregister('__twitterUsername');
         }
     }
     if ($this->twitterDisconnect && StringUtil::startsWith(WCF::getUser()->authData, 'twitter:')) {
         $updateParameters['authData'] = '';
         $success[] = 'wcf.user.3rdparty.twitter.disconnect.success';
     }
     if (FACEBOOK_PUBLIC_KEY !== '' && FACEBOOK_PRIVATE_KEY !== '') {
         if ($this->facebookConnect && WCF::getSession()->getVar('__facebookData')) {
             $facebookData = WCF::getSession()->getVar('__facebookData');
             $updateParameters['authData'] = 'facebook:' . $facebookData['id'];
             $success[] = 'wcf.user.3rdparty.facebook.connect.success';
             WCF::getSession()->unregister('__facebookData');
             WCF::getSession()->unregister('__facebookUsername');
         }
     }
     if ($this->facebookDisconnect && StringUtil::startsWith(WCF::getUser()->authData, 'facebook:')) {
         $updateParameters['authData'] = '';
         $success[] = 'wcf.user.3rdparty.facebook.disconnect.success';
     }
     if (GOOGLE_PUBLIC_KEY !== '' && GOOGLE_PRIVATE_KEY !== '') {
         if ($this->googleConnect && WCF::getSession()->getVar('__googleData')) {
             $googleData = WCF::getSession()->getVar('__googleData');
             $updateParameters['authData'] = 'google:' . $googleData['id'];
             $success[] = 'wcf.user.3rdparty.google.connect.success';
             WCF::getSession()->unregister('__googleData');
             WCF::getSession()->unregister('__googleUsername');
         }
     }
     if ($this->googleDisconnect && StringUtil::startsWith(WCF::getUser()->authData, 'google:')) {
         $updateParameters['authData'] = '';
         $success[] = 'wcf.user.3rdparty.google.disconnect.success';
     }
     $data = array();
     if (!empty($updateParameters) || !empty($this->additionalFields)) {
         $data['data'] = array_merge($this->additionalFields, $updateParameters);
     }
     $this->objectAction = new UserAction(array(WCF::getUser()), 'update', $data);
     $this->objectAction->executeAction();
     // update cookie
     if (isset($_COOKIE[COOKIE_PREFIX . 'password']) && isset($updateParameters['password'])) {
         // reload user
         $user = new User(WCF::getUser()->userID);
         HeaderUtil::setCookie('password', PasswordUtil::getSaltedHash($updateParameters['password'], $user->password), TIME_NOW + 365 * 24 * 3600);
     }
     $this->saved();
     $success = array_merge($success, WCF::getTPL()->get('success') ?: array());
     // show success message
     WCF::getTPL()->assign('success', $success);
     // reset password
     $this->password = '';
     $this->newPassword = $this->confirmNewPassword = '';
 }
 /**
  * Exports users.
  */
 public function exportUsers($offset, $limit)
 {
     // cache profile fields
     $profileFields = $knownProfileFields = array();
     $sql = "SELECT\t*\n\t\t\tFROM\t" . $this->databasePrefix . "profilefields";
     $statement = $this->database->prepareStatement($sql);
     $statement->execute();
     while ($row = $statement->fetchArray()) {
         if (in_array($row['name'], self::$knownProfileFields)) {
             $knownProfileFields[$row['name']] = $row;
         } else {
             $profileFields[] = $row;
         }
     }
     // prepare password update
     $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tpassword = ?\n\t\t\tWHERE\tuserID = ?";
     $passwordUpdateStatement = WCF::getDB()->prepareStatement($sql);
     // get users
     $sql = "SELECT\t\tuserfields_table.*, user_table.*, activation_table.code AS activationCode, activation_table.type AS activationType,\n\t\t\t\t\tactivation_table.misc AS newEmail, ban_table.reason AS banReason\n\t\t\tFROM\t\t" . $this->databasePrefix . "users user_table\n\t\t\tLEFT JOIN\t" . $this->databasePrefix . "awaitingactivation activation_table\n\t\t\tON\t\tuser_table.uid = activation_table.uid\n\t\t\tLEFT JOIN\t" . $this->databasePrefix . "userfields userfields_table\n\t\t\tON\t\tuser_table.uid = userfields_table.ufid\n\t\t\tLEFT JOIN\t" . $this->databasePrefix . "banned ban_table\n\t\t\tON\t\tuser_table.uid = ban_table.uid AND ban_table.lifted <> ?\n\t\t\tWHERE\t\tuser_table.uid BETWEEN ? AND ?\n\t\t\tORDER BY\tuser_table.uid";
     $statement = $this->database->prepareStatement($sql);
     $statement->execute(array(0, $offset + 1, $offset + $limit));
     while ($row = $statement->fetchArray()) {
         $data = array('username' => $row['username'], 'password' => '', 'email' => $row['email'], 'registrationDate' => $row['regdate'], 'banned' => $row['banReason'] === null ? 0 : 1, 'banReason' => $row['banReason'], ($row['activationType'] == 'e' ? 're' : '') . 'activationCode' => $row['activationCode'] ? UserRegistrationUtil::getActivationCode() : 0, 'newEmail' => $row['newEmail'] ?: '', 'oldUsername' => '', 'registrationIpAddress' => UserUtil::convertIPv4To6($row['regip']), 'signature' => $row['signature'], 'signatureEnableBBCodes' => 1, 'signatureEnableHtml' => 0, 'signatureEnableSmilies' => 1, 'disableSignature' => $row['suspendsignature'], 'disableSignatureReason' => '', 'userTitle' => $row['usertitle'], 'lastActivityTime' => $row['lastactive']);
         $birthday = \DateTime::createFromFormat('j-n-Y', $row['birthday']);
         // get user options
         $options = array('location' => isset($knownProfileFields['Location']) && !empty($row['fid' . $knownProfileFields['Location']['fid']]) ? $row['fid' . $knownProfileFields['Location']['fid']] : '', 'birthday' => $birthday ? $birthday->format('Y-m-d') : '', 'icq' => $row['icq'], 'homepage' => $row['website']);
         // get gender
         if (isset($knownProfileFields['Sex']) && !empty($row['fid' . $knownProfileFields['Sex']['fid']])) {
             switch ($row['fid' . $knownProfileFields['Sex']['fid']]) {
                 case 'Male':
                     $options['gender'] = UserProfile::GENDER_MALE;
                     break;
                 case 'Female':
                     $options['gender'] = UserProfile::GENDER_FEMALE;
             }
         }
         $additionalData = array('groupIDs' => array_unique(ArrayUtil::toIntegerArray(explode(',', $row['additionalgroups'] . ',' . $row['usergroup']))), 'options' => $options);
         // handle user options
         foreach ($profileFields as $profileField) {
             if (!empty($row['fid' . $profileField['fid']])) {
                 $additionalData['options'][$profileField['fid']] = $row['fid' . $profileField['fid']];
             }
         }
         // import user
         $newUserID = ImportHandler::getInstance()->getImporter('com.woltlab.wcf.user')->import($row['uid'], $data, $additionalData);
         // update password hash
         if ($newUserID) {
             $passwordUpdateStatement->execute(array('mybb1:' . $row['password'] . ':' . $row['salt'], $newUserID));
         }
     }
 }
 /**
  * @see \wcf\form\IForm::save()
  */
 public function save()
 {
     AbstractForm::save();
     // get options
     $saveOptions = $this->optionHandler->save();
     $registerVia3rdParty = true;
     $avatarURL = '';
     if (isset($this->ttid_profile['avatar_url']) && !empty($this->ttid_profile['avatar_url'])) {
         $avatarURL = $this->ttid_profile['avatar_url'];
     }
     $this->additionalFields['languageID'] = $this->languageID;
     if (LOG_IP_ADDRESS) {
         $this->additionalFields['registrationIpAddress'] = WCF::getSession()->ipAddress;
     }
     // generate activation code
     $addDefaultGroups = true;
     if ($this->verified !== true && REGISTER_ACTIVATION_METHOD != 0 || $this->verified === true && REGISTER_ACTIVATION_METHOD == 2 && !WBB_TAPATALK_REG_AUTO_APPROVAL) {
         $activationCode = UserRegistrationUtil::getActivationCode();
         $this->additionalFields['activationCode'] = $activationCode;
         $addDefaultGroups = false;
         $this->groupIDs = UserGroup::getGroupIDsByType(array(UserGroup::EVERYONE, UserGroup::GUESTS));
     }
     // check gravatar support
     if (MODULE_GRAVATAR && Gravatar::test($this->email)) {
         $this->additionalFields['enableGravatar'] = 1;
     }
     // create user
     $data = array('data' => array_merge($this->additionalFields, array('username' => $this->username, 'email' => $this->email, 'password' => $this->password)), 'groups' => $this->groupIDs, 'languageIDs' => $this->visibleLanguages, 'options' => $saveOptions, 'addDefaultGroups' => $addDefaultGroups);
     $this->objectAction = new UserAction(array(), 'create', $data);
     $result = $this->objectAction->executeAction();
     $user = $result['returnValues'];
     $userEditor = new UserEditor($user);
     // set avatar if provided
     if (!empty($avatarURL)) {
         $userAvatarAction = new UserAvatarAction(array(), 'fetchRemoteAvatar', array('url' => $avatarURL, 'userEditor' => $userEditor));
         $userAvatarAction->executeAction();
     }
     // update session
     WCF::getSession()->changeUser($user);
     // activation management
     if (REGISTER_ACTIVATION_METHOD == 0) {
         $this->message = 'wcf.user.register.success';
     } else {
         if (REGISTER_ACTIVATION_METHOD == 1) {
             // registering via 3rdParty leads to instant activation
             if ($registerVia3rdParty && $this->verified) {
                 $this->message = 'wcf.user.register.success';
             } else {
                 $mail = new Mail(array($this->username => $this->email), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail', array('user' => $user)));
                 $mail->send();
                 $this->message = 'wcf.user.register.needActivation';
             }
         } else {
             if (REGISTER_ACTIVATION_METHOD == 2 && (!$this->verified || $this->verified && !WBB_TAPATALK_REG_AUTO_APPROVAL)) {
                 $this->message = 'wcf.user.register.awaitActivation';
             }
         }
     }
     // notify admin
     if (REGISTER_ADMIN_NOTIFICATION) {
         // get default language
         $language = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
         // send mail
         $mail = new Mail(MAIL_ADMIN_ADDRESS, $language->getDynamicVariable('wcf.user.register.notification.mail.subject'), $language->getDynamicVariable('wcf.user.register.notification.mail', array('user' => $user)));
         $mail->setLanguage($language);
         $mail->send();
     }
     if ($this->captchaObjectType) {
         $this->captchaObjectType->getProcessor()->reset();
     }
     if (WCF::getSession()->getVar('noRegistrationCaptcha')) {
         WCF::getSession()->unregister('noRegistrationCaptcha');
     }
     // login user
     UserAuthenticationFactory::getInstance()->getUserAuthentication()->storeAccessData($user, $this->username, $this->password);
     WCF::getSession()->unregister('registrationStartTime');
     $this->saved();
 }
Beispiel #7
0
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     AbstractForm::save();
     // get options
     $saveOptions = $this->optionHandler->save();
     $registerVia3rdParty = false;
     $avatarURL = '';
     if ($this->isExternalAuthentication) {
         switch (WCF::getSession()->getVar('__3rdPartyProvider')) {
             case 'github':
                 // GitHub
                 if (WCF::getSession()->getVar('__githubData')) {
                     $githubData = WCF::getSession()->getVar('__githubData');
                     $this->additionalFields['authData'] = 'github:' . WCF::getSession()->getVar('__githubToken');
                     WCF::getSession()->unregister('__githubData');
                     WCF::getSession()->unregister('__githubToken');
                     if (WCF::getSession()->getVar('__email') && WCF::getSession()->getVar('__email') == $this->email) {
                         $registerVia3rdParty = true;
                     }
                     if (isset($githubData['bio']) && User::getUserOptionID('aboutMe') !== null) {
                         $saveOptions[User::getUserOptionID('aboutMe')] = $githubData['bio'];
                     }
                     if (isset($githubData['location']) && User::getUserOptionID('location') !== null) {
                         $saveOptions[User::getUserOptionID('location')] = $githubData['location'];
                     }
                 }
                 break;
             case 'twitter':
                 // Twitter
                 if (WCF::getSession()->getVar('__twitterData')) {
                     $twitterData = WCF::getSession()->getVar('__twitterData');
                     $this->additionalFields['authData'] = 'twitter:' . $twitterData['user_id'];
                     WCF::getSession()->unregister('__twitterData');
                     if (isset($twitterData['description']) && User::getUserOptionID('aboutMe') !== null) {
                         $saveOptions[User::getUserOptionID('aboutMe')] = $twitterData['description'];
                     }
                     if (isset($twitterData['location']) && User::getUserOptionID('location') !== null) {
                         $saveOptions[User::getUserOptionID('location')] = $twitterData['location'];
                     }
                 }
                 break;
             case 'facebook':
                 // Facebook
                 if (WCF::getSession()->getVar('__facebookData')) {
                     $facebookData = WCF::getSession()->getVar('__facebookData');
                     $this->additionalFields['authData'] = 'facebook:' . $facebookData['id'];
                     WCF::getSession()->unregister('__facebookData');
                     if (isset($facebookData['email']) && $facebookData['email'] == $this->email) {
                         $registerVia3rdParty = true;
                     }
                     if (isset($facebookData['gender']) && User::getUserOptionID('gender') !== null) {
                         $saveOptions[User::getUserOptionID('gender')] = $facebookData['gender'] == 'male' ? UserProfile::GENDER_MALE : UserProfile::GENDER_FEMALE;
                     }
                     if (isset($facebookData['birthday']) && User::getUserOptionID('birthday') !== null) {
                         list($month, $day, $year) = explode('/', $facebookData['birthday']);
                         $saveOptions[User::getUserOptionID('birthday')] = $year . '-' . $month . '-' . $day;
                     }
                     if (isset($facebookData['bio']) && User::getUserOptionID('bio') !== null) {
                         $saveOptions[User::getUserOptionID('aboutMe')] = $facebookData['bio'];
                     }
                     if (isset($facebookData['location']) && User::getUserOptionID('location') !== null) {
                         $saveOptions[User::getUserOptionID('location')] = $facebookData['location']['name'];
                     }
                     if (isset($facebookData['website']) && User::getUserOptionID('website') !== null) {
                         $urls = preg_split('/[\\s,;]/', $facebookData['website'], -1, PREG_SPLIT_NO_EMPTY);
                         if (!empty($urls)) {
                             if (!Regex::compile('^https?://')->match($urls[0])) {
                                 $urls[0] = 'http://' . $urls[0];
                             }
                             $saveOptions[User::getUserOptionID('homepage')] = $urls[0];
                         }
                     }
                     // avatar
                     if (isset($facebookData['picture']) && !$facebookData['picture']['data']['is_silhouette']) {
                         $avatarURL = $facebookData['picture']['data']['url'];
                     }
                 }
                 break;
             case 'google':
                 // Google Plus
                 if (WCF::getSession()->getVar('__googleData')) {
                     $googleData = WCF::getSession()->getVar('__googleData');
                     $this->additionalFields['authData'] = 'google:' . $googleData['id'];
                     WCF::getSession()->unregister('__googleData');
                     if (isset($googleData['emails'][0]['value']) && $googleData['emails'][0]['value'] == $this->email) {
                         $registerVia3rdParty = true;
                     }
                     if (isset($googleData['gender']) && User::getUserOptionID('gender') !== null) {
                         switch ($googleData['gender']) {
                             case 'male':
                                 $saveOptions[User::getUserOptionID('gender')] = UserProfile::GENDER_MALE;
                                 break;
                             case 'female':
                                 $saveOptions[User::getUserOptionID('gender')] = UserProfile::GENDER_FEMALE;
                                 break;
                         }
                     }
                     if (isset($googleData['birthday']) && User::getUserOptionID('birthday') !== null) {
                         $saveOptions[User::getUserOptionID('birthday')] = $googleData['birthday'];
                     }
                     if (isset($googleData['placesLived']) && User::getUserOptionID('location') !== null) {
                         // save primary location
                         $saveOptions[User::getUserOptionID('location')] = current(array_map(function ($element) {
                             return $element['value'];
                         }, array_filter($googleData['placesLived'], function ($element) {
                             return isset($element['primary']) && $element['primary'];
                         })));
                     }
                     // avatar
                     if (isset($googleData['image']['url'])) {
                         $avatarURL = $googleData['image']['url'];
                     }
                 }
                 break;
         }
         // create fake password
         $this->password = StringUtil::getRandomID();
     }
     $this->additionalFields['languageID'] = $this->languageID;
     if (LOG_IP_ADDRESS) {
         $this->additionalFields['registrationIpAddress'] = WCF::getSession()->ipAddress;
     }
     // generate activation code
     $addDefaultGroups = true;
     if (REGISTER_ACTIVATION_METHOD == 1 && !$registerVia3rdParty || REGISTER_ACTIVATION_METHOD == 2) {
         $activationCode = UserRegistrationUtil::getActivationCode();
         $this->additionalFields['activationCode'] = $activationCode;
         $addDefaultGroups = false;
         $this->groupIDs = UserGroup::getGroupIDsByType(array(UserGroup::EVERYONE, UserGroup::GUESTS));
     }
     // check gravatar support
     if (MODULE_GRAVATAR && Gravatar::test($this->email)) {
         $this->additionalFields['enableGravatar'] = 1;
     }
     // create user
     $data = array('data' => array_merge($this->additionalFields, array('username' => $this->username, 'email' => $this->email, 'password' => $this->password)), 'groups' => $this->groupIDs, 'languageIDs' => $this->visibleLanguages, 'options' => $saveOptions, 'addDefaultGroups' => $addDefaultGroups);
     $this->objectAction = new UserAction(array(), 'create', $data);
     $result = $this->objectAction->executeAction();
     $user = $result['returnValues'];
     $userEditor = new UserEditor($user);
     // update session
     WCF::getSession()->changeUser($user);
     // set avatar if provided
     if (!empty($avatarURL)) {
         $userAvatarAction = new UserAvatarAction(array(), 'fetchRemoteAvatar', array('url' => $avatarURL, 'userEditor' => $userEditor));
         $userAvatarAction->executeAction();
     }
     // activation management
     if (REGISTER_ACTIVATION_METHOD == 0) {
         $this->message = 'wcf.user.register.success';
     } else {
         if (REGISTER_ACTIVATION_METHOD == 1) {
             // registering via 3rdParty leads to instant activation
             if ($registerVia3rdParty) {
                 $this->message = 'wcf.user.register.success';
             } else {
                 $mail = new Mail(array($this->username => $this->email), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail', array('user' => $user)));
                 $mail->send();
                 $this->message = 'wcf.user.register.needActivation';
             }
         } else {
             if (REGISTER_ACTIVATION_METHOD == 2) {
                 $this->message = 'wcf.user.register.awaitActivation';
             }
         }
     }
     // notify admin
     if (REGISTER_ADMIN_NOTIFICATION) {
         // get default language
         $language = LanguageFactory::getInstance()->getLanguage(LanguageFactory::getInstance()->getDefaultLanguageID());
         // send mail
         $mail = new Mail(MAIL_ADMIN_ADDRESS, $language->getDynamicVariable('wcf.user.register.notification.mail.subject'), $language->getDynamicVariable('wcf.user.register.notification.mail', array('user' => $user)));
         $mail->setLanguage($language);
         $mail->send();
     }
     if ($this->captchaObjectType) {
         $this->captchaObjectType->getProcessor()->reset();
     }
     if (WCF::getSession()->getVar('noRegistrationCaptcha')) {
         WCF::getSession()->unregister('noRegistrationCaptcha');
     }
     // login user
     UserAuthenticationFactory::getInstance()->getUserAuthentication()->storeAccessData($user, $this->username, $this->password);
     WCF::getSession()->unregister('registrationRandomFieldNames');
     WCF::getSession()->unregister('registrationStartTime');
     $this->saved();
     // forward to index page
     HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->getDynamicVariable($this->message, array('user' => $user)), 15);
     exit;
 }
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     parent::save();
     // generate activation code
     $activationCode = UserRegistrationUtil::getActivationCode();
     // save user
     $parameters = array('activationCode' => $activationCode);
     if (!empty($this->email)) {
         $parameters['email'] = $this->email;
     }
     $this->objectAction = new UserAction(array($this->user), 'update', array('data' => array_merge($this->additionalFields, $parameters)));
     $this->objectAction->executeAction();
     // reload user to reflect changes
     $this->user = new User($this->user->userID);
     // send activation mail
     $mail = new Mail(array($this->user->username => !empty($this->email) ? $this->email : $this->user->email), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.register.needActivation.mail', array('user' => $this->user)));
     $mail->send();
     $this->saved();
     // forward to index page
     HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.user.newActivationCode.success', array('email' => !empty($this->email) ? $this->email : $this->user->email)), 10);
     exit;
 }
 /**
  * Exports users.
  */
 public function exportUsers($offset, $limit)
 {
     // prepare password update
     $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tpassword = ?\n\t\t\tWHERE\tuserID = ?";
     $passwordUpdateStatement = WCF::getDB()->prepareStatement($sql);
     // get users
     $sql = "SELECT\t\tuser_table.*, textfield.*, useractivation.type AS activationType, useractivation.emailchange, userban.liftdate, userban.reason AS banReason\n\t\t\tFROM\t\t" . $this->databasePrefix . "user user_table\n\t\t\tLEFT JOIN\t" . $this->databasePrefix . "usertextfield textfield\n\t\t\tON\t\tuser_table.userid = textfield.userid\n\t\t\tLEFT JOIN\t" . $this->databasePrefix . "useractivation useractivation\n\t\t\tON\t\tuser_table.userid = useractivation.userid\n\t\t\tLEFT JOIN\t" . $this->databasePrefix . "userban userban\n\t\t\tON\t\tuser_table.userid = userban.userid\n\t\t\tWHERE\t\tuser_table.userid BETWEEN ? AND ?\n\t\t\tORDER BY\tuser_table.userid";
     $statement = $this->database->prepareStatement($sql);
     $statement->execute(array($offset + 1, $offset + $limit));
     while ($row = $statement->fetchArray()) {
         $data = array('username' => $row['username'], 'password' => '', 'email' => $row['email'], 'registrationDate' => $row['joindate'], 'banned' => $row['liftdate'] !== null && $row['liftdate'] == 0 ? 1 : 0, 'banReason' => $row['banReason'], 'activationCode' => $row['activationType'] !== null && $row['activationType'] == 0 && $row['emailchange'] == 0 ? UserRegistrationUtil::getActivationCode() : 0, 'oldUsername' => '', 'registrationIpAddress' => UserUtil::convertIPv4To6($row['ipaddress']), 'signature' => $row['signature'], 'userTitle' => $row['customtitle'] != 0 ? $row['usertitle'] : '', 'lastActivityTime' => $row['lastactivity']);
         $additionalData = array('groupIDs' => explode(',', $row['membergroupids'] . ',' . $row['usergroupid']), 'options' => array());
         // import user
         $newUserID = ImportHandler::getInstance()->getImporter('com.woltlab.wcf.user')->import($row['userid'], $data, $additionalData);
         // update password hash
         if ($newUserID) {
             if (StringUtil::startsWith($row['scheme'], 'blowfish')) {
                 $password = PasswordUtil::getSaltedHash($row['token'], $row['token']);
             } else {
                 if ($row['scheme'] == 'legacy') {
                     $password = '******' . implode(':', explode(' ', $row['token'], 2));
                 }
             }
             $passwordUpdateStatement->execute(array($password, $newUserID));
         }
     }
 }
 /**
  * Exports users.
  */
 public function exportUsers($offset, $limit)
 {
     // cache profile fields
     $profileFields = array();
     $sql = "SELECT\tcol_name, id_field\n\t\t\tFROM\t" . $this->databasePrefix . "custom_fields";
     $statement = $this->database->prepareStatement($sql);
     $statement->execute();
     while ($row = $statement->fetchArray()) {
         $profileFields[$row['col_name']] = $row;
     }
     // prepare password update
     $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tpassword = ?\n\t\t\tWHERE\tuserID = ?";
     $passwordUpdateStatement = WCF::getDB()->prepareStatement($sql);
     // get userIDs
     $userIDs = array();
     $sql = "SELECT\t\tid_member\n\t\t\tFROM\t\t" . $this->databasePrefix . "members\n\t\t\tWHERE\t\tid_member BETWEEN ? AND ?\n\t\t\tORDER BY\tid_member";
     $statement = $this->database->prepareStatement($sql);
     $statement->execute(array($offset + 1, $offset + $limit));
     while ($row = $statement->fetchArray()) {
         $userIDs[] = $row['id_member'];
     }
     // wtf?!
     if (empty($userIDs)) {
         return;
     }
     // get profile field values
     $profileFieldValues = array();
     if (!empty($profileFields)) {
         $condition = new PreparedStatementConditionBuilder();
         $condition->add('id_member IN(?)', array($userIDs));
         $condition->add('variable IN(?)', array(array_keys($profileFields)));
         $sql = "SELECT\t*\n\t\t\t\tFROM\t" . $this->databasePrefix . "themes\n\t\t\t\t" . $condition;
         $statement = $this->database->prepareStatement($sql);
         $statement->execute($condition->getParameters());
         while ($row = $statement->fetchArray()) {
             if (!isset($profileFieldValues[$row['id_member']])) {
                 $profileFieldValues[$row['id_member']] = array();
             }
             $profileFieldValues[$row['id_member']][$profileFields[$row['variable']]['id_field']] = $row['value'];
         }
     }
     // get users
     $condition = new PreparedStatementConditionBuilder();
     $condition->add('member.id_member IN(?)', array($userIDs));
     $sql = "SELECT\t\tmember.*, ban_group.ban_time, ban_group.expire_time AS banExpire, ban_group.reason AS banReason,\n\t\t\t\t\t(SELECT COUNT(*) FROM " . $this->databasePrefix . "moderators moderator WHERE member.id_member = moderator.id_member) AS isMod\n\t\t\tFROM\t\t" . $this->databasePrefix . "members member\n\t\t\tLEFT JOIN\t" . $this->databasePrefix . "ban_items ban_item\n\t\t\tON\t\t(member.id_member = ban_item.id_member)\n\t\t\tLEFT JOIN\t" . $this->databasePrefix . "ban_groups ban_group\n\t\t\tON\t\t(ban_item.id_ban_group = ban_group.id_ban_group)\n\t\t\t" . $condition;
     $statement = $this->database->prepareStatement($sql);
     $statement->execute($condition->getParameters());
     while ($row = $statement->fetchArray()) {
         $data = array('username' => $row['member_name'], 'password' => '', 'email' => $row['email_address'], 'registrationDate' => $row['date_registered'], 'banned' => $row['ban_time'] && $row['banExpire'] === null ? 1 : 0, 'banReason' => $row['banReason'], 'activationCode' => $row['validation_code'] ? UserRegistrationUtil::getActivationCode() : 0, 'registrationIpAddress' => $row['member_ip'], 'signature' => $row['signature'], 'signatureEnableBBCodes' => 1, 'signatureEnableHtml' => 0, 'signatureEnableSmilies' => 1, 'userTitle' => StringUtil::decodeHTML($row['usertitle']), 'lastActivityTime' => $row['last_login']);
         // get user options
         $options = array('location' => $row['location'], 'birthday' => $row['birthdate'], 'icq' => $row['icq'], 'homepage' => $row['website_url'], 'aboutMe' => $row['personal_text']);
         $additionalData = array('groupIDs' => explode(',', $row['additional_groups'] . ',' . $row['id_group']), 'options' => $options);
         if ($row['isMod']) {
             $additionalData['groupIDs'][] = self::GROUP_MODERATORS;
         }
         // handle user options
         if (isset($profileFieldValues[$row['id_member']])) {
             foreach ($profileFieldValues[$row['id_member']] as $key => $val) {
                 if (!$val) {
                     continue;
                 }
                 $additionalData['options'][$key] = $val;
             }
         }
         // import user
         $newUserID = ImportHandler::getInstance()->getImporter('com.woltlab.wcf.user')->import($row['id_member'], $data, $additionalData);
         // update password hash
         if ($newUserID) {
             $passwordUpdateStatement->execute(array('smf2:' . $row['passwd'] . ':' . $row['password_salt'], $newUserID));
         }
     }
 }