本文整理汇总了PHP中CommonFunctions::generateRandomString方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonFunctions::generateRandomString方法的具体用法?PHP CommonFunctions::generateRandomString怎么用?PHP CommonFunctions::generateRandomString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonFunctions
的用法示例。
在下文中一共展示了CommonFunctions::generateRandomString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initiatePasswordReset
/**
* @author Anthony Boutinov
*
* @param string $login_or_email Логин или email
* @retval array|false Ассоциативный массив с ключами EMAIL, LOGIN, PASSWORD_RESET_TOKEN. Если пользователь с таким логином или email не найден, возвращается false
*/
public function initiatePasswordReset($login_or_email)
{
$is_email = filter_var($login_or_email, FILTER_VALIDATE_EMAIL);
$this->sanitize($login_or_email);
$password_restore_token = CommonFunctions::generateRandomString(64);
$this->sanitize($password_restore_token);
$sql = 'update CM$DB_USER set PASSWORD_RESET_TOKEN=\'' . password_hash($password_restore_token, PASSWORD_BCRYPT) . '\' where ';
if ($is_email) {
$sql = $sql . 'ID_DB_USER=(
select ID_DB_USER
from SP$VAR
where
VALUE=\'' . $login_or_email . '\'
and ID_DICTIONARY=(
select ID_DICTIONARY
from CM$DICTIONARY
where SHORT_NAME=\'EMAIL\'
)
)';
} else {
$sql = $sql . 'login=\'' . $login_or_email . '\'';
}
$this->getQueryResultWithErrorNoticing($sql);
$login = $login_or_email;
$email = $login_or_email;
if ($is_email) {
$email = $login_or_email;
$sql = 'select LOGIN
from CM$DB_USER
where ID_DB_USER=(
select ID_DB_USER
from SP$VAR
where
VALUE=\'' . $login_or_email . '\'
and ID_DICTIONARY=(
select ID_DICTIONARY
from CM$DICTIONARY
where SHORT_NAME=\'EMAIL\'
)
)';
$result = $this->getQueryFirstRowResultWithErrorNoticing($sql, null, true);
if (!$result) {
return false;
} else {
$login = $result['LOGIN'];
}
} else {
$sql = 'select VALUE as EMAIL from SP$VAR
where ID_DB_USER=(
select ID_DB_USER from CM$DB_USER
where LOGIN=\'' . $login_or_email . '\'
) and ID_DICTIONARY=(
select ID_DICTIONARY from CM$DICTIONARY
where SHORT_NAME=\'EMAIL\'
)';
$result = $this->getQueryFirstRowResultWithErrorNoticing($sql, null, true);
if (!$result) {
return false;
} else {
$email = $result['EMAIL'];
}
}
return ['PASSWORD_RESET_TOKEN' => $password_restore_token, 'LOGIN' => $login, 'EMAIL' => $email];
}