当前位置: 首页>>代码示例>>PHP>>正文


PHP XenForo_Application::generateRandomString方法代码示例

本文整理汇总了PHP中XenForo_Application::generateRandomString方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Application::generateRandomString方法的具体用法?PHP XenForo_Application::generateRandomString怎么用?PHP XenForo_Application::generateRandomString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XenForo_Application的用法示例。


在下文中一共展示了XenForo_Application::generateRandomString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $optionModel = XenForo_Model::create('XenForo_Model_Option');
     $optionModel->updateOption('dppa_adsense_password', XenForo_Application::generateRandomString(32));
     $optionModel->rebuildOptionCache();
     return false;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:7,代码来源:RandomGenerator.php

示例2: generateSalt

 /**
  * Generates an arbtirary length salt
  *
  * @return string
  */
 public static function generateSalt($length = null)
 {
     if (!$length) {
         $length = self::DEFAULT_SALT_LENGTH;
     }
     return XenForo_Application::generateRandomString($length);
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:12,代码来源:Abstract.php

示例3: _genKey

 protected function _genKey($userId)
 {
     $randomKey = XenForo_Application::generateRandomString(10);
     $db = XenForo_Application::getDb();
     $db->query('UPDATE xf_user
         SET gen_key = ' . $db->quote($randomKey) . '
         WHERE user_id = ' . $userId . '');
 }
开发者ID:ThemeHouse-XF,项目名称:RandomKeyGen,代码行数:8,代码来源:Misc.php

示例4: _postSave

 protected function _postSave()
 {
     parent::_postSave();
     // update sourcebans if we updated the groups
     if ($this->get('option_id') == 'AWickham_SourceBansSync_Groups') {
         if (is_array(unserialize($this->get('option_value'))) && !array_key_exists('newInstall', unserialize($this->get('option_value')))) {
             // create a group model
             $xfUserGroupModel = XenForo_Model::create('XenForo_Model_UserGroup');
             // create a user model
             $xfUserModel = XenForo_Model::create('XenForo_Model_User');
             // create an admin model
             $sbAdminModel = new AWickham_SourceBansSync_Model_SourceBans_Admin();
             // delete the users out of sourcebans that don't exist in xenforo
             $sbAdmins = $sbAdminModel->fetchAll();
             foreach ($sbAdmins as $sbAdmin) {
                 $xfUser = $xfUserModel->getUserBySteamId($sbAdmin['authid']);
                 if (!$xfUser || !$xfUserModel->getSourceBansGroups($xfUser, unserialize($this->get('option_value')))) {
                     $sbAdminModel->delete($xfUser['user_id'], $sbAdmin['authid']);
                 }
             }
             // loop through all the groups
             foreach (unserialize($this->get('option_value')) as $userGroupId => $sbGroups) {
                 //$userGroup = $userGroupModel->getUserGroupById($userGroupId);
                 $users = $xfUserGroupModel->getUserIdsInUserGroup($userGroupId);
                 foreach ($users as $user => $inGroup) {
                     $identities = $xfUserModel->getIdentities($user);
                     // pay attention to this user, they have a steam id
                     if ($identities && array_key_exists('Steam', $identities)) {
                         // check to see if the user exists in source bans
                         $sbUser = $sbAdminModel->fetchBySteamId($identities['Steam']);
                         // get the user
                         $xfUser = $xfUserModel->getFullUserById($user);
                         // figure out the groups
                         list($gid, $srvGroupsId, $serverGroupId) = $xfUserModel->getSourceBansGroups($xfUser, unserialize($this->get('option_value')));
                         // add the user to source bans
                         if (!$sbUser) {
                             if ($gid && $srvGroupsId && $serverGroupId) {
                                 // add the user
                                 $insertValues = array('user' => $xfUser['username'], 'email' => $xfUser['email'], 'authid' => $identities['Steam'], 'password' => XenForo_Application::generateRandomString(8), 'gid' => $gid, 'srvgroups_id' => $srvGroupsId, 'server_group_id' => $serverGroupId, 'validate' => '', 'extraflags' => 0);
                                 $sbAdminModel->insert($xfUser['user_id'], $insertValues);
                             }
                         } else {
                             if (!$gid || !$srvGroupsId || !$serverGroupId) {
                                 // remove the user from source bans
                                 $sbAdminModel->delete($xfUser, $identities['Steam']);
                             } else {
                                 $updateArray = array('user' => $xfUser['username'], 'email' => $xfUser['email'], 'gid' => $gid, 'srvgroups_id' => $srvGroupsId, 'server_group_id' => $serverGroupId);
                                 $sbAdminModel->update($identities['Steam'], $updateArray);
                             }
                         }
                     }
                 }
             }
         }
         // rehash the sourcebans servers
         AWickham_SourceBansSync_Model_SourceBans_Rcon::rehash();
     }
 }
开发者ID:Zipcore,项目名称:sourcebans-xenforo-sync,代码行数:58,代码来源:Option.php

示例5: createSecret

 /**
  * Create new secret.
  * 16 characters, randomly chosen from the allowed base32 characters.
  *
  * @param int $secretLength
  * @return string
  */
 public function createSecret($secretLength = 16)
 {
     $validChars = $this->_getBase32LookupTable();
     unset($validChars[32]);
     $random = XenForo_Application::generateRandomString($secretLength);
     $secret = '';
     for ($i = 0; $i < $secretLength; $i++) {
         $secret .= $validChars[ord($random[$i]) & 0x1f];
     }
     return $secret;
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:18,代码来源:GoogleAuthenticator.php

示例6: triggerVerification

 public function triggerVerification($context, array $user, $ip, array &$providerData)
 {
     $length = 6;
     $random = XenForo_Application::generateRandomString(4, true);
     $code = ((ord($random[0]) & 0x7f) << 24 | (ord($random[1]) & 0xff) << 16 | (ord($random[2]) & 0xff) << 8 | ord($random[3]) & 0xff) % pow(10, $length);
     $code = str_pad($code, $length, '0', STR_PAD_LEFT);
     $providerData['code'] = $code;
     $providerData['codeGenerated'] = time();
     $mail = XenForo_Mail::create('two_step_login_email', array('code' => $code, 'user' => $user, 'ip' => $ip), $user['language_id']);
     $mail->send($user['email'], $user['username']);
     return array();
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:12,代码来源:Email.php

示例7: generateInitialData

 public function generateInitialData(array $user, array $setupData)
 {
     $codes = array();
     $total = 10;
     $length = 9;
     $random = XenForo_Application::generateRandomString(4 * $total, true);
     for ($i = 0; $i < $total; $i++) {
         $offset = $i * 4;
         // 4 bytes for each set
         $code = ((ord($random[$offset + 0]) & 0x7f) << 24 | (ord($random[$offset + 1]) & 0xff) << 16 | (ord($random[$offset + 2]) & 0xff) << 8 | ord($random[$offset + 3]) & 0xff) % pow(10, $length);
         $code = str_pad($code, $length, '0', STR_PAD_LEFT);
         $codes[] = $code;
     }
     return array('codes' => $codes, 'used' => array());
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:15,代码来源:Backup.php

示例8: resetParentPassword

 /**
  * Resets the specified user's parental control password and emails the password to the parent if requested.
  *
  * @param integer $userId
  * @param boolean $sendEmail
  *
  * @return string New password
  */
 public function resetParentPassword($userId, $sendEmail = true)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
     $dw->setExistingData($userId);
     $password = XenForo_Application::generateRandomString(8);
     $auth = XenForo_Authentication_Abstract::createDefault();
     $dw->set('parent_scheme_class', $auth->getClassName());
     $dw->set('parent_data', $auth->generate($password));
     $dw->save();
     $user = $dw->getMergedData();
     if ($sendEmail) {
         $params = array('user' => $user, 'password' => $password, 'boardTitle' => XenForo_Application::get('options')->boardTitle, 'boardUrl' => XenForo_Application::get('options')->boardUrl);
         $mail = XenForo_Mail::create('th_lost_password_reset_parentalcontrol', $params, $user['language_id']);
         $mail->send($user['parent_email'], (string) new XenForo_Phrase('th_parent_of_x_parentalcontrol', array('username' => $user['username'])));
     }
     return $password;
 }
开发者ID:ThemeHouse-XF,项目名称:ParentalContro,代码行数:25,代码来源:UserConfirmation.php

示例9: _postSave

 protected function _postSave()
 {
     parent::_postSave();
     // get the source bans admin model
     $sbAdminModel = new AWickham_SourceBansSync_Model_SourceBans_Admin();
     $xfUserModel = XenForo_Model::create('XenForo_Model_User');
     $xfUserExternalModel = XenForo_Model::create('XenForo_Model_UserExternal');
     // get the user's new identities
     $identities = unserialize($this->get('identities'));
     // only do this if the steam id is set
     if ($identities && array_key_exists('steam', $identities)) {
         // check to see if the user exists in source bans
         $sbUser = $sbAdminModel->fetchBySteamId($xfUserModel->toSteamId($this->_currentSteamId));
         // add the user to source bans
         if (!$sbUser) {
             // figure out the groups
             list($gid, $srvgroups_id, $serverGroupId) = $xfUserModel->getSourceBansGroups($this, XenForo_Application::get('options')->AWickham_SourceBansSync_Groups);
             if ($gid && $srvgroups_id && $serverGroupId) {
                 // add the user
                 $insertValues = array('user' => $this->get('username'), 'email' => $this->get('email'), 'authid' => $xfUserModel->toSteamId($identities['steam']['provider_key']), 'password' => XenForo_Application::generateRandomString(8), 'gid' => $gid, 'srvgroups_id' => $srvgroups_id, 'server_group_id' => $serverGroupId, 'validate' => '', 'extraflags' => 0);
                 $sbAdminModel->insert($this->get('user_id'), $insertValues);
                 // rehash the sourcebans servers
                 AWickham_SourceBansSync_Model_SourceBans_Rcon::rehash();
             }
         } else {
             // update the user if anything we care about changed
             if ($this->isChanged('user_group_id') || $this->isChanged('secondary_group_ids') || $this->isChanged('email') || $this->isChanged('username') || array_key_exists('steam', $this->_identities) && $this->_identities['steam'] != $identities['steam']) {
                 // figure out the groups
                 list($gid, $srvgroups_id, $serverGroupId) = $xfUserModel->getSourceBansGroups($this, XenForo_Application::get('options')->AWickham_SourceBansSync_Groups);
                 if (!$gid || !$srvgroups_id || !$serverGroupId) {
                     // remove the user from source bans
                     $sbAdminModel->delete($this->get('user_id'), $xfUserModel->toSteamId($this->_currentSteamId));
                 } else {
                     $updateArray = array('user' => $this->get('username'), 'email' => $this->get('email'), 'authid' => $xfUserModel->toSteamId($identities['steam']['provider_key']), 'gid' => $gid, 'srvgroups_id' => $srvgroups_id, 'server_group_id' => $serverGroupId);
                     $sbAdminModel->update($xfUserModel->toSteamId($this->_currentSteamId), $updateArray);
                 }
                 // rehash the sourcebans servers
                 AWickham_SourceBansSync_Model_SourceBans_Rcon::rehash();
             }
         }
     }
 }
开发者ID:jljr222,项目名称:sourcebans-xenforo-sync,代码行数:42,代码来源:User.php

示例10: _preSaveDefaults

 /**
  * Pre-save default setting.
  */
 protected function _preSaveDefaults()
 {
     if (is_array($this->_secondaryGroups)) {
         $primaryGroupKey = array_search($this->get('user_group_id'), $this->_secondaryGroups);
         if ($primaryGroupKey !== false) {
             unset($this->_secondaryGroups[$primaryGroupKey]);
         }
         $this->set('secondary_group_ids', implode(',', $this->_secondaryGroups));
     }
     if ($this->isChanged('scheme_class', 'xf_user_authenticate') || $this->isChanged('data', 'xf_user_authenticate')) {
         $this->set('remember_key', XenForo_Application::generateRandomString(40));
         $this->set('password_date', XenForo_Application::$time);
     }
     if (!$this->get('csrf_token')) {
         $this->set('csrf_token', XenForo_Application::generateRandomString(40));
     }
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:20,代码来源:User.php

示例11: resetPassword

 /**
  * Resets the specified user's password and emails the password to them if requested.
  *
  * @param integer $userId
  * @param boolean $sendEmail
  *
  * @return string New password
  */
 public function resetPassword($userId, $sendEmail = true)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
     $dw->setExistingData($userId);
     $password = XenForo_Application::generateRandomString(8);
     $password = strtr($password, array('I' => 'i', 'l' => 'L', '0' => 'O', 'o' => 'O'));
     $password = trim($password, '_-');
     $auth = XenForo_Authentication_Abstract::createDefault();
     $dw->set('scheme_class', $auth->getClassName());
     $dw->set('data', $auth->generate($password));
     $dw->save();
     $user = $dw->getMergedData();
     if ($sendEmail) {
         $params = array('user' => $user, 'password' => $password, 'boardTitle' => XenForo_Application::get('options')->boardTitle, 'boardUrl' => XenForo_Application::get('options')->boardUrl);
         $mail = XenForo_Mail::create('user_lost_password_reset', $params, $user['language_id']);
         $mail->send($user['email'], $user['username']);
     }
     return $password;
 }
开发者ID:darkearl,项目名称:projectT122015,代码行数:27,代码来源:UserConfirmation.php

示例12: generateSessionCsrf

 /**
  * Generates a session-specific CSRF token.
  *
  * @return string
  */
 public function generateSessionCsrf()
 {
     $csrf = XenForo_Application::generateRandomString(16);
     $this->set('sessionCsrf', $csrf);
     return $csrf;
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:11,代码来源:Session.php

示例13: pullContact

 /**
  *
  * @param array $contact
  * @param array $user
  * @return array|boolean|null $user
  */
 public function pullContact(array $contact, $user = null)
 {
     $xenOptions = XenForo_Application::get('options');
     /* @var $userModel XenForo_Model_User */
     $userModel = $this->getModelFromCache('XenForo_Model_User');
     if ($user === null) {
         $user = $userModel->getUserByContactId($contact['Id']);
     }
     if (!$user && !empty($contact['Email'])) {
         $user = $userModel->getUserByEmail($contact['Email'], array('join' => XenForo_Model_User::FETCH_USER_PROFILE));
         if ($user && !empty($user['infusionsoft_contact_id_th'])) {
             return;
         }
     }
     $lastUpdated = ThemeHouse_Infusionsoft_Helper_InfusionsoftApi::getDateAsTimestamp($contact['LastUpdated']);
     if ($user && !empty($user['infusionsoft_last_updated_th']) && $user['infusionsoft_last_updated_th'] == $lastUpdated) {
         return $user;
     }
     if (!$user) {
         if (empty($contact['Groups'])) {
             return false;
         } else {
             $groups = explode(',', $contact['Groups']);
             if (!array_intersect($groups, $xenOptions->th_infusionsoftApi_importUserTags)) {
                 return false;
             }
         }
     }
     /* @var $writer XenForo_DataWriter_User */
     $writer = XenForo_DataWriter::create('XenForo_DataWriter_User');
     $writer->setOption(XenForo_DataWriter_User::OPTION_ADMIN_EDIT, true);
     if ($user) {
         $writer->setExistingData($user);
     }
     $writer->set('infusionsoft_contact_id_th', $contact['Id']);
     $writer->set('infusionsoft_last_updated_th', $lastUpdated);
     if (!$user) {
         if ($xenOptions->registrationDefaults) {
             $writer->bulkSet($xenOptions->registrationDefaults, array('ignoreInvalidFields' => true));
         }
         $name = $this->getFullNameFromContact($contact);
         $input = array('user_group_id' => XenForo_Model_User::$defaultRegisteredGroupId, 'language_id' => XenForo_Visitor::getInstance()->get('language_id'), 'user_state' => 'valid', 'username' => $name);
         $i = 1;
         while ($userModel->getUserByName($input['username'])) {
             $input['username'] = $name . ' ' . $i;
             $i++;
         }
         $writer->bulkSet($input);
         $password = XenForo_Application::generateRandomString(8);
         $password = strtr($password, array('I' => 'i', 'l' => 'L', '0' => 'O', 'o' => 'O'));
         $password = trim($password, '_-');
         $writer->setPassword($password);
     }
     if (!empty($contact['Email'])) {
         $writer->set('email', $contact['Email']);
         if ($xenOptions->gravatarEnable && XenForo_Model_Avatar::gravatarExists($contact['Email'])) {
             $writer->set('gravatar', $contact['Email']);
         }
     } else {
         $writer->setOption(ThemeHouse_Infusionsoft_Extend_XenForo_DataWriter_User::OPTION_INFUSIONSOFT_API_IMPORT, true);
         $writer->set('email', '');
     }
     if (!empty($contact['Groups'])) {
         $writer->set('infusionsoft_contact_group_ids_th', $contact['Groups']);
     } else {
         $writer->set('infusionsoft_contact_group_ids_th', '');
     }
     $writer->save();
     $user = $writer->getMergedData();
     /* @var $promotionModel XenForo_Model_UserGroupPromotion */
     $promotionModel = $this->getModelFromCache('XenForo_Model_UserGroupPromotion');
     $promotionModel->updatePromotionsForUser($user);
     return $user;
 }
开发者ID:ThemeHouse-XF,项目名称:Infusionsoft,代码行数:80,代码来源:Contact.php

示例14: createTrustedKey

 public function createTrustedKey($userId, $trustedUntil = null)
 {
     if ($trustedUntil === null) {
         $trustedUntil = XenForo_Application::$time + 86400 * 30;
     }
     $key = XenForo_Application::generateRandomString(32);
     $this->_getDb()->query("\n\t\t\tINSERT IGNORE INTO xf_user_tfa_trusted\n\t\t\t\t(user_id, trusted_key, trusted_until)\n\t\t\tVALUES\n\t\t\t\t(?, ?, ?)\n\t\t", array($userId, $key, $trustedUntil));
     return $key;
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:9,代码来源:Tfa.php

示例15: massImportUsers

 public function massImportUsers(array $users, &$errors = array())
 {
     $db = $this->_getDb();
     foreach ($users as $userId => $user) {
         $existingUser = array();
         if (!empty($user['email'])) {
             $existingUser = $this->getUserByEmail($user['email']);
         }
         /* @var $dw XenForo_DataWriter_User */
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
         $dw->setOption(XenForo_DataWriter_User::OPTION_ADMIN_EDIT, true);
         $xenOptions = XenForo_Application::get('options');
         if (isset($user['user_id']) && $xenOptions->th_userImpEx_allowUserIdSet) {
             $dw->disableUserIdVerification();
         }
         if ($existingUser) {
             $dw->setExistingData($existingUser);
         }
         if (!empty($user['custom_fields']) && is_array($user['custom_fields'])) {
             $dw->setCustomFields($user['custom_fields']);
             unset($user['custom_fields']);
         }
         if (isset($user['password'])) {
             $dw->setPassword($user['password']);
             unset($user['password']);
         } elseif ($dw->isInsert()) {
             if ($xenOptions->th_userImpEx_randomPassword) {
                 $password = XenForo_Application::generateRandomString(8);
                 $password = strtr($password, array('I' => 'i', 'l' => 'L', '0' => 'O', 'o' => 'O'));
                 $password = trim($password, '_-');
                 $dw->setPassword($password);
             }
             $auth = XenForo_Authentication_Abstract::create('XenForo_Authentication_NoPassword');
             $dw->set('scheme_class', $auth->getClassName());
             $dw->set('data', $auth->generate(''), 'xf_user_authenticate');
         }
         if (!isset($user['user_group_id']) && $dw->isInsert()) {
             $dw->set('user_group_id', XenForo_Model_User::$defaultRegisteredGroupId);
         }
         if (!isset($user['language_id']) && $dw->isInsert()) {
             $dw->set('language_id', XenForo_Visitor::getInstance()->get('language_id'));
         }
         $fieldNames = $dw->getFieldNames();
         foreach ($fieldNames as $fieldName) {
             if (isset($user[$fieldName])) {
                 $dw->set($fieldName, $user[$fieldName]);
             }
         }
         $dwErrors = $dw->getErrors();
         if ($dwErrors) {
             $users[$userId]['dwErrors'] = $dwErrors;
         } else {
             $dw->preSave();
             $dwErrors = $dw->getErrors();
             if ($dwErrors) {
                 $users[$userId]['dwErrors'] = $dwErrors;
             } else {
                 unset($users[$userId]);
                 $dw->save();
             }
         }
     }
     return $users;
 }
开发者ID:ThemeHouse-XF,项目名称:UserImpEx,代码行数:64,代码来源:User.php


注:本文中的XenForo_Application::generateRandomString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。