本文整理汇总了PHP中CUtils::genKey方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtils::genKey方法的具体用法?PHP CUtils::genKey怎么用?PHP CUtils::genKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtils
的用法示例。
在下文中一共展示了CUtils::genKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _processForgetForm
private function _processForgetForm()
{
$aMessages = array('info' => array(), 'errors' => array());
$t = $GLOBALS['rtti']->getTable('auth_users');
if (CUtils::_sessionVar('c_sec_code') != md5(CUtils::_postVar('captcha') . __CAPTCHA_HASH)) {
$aMessages['errors'][] = $this->_aErrors['incorrect_securecode'];
} else {
$sLogin = CUtils::_postVar('login');
if ($aUser = $GLOBALS['rtti']->getItem('auth_users', "email='{$sLogin}'")) {
$sNewPassword = CUtils::genKey(6);
$sUpdate = "password='{$sNewPassword}'";
if ($t->update($sUpdate . ", change_date = NOW() WHERE email='" . $sLogin . "'")) {
$this->smarty->assign('Login', $sLogin);
$this->smarty->assign('NewPassword', $sNewPassword);
$this->_sendMail('Восстановление пароля в магазине Цвета жизни', $this->smarty->fetch('service/auth/' . $this->props['lang'] . '/forget.mail.tpl'), array($sLogin));
$aMessages['info'][] = $this->_aInfo['send_password'];
}
} else {
$this->smarty->assign('login', $sLogin);
$aMessages['errors'][] = $this->_aErrors['no_user'];
}
}
return $aMessages;
}
示例2: forgot
function forgot()
{
global $MAIN_EMAIL;
if (CUtils::_postVar('submited') && (CUtils::_postVar('fuser') || CUtils::_postVar('femail'))) {
$user = array();
if (CUtils::_postVar('fuser') != '') {
$user = $GLOBALS['db']->getItem('users_users', "SELECT * FROM users_users WHERE syslogin='" . CUtils::_postVar('fuser') . "'");
if (empty($user)) {
$this->message['type'] = 'error';
$this->message['text'] = 'Не найден пользователь с указанным <b>логином</b>!';
}
}
if (CUtils::_postVar('femail') != '' && empty($user)) {
$user = $GLOBALS['db']->getItem('users_users', "SELECT * FROM users_users WHERE email='" . CUtils::_postVar('femail') . "'");
if (empty($user)) {
$this->message['type'] = 'error';
$this->message['text'] = 'Не найден пользователь с указанным <b>e-mail</b>!';
}
}
if (!empty($user)) {
$key = CUtils::genKey(32);
inc_lib('libmail.php');
$msg = new Mail();
$msg->From($MAIN_EMAIL);
$msg->Subject('Новые регистрационные данные. Сайт ' . $_SERVER['SERVER_NAME']);
$body = 'Информационное сообщение сайта ' . $_SERVER['SERVER_NAME'] . "\n";
$body .= '------------------------------------------' . "\n";
$body .= 'Вы запросили ваши регистрационные данные.' . "\n\n";
$body .= 'Ваша регистрационная информация:' . "\n";
$body .= 'ID пользователя: ' . $user['id'] . "\n";
$body .= 'Логин: ' . $user['syslogin'] . "\n\n";
$body .= 'Для смены пароля перейдите по следующей ссылке:' . "\n";
$body .= 'http://' . $_SERVER['SERVER_NAME'] . '/admin/?operation=change_password&key=' . $key . "\n\n";
$body .= 'Сообщение сгенерировано автоматически.' . "\n";
$msg->Body($body, 'UTF-8');
$msg->To($user['email']);
$msg->Send();
$GLOBALS['db']->execQuery('users_users', "UPDATE users_users SET hashkey='" . $key . "' WHERE id=" . $user['id']);
$this->message['type'] = 'ok';
$this->message['text'] = 'Новые параметры авторизации отправлены Вам на <b>e-mail</b>!';
}
}
$this->showForgotForm();
exit;
}
示例3: makeArchive
function makeArchive($fD)
{
$my_time = time();
$my_key = CUtils::genKey(8);
$objResponse = new xajaxResponse();
$objResponse->assign("archive_info", 'innerHTML', '');
$filename = 'admin/backup/' . date('YmdHi', $my_time) . '_' . $my_key . '.tar.gz';
$filename_sql = 'admin/backup/' . date('YmdHi', $my_time) . '_' . $my_key . '.sql';
$filename_sql2 = 'admin/backup/' . date('YmdHi', $my_time) . '_' . $my_key . '_after_connect.sql';
$f = fopen($GLOBALS['PRJ_DIR'] . '/' . $filename_sql2, "a");
fwrite($f, "/*!41000 SET NAMES 'cp1251' */;");
fclose($f);
set_time_limit(0);
$GLOBALS['db']->backupDB($filename_sql);
inc_lib('tools/CArchive.php');
$test = new gzip_file($filename);
$test->set_options(array('basedir' => $GLOBALS['PRJ_DIR'] . '/', 'overwrite' => 1, 'level' => 5));
$test->add_files(array("*.*"));
//$test->exclude_files(array("admin/lib/templates_c/*.php", "*.gz"));
$cfiles = 0;
$sfiles = 0;
foreach ($test->files as $key => $current) {
if (stristr($current['name'], '.tar.gz')) {
unset($test->files[$key]);
} else {
$sfiles += $current['stat'][7];
$cfiles++;
}
}
$test->create_archive();
$text = '';
$text .= 'Количество файлов: ' . $cfiles;
$text .= '<br>';
$text .= 'Размер неупакованых файлов: ' . CUtils::getSize($sfiles, 2);
$text .= '<br>';
$text .= 'Размер архива: ' . CUtils::getFileSize('/' . $filename, 2);
//$text = 'test';
@unlink($GLOBALS['PRJ_DIR'] . '/' . $filename_sql);
@unlink($GLOBALS['PRJ_DIR'] . '/' . $filename_sql2);
$objResponse->assign("archive_info", 'innerHTML', $text);
$objResponse->script("hideDiv('waiting');window.location.reload()");
return $objResponse;
}