本文整理汇总了PHP中UTIL_String::generatePassword方法的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_String::generatePassword方法的具体用法?PHP UTIL_String::generatePassword怎么用?PHP UTIL_String::generatePassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTIL_String
的用法示例。
在下文中一共展示了UTIL_String::generatePassword方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public function send()
{
if (empty($_POST['emailList'])) {
exit(json_encode(array('success' => false, 'message' => OW::getLanguage()->text('contactimporter', 'email_send_error_empty_email_list'))));
}
if (count($_POST['emailList']) > (int) OW::getConfig()->getValue('base', 'user_invites_limit')) {
exit(json_encode(array('success' => false, 'message' => OW::getLanguage()->text('contactimporter', 'email_send_error_max_limit_message', array('limit' => (int) OW::getConfig()->getValue('base', 'user_invites_limit'))))));
}
$userId = OW::getUser()->getId();
$displayName = BOL_UserService::getInstance()->getDisplayName($userId);
$vars = array('inviter' => $displayName, 'siteName' => OW::getConfig()->getValue('base', 'site_name'), 'customMessage' => empty($_POST['text']) ? null : trim($_POST['text']));
foreach ($_POST['emailList'] as $email) {
$code = UTIL_String::generatePassword(20);
BOL_UserService::getInstance()->saveUserInvitation($userId, $code);
$vars['siteInviteURL'] = OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlForRoute('base_join'), array('code' => $code));
$mail = OW::getMailer()->createMail();
$mail->setSubject(OW::getLanguage()->text('contactimporter', 'mail_email_invite_subject', $vars));
$mail->setHtmlContent(OW::getLanguage()->text('contactimporter', 'mail_email_invite_' . (empty($_POST['text']) ? '' : 'msg_') . 'html', $vars));
$mail->setTextContent(OW::getLanguage()->text('contactimporter', 'mail_email_invite_' . (empty($_POST['text']) ? '' : 'msg_') . 'txt', $vars));
$mail->addRecipientEmail($email);
OW::getMailer()->addToQueue($mail);
}
exit(json_encode(array('success' => true, 'message' => OW::getLanguage()->text('contactimporter', 'email_send_success', array('count' => count($_POST['emailList']))))));
}
示例2: passwordProtection
public function passwordProtection()
{
$form = new Form('password_protection');
$form->setAjax(true);
$form->setAction(OW::getRouter()->urlFor('BASE_CTRL_BaseDocument', 'passwordProtection'));
$form->setAjaxDataType(Form::AJAX_DATA_TYPE_SCRIPT);
$password = new PasswordField('password');
$form->addElement($password);
$submit = new Submit('submit');
$submit->setValue(OW::getLanguage()->text('base', 'password_protection_submit_label'));
$form->addElement($submit);
$this->addForm($form);
if (OW::getRequest()->isAjax() && $form->isValid($_POST)) {
$data = $form->getValues();
$password = OW::getConfig()->getValue('base', 'guests_can_view_password');
if (!empty($data['password']) && trim($data['password']) === $password) {
setcookie('base_password_protection', UTIL_String::generatePassword(), time() + 86400 * 30, '/');
echo "OW.info('" . OW::getLanguage()->text('base', 'password_protection_success_message') . "');window.location.reload();";
} else {
echo "OW.error('" . OW::getLanguage()->text('base', 'password_protection_error_message') . "');";
}
exit;
}
OW::getDocument()->getMasterPage()->setTemplate(OW::getThemeManager()->getMasterPageTemplate(OW_MasterPage::TEMPLATE_BLANK));
}
示例3: addFakeQuestions
private function addFakeQuestions()
{
$step = $this->getStep();
$realQuestionList = array();
$valueList = $this->questionValuesList;
$this->questionValuesList = array();
$this->sortedQuestionsList = array();
$this->questionListBySection = array();
$section = '';
$oldQuestionList = OW::getSession()->get(self::SESSION_REAL_QUESTION_LIST);
$allQuestionList = OW::getSession()->get(self::SESSION_ALL_QUESTION_LIST);
if (!empty($oldQuestionList) && !empty($oldQuestionList)) {
$realQuestionList = $oldQuestionList;
$this->sortedQuestionsList = $allQuestionList;
foreach ($this->sortedQuestionsList as $key => $question) {
$this->questionListBySection[$question['sectionName']][] = $question;
if ($question['fake'] == true) {
$this->addDisplayNoneClass(preg_replace('/\\s+(ow_alt1|ow_alt2)/', '', $question['trClass']));
} else {
$this->addEmptyClass(preg_replace('/\\s+(ow_alt1|ow_alt2)/', '', $question['trClass']));
}
if (!empty($valueList[$question['realName']])) {
$this->questionValuesList[$question['name']] = $valueList[$question['realName']];
}
}
} else {
foreach ($this->questions as $sort => $question) {
if ((string) $question['base'] === '0' && $step === 2 || $step === 1) {
if ($section !== $question['sectionName']) {
$section = $question['sectionName'];
}
$event = new OW_Event('base.questions_field_add_fake_questions', $question, true);
OW::getEventManager()->trigger($event);
$addFakes = $event->getData();
if (!$addFakes || $this->questions[$sort]['presentation'] == 'password') {
$this->questions[$sort]['fake'] = false;
$this->questions[$sort]['realName'] = $question['name'];
$this->questions[$sort]['trClass'] = $this->toggleQuestionClass();
if ($this->questions[$sort]['presentation'] == 'password') {
$this->toggleQuestionClass();
}
$this->sortedQuestionsList[$question['name']] = $this->questions[$sort];
$this->questionListBySection[$section][] = $this->questions[$sort];
continue;
}
$fakesCount = rand(2, 5);
$fakesCount = $fakesCount + 1;
$randId = rand(0, $fakesCount);
for ($i = 0; $i <= $fakesCount; $i++) {
$randName = UTIL_String::generatePassword(rand(5, 16), 2);
$question['trClass'] = uniqid('ow_' . rand(0, 99999999999));
if ($i == $randId) {
$realQuestionList[$randName] = $this->questions[$sort]['name'];
$question['fake'] = false;
$question['required'] = $this->questions[$sort]['required'];
$this->addEmptyClass($question['trClass']);
$question['trClass'] = $question['trClass'] . " " . $this->toggleQuestionClass();
} else {
$question['required'] = 0;
$question['fake'] = true;
$this->addDisplayNoneClass($question['trClass']);
$question['trClass'] = $question['trClass'] . " " . $this->randQuestionClass();
}
$question['realName'] = $this->questions[$sort]['name'];
$question['name'] = $randName;
$this->sortedQuestionsList[$randName] = $question;
if (!empty($valueList[$this->questions[$sort]['name']])) {
$this->questionValuesList[$randName] = $valueList[$this->questions[$sort]['name']];
}
$this->questionListBySection[$section][] = $question;
}
}
}
}
if (OW::getRequest()->isPost()) {
$this->post = $_POST;
if (empty($oldQuestionList)) {
$oldQuestionList = array();
}
if (empty($allQuestionList)) {
$allQuestionList = array();
}
if ($oldQuestionList && $allQuestionList) {
foreach ($oldQuestionList as $key => $value) {
$newKey = array_search($value, $realQuestionList);
if ($newKey !== false && isset($_POST[$key]) && isset($realQuestionList[$newKey])) {
$this->post[$newKey] = $_POST[$key];
}
}
foreach ($allQuestionList as $question) {
if (!empty($question['fake']) && !empty($_POST[$question['name']])) {
$this->isBot = true;
}
}
}
}
if ($this->isBot) {
$event = new OW_Event('base.bot_detected', array('isBot' => true));
OW::getEventManager()->trigger($event);
}
//.........这里部分代码省略.........
示例4: getNewResetPassword
/**
* @param integer $affiliateId
* @return OCSAFFILIATES_BOL_ResetPassword
*/
public function getNewResetPassword($affiliateId)
{
$resetPassword = $this->findResetPasswordByAffiliateId($affiliateId);
if (!$resetPassword) {
$resetPassword = new OCSAFFILIATES_BOL_ResetPassword();
$resetPassword->affiliateId = $affiliateId;
}
$resetPassword->expirationTimeStamp = time() + 24 * 3600;
$resetPassword->code = md5(UTIL_String::generatePassword(8, 5));
$this->resetPasswordDao->save($resetPassword);
return $resetPassword;
}
示例5: getNewResetPassword
/**
* @param integer $userId
* @return BOL_UserResetPassword
*/
public function getNewResetPassword($userId)
{
$resetPassword = new BOL_UserResetPassword();
$resetPassword->setUserId($userId);
$resetPassword->setExpirationTimeStamp(time() + 24 * 3600);
$resetPassword->setCode(md5(UTIL_String::generatePassword(8, 5)));
$this->resetPasswordDao->save($resetPassword);
return $resetPassword;
}
示例6: send
public function send()
{
$request = json_decode($_POST['request'], true);
$userId = OW::getUser()->getId();
$displayName = BOL_UserService::getInstance()->getDisplayName($userId);
foreach ($request['contacts'] as $email) {
$code = UTIL_String::generatePassword(20);
BOL_UserService::getInstance()->saveUserInvitation($userId, $code);
$inviteUrl = OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlForRoute('base_join'), array('code' => $code));
$assigns = array('url' => $inviteUrl, 'message' => empty($request['message']) ? '' : $request['message'], 'user' => $displayName);
$tpl = empty($request['message']) ? 'mail_google_invite' : 'mail_google_invite_msg';
$mail = OW::getMailer()->createMail();
$mail->setSubject(OW::getLanguage()->text('contactimporter', 'mail_google_invite_subject', $assigns));
$mail->setHtmlContent(OW::getLanguage()->text('contactimporter', $tpl . '_html', $assigns));
$mail->setTextContent(OW::getLanguage()->text('contactimporter', $tpl . '_txt', $assigns));
$mail->addRecipientEmail($email);
OW::getMailer()->addToQueue($mail);
}
$message = OW::getLanguage()->text('contactimporter', 'google_send_success', array('count' => count($request['contacts'])));
exit($message);
}