本文整理汇总了PHP中CB\Database\Table\UserTable::storeDatabaseValues方法的典型用法代码示例。如果您正苦于以下问题:PHP UserTable::storeDatabaseValues方法的具体用法?PHP UserTable::storeDatabaseValues怎么用?PHP UserTable::storeDatabaseValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CB\Database\Table\UserTable
的用法示例。
在下文中一共展示了UserTable::storeDatabaseValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendNewPass
function sendNewPass($option)
{
global $_CB_framework, $ueConfig, $_PLUGINS, $_POST;
$loginType = isset($ueConfig['login_type']) ? (int) $ueConfig['login_type'] : 0;
if ($loginType == 4) {
cbRedirect($_CB_framework->viewUrl('done', false), CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!'), 'error');
return;
}
// simple spoof check security
checkCBPostIsHTTPS();
cbSpoofCheck('lostPassForm');
cbRegAntiSpamCheck();
$liveSite = $_CB_framework->getCfg('live_site');
$usernameExists = $loginType != 2;
// ensure no malicous sql gets past
$checkusername = trim(cbGetParam($_POST, 'checkusername', ''));
$confirmEmail = trim(cbGetParam($_POST, 'checkemail', ''));
$_PLUGINS->loadPluginGroup('user');
$_PLUGINS->trigger('onStartNewPassword', array(&$checkusername, &$confirmEmail));
if ($_PLUGINS->is_errors()) {
cbRedirect($_CB_framework->viewUrl('lostpassword', false), $_PLUGINS->getErrorMSG(), 'error');
return;
}
$checkusername = stripslashes($checkusername);
$confirmEmail = stripslashes($confirmEmail);
$res = false;
$error = null;
if ($usernameExists && $confirmEmail != '' && !$checkusername) {
$user = new UserTable();
if (!$user->loadByEmail($confirmEmail)) {
cbRedirect($_CB_framework->viewUrl('lostpassword', false), CBTxt::Th('UE_EMAIL_DOES_NOT_EXISTS_ON_SITE', "The email '[email]' does not exist on this site.", array('[email]' => htmlspecialchars($confirmEmail))), 'error');
}
$message = str_replace('\\n', "\n", sprintf(CBTxt::T('UE_USERNAMEREMINDER_MSG', 'Hello,\\nA username reminder has been requested for your %s account.\\n\\nYour username is: %s\\n\\nTo log in to your account, click on the link below:\\n%s\\n\\nThank you.\\n'), $_CB_framework->getCfg('sitename'), $user->username, $liveSite));
/*
'Hello,\n'
.'A username reminder has been requested for your %s account.\n\n'
.'Your username is: %s\n\n'
.'To log in to your account, click on the link below:\n'
.'%s\n\n'
.'Thank you.\n'
*/
$subject = sprintf(CBTxt::T('UE_USERNAMEREMINDER_SUB', 'Username reminder for %s'), $user->username);
$_PLUGINS->trigger('onBeforeUsernameReminder', array($user, &$subject, &$message));
if ($_PLUGINS->is_errors()) {
cbRedirect($_CB_framework->viewUrl('lostpassword', false), $_PLUGINS->getErrorMSG(), 'error');
return;
}
$cbNotification = new cbNotification();
$res = $cbNotification->sendFromSystem($user->id, $subject, $message);
$error = $cbNotification->errorMSG;
$_PLUGINS->trigger('onAfterUsernameReminder', array($user, &$res));
if ($res) {
cbRedirect($_CB_framework->viewUrl('done', false), sprintf(CBTxt::Th('UE_USERNAME_REMINDER_SENT', 'Username reminder sent to your email address %s. Please check your email (and if needed your spambox too)!'), htmlspecialchars($confirmEmail)));
} else {
cbRedirect($_CB_framework->viewUrl('done', false), $error ? CBTxt::Th('SENDING_EMAIL_FAILED_ERROR_ERROR', 'Sending Email Failed! Error: [error]', array('[error]' => $error)) : CBTxt::Th('UE_EMAIL_SENDING_ERROR', 'Error sending email'), 'error');
}
} elseif ($confirmEmail != '') {
$user = new UserTable();
if ($usernameExists) {
$foundUser = $user->loadByUsername($checkusername);
if ($foundUser && cbutf8_strtolower($user->email) != cbutf8_strtolower($confirmEmail)) {
$foundUser = false;
}
} else {
$foundUser = $user->loadByEmail($confirmEmail);
}
if (!$foundUser) {
cbRedirect($_CB_framework->viewUrl('lostpassword', false), CBTxt::Th('ERROR_PASS', 'Sorry, no corresponding user was found'), 'error');
}
$resetTime = (int) $_CB_framework->getCfg('reset_time');
$resetCount = (int) $_CB_framework->getCfg('reset_count');
$hoursSinceLastReset = ($_CB_framework->getUTCNow() - (int) $_CB_framework->getUTCTimestamp($user->lastResetTime)) / 3600;
if ($hoursSinceLastReset > $resetTime) {
$user->lastResetTime = $_CB_framework->getUTCDate();
$user->resetCount = 1;
} else {
$user->resetCount = $user->resetCount + 1;
}
if ($resetCount && $user->resetCount > $resetCount) {
cbRedirect($_CB_framework->viewUrl('lostpassword', false), CBTxt::Th('EXCEEDED_MAXIMUM_PASSWORD_RESETS', 'You have exceeded the maximum number of password resets allowed. Please try again in %%COUNT%% hours.|You have exceeded the maximum number of password resets allowed. Please try again in 1 hour.', array('%%COUNT%%' => $resetTime)), 'error');
}
$newpass = $user->getRandomPassword();
$message = str_replace('\\n', "\n", sprintf(CBTxt::T('UE_NEWPASS_MSG', 'The user account %s has this email associated with it.\\nA web user from %s has just requested that a new password be sent.\\n\\nYour New Password is: %s\\n\\nIf you didn\'t ask for this, don\'t worry. You are seeing this message, not them. If this was an error just log in with your new password and then change your password to what you would like it to be.'), $user->username, $liveSite, $newpass));
/*
'The user account %s has this email associated with it.\n'
.'A web user from %s has just requested that a new password be sent.\n\n'
.'Your New Password is: %s\n\n'
.'If you didn\'t ask for this, don\'t worry. You are seeing this message, not them. If this was an error just log in with your new password and then change your password to what you would like it to be.'
*/
$subject = sprintf(CBTxt::T('UE_NEWPASS_SUB', 'New password for: %s'), $user->username);
$_PLUGINS->trigger('onBeforeNewPassword', array($user, &$newpass, &$subject, &$message));
if ($_PLUGINS->is_errors()) {
cbRedirect($_CB_framework->viewUrl('lostpassword', false), $_PLUGINS->getErrorMSG(), 'error');
}
$_PLUGINS->trigger('onNewPassword', array($user, $newpass));
$storeValues = array('password' => $newpass, 'lastResetTime' => $user->lastResetTime, 'resetCount' => $user->resetCount);
if (!$user->storeDatabaseValues($storeValues)) {
cbRedirect($_CB_framework->viewUrl('lostpassword', false), $user->getError(), 'error');
} else {
$cbNotification = new cbNotification();
//.........这里部分代码省略.........