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


PHP CUtils::genKey方法代码示例

本文整理汇总了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;
 }
开发者ID:rawork,项目名称:colors-life,代码行数:24,代码来源:AuthUnit.php

示例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;
 }
开发者ID:rawork,项目名称:colors-life,代码行数:45,代码来源:AdminProtect.php

示例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;
}
开发者ID:rawork,项目名称:colors-life,代码行数:43,代码来源:procajax.php


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