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


PHP SJB_UserManager::changeUserPassword方法代码示例

本文整理汇总了PHP中SJB_UserManager::changeUserPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP SJB_UserManager::changeUserPassword方法的具体用法?PHP SJB_UserManager::changeUserPassword怎么用?PHP SJB_UserManager::changeUserPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SJB_UserManager的用法示例。


在下文中一共展示了SJB_UserManager::changeUserPassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     $template_processor = SJB_System::getTemplateProcessor();
     $username = SJB_Request::getVar('username', null);
     $verification_key = SJB_Request::getVar('verification_key', null);
     $ERRORS = array();
     $password_was_changed = false;
     $user_info = SJB_UserManager::getUserInfoByUserName($username);
     if (empty($user_info)) {
         $ERRORS['EMPTY_USERNAME'] = 1;
     } elseif (empty($verification_key)) {
         $ERRORS['EMPTY_VERIFICATION_KEY'] = 1;
     } elseif ($user_info['verification_key'] != $verification_key) {
         $ERRORS['WRONG_VERIFICATION_KEY'] = 1;
     } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!empty($_REQUEST['password']) && $_REQUEST['password'] == $_REQUEST['confirm_password']) {
             $password_was_changed = SJB_UserManager::changeUserPassword($user_info['sid'], $_REQUEST['password']);
         } else {
             $ERRORS['PASSWORD_NOT_CONFIRMED'] = 1;
         }
     }
     if ($password_was_changed) {
         $template_processor->display('successful_password_change.tpl');
     } else {
         $template_processor->assign('username', $username);
         $template_processor->assign('verification_key', $verification_key);
         $template_processor->assign('errors', $ERRORS);
         $template_processor->display('change_password.tpl');
     }
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:30,代码来源:change_password.php

示例2: login_sjb

function login_sjb(&$username, &$user_data)
{
    global $phpbb_root_path, $db, $user, $config, $cache, $phpEx;
    define('LOGIN_PHPBB', true);
    //set define to allow to check for recursivity
    $password = is_array($user_data) ? $user_data['password'] : $user_data;
    $status = null;
    if (!$password) {
        return array('status' => LOGIN_ERROR_PASSWORD, 'error_msg' => 'NO_PASSWORD_SUPPLIED', 'user_row' => array('user_id' => ANONYMOUS));
    }
    if (!$username) {
        return array('status' => LOGIN_ERROR_USERNAME, 'error_msg' => 'LOGIN_ERROR_USERNAME', 'user_row' => array('user_id' => ANONYMOUS));
    }
    $sql = 'DESCRIBE ' . USERS_TABLE . ' login_name';
    $result = $db->sql_query($sql);
    $has_login_name = $db->sql_fetchrow();
    $db->sql_freeresult($result);
    if (!empty($has_login_name)) {
        $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type, login_name
			FROM ' . USERS_TABLE . "\n\t\t\tWHERE login_name = '" . $db->sql_escape($username) . "'";
    } else {
        $sql = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type
			FROM ' . USERS_TABLE . "\n\t\t\tWHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
    }
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);
    if ($row) {
        // User inactive...
        if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) {
            return array('status' => LOGIN_ERROR_ACTIVE, 'error_msg' => 'ACTIVE_ERROR', 'user_row' => $row);
        }
        $status = LOGIN_SUCCESS;
    }
    $dir = getcwd();
    loadSJB();
    //get the sjb user
    $errors = array();
    $logged_in = SJB_Authorization::login($username, $password, false, $errors, false);
    // user not in phpbb3 db, but is in sjb
    $userInfo = SJB_UserDBManager::getUserInfoByUserName($username);
    chdir($dir);
    if ($row && $userInfo) {
        if (!$logged_in && phpbb_check_hash($password, $row['user_password'])) {
            if (SJB_UserManager::changeUserPassword($userInfo['sid'], $password)) {
                $errors = array();
            }
            $logged_in = SJB_Authorization::login($username, $password, false, $errors, false);
        } elseif ($logged_in && !phpbb_check_hash($password, $row['user_password'])) {
            $sql_ary = array('user_actkey' => '', 'user_password' => phpbb_hash($password), 'user_newpasswd' => '', 'user_pass_convert' => 0, 'user_login_attempts' => 0);
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
				WHERE user_id = ' . $row['user_id'];
            $db->sql_query($sql);
        }
    } elseif (!$row && $userInfo) {
        // retrieve default group id
        $sql = 'SELECT group_id
				FROM ' . GROUPS_TABLE . "\n\t\t\t\tWHERE group_name = '" . $db->sql_escape('REGISTERED') . "'\n\t\t\t\tAND group_type = " . GROUP_SPECIAL;
        $result = $db->sql_query($sql);
        $group = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!$group) {
            trigger_error('NO_GROUP');
        }
        // generate user account data
        $row = array('username' => $username, 'user_password' => phpbb_hash($password), 'user_email' => $userInfo['email'], 'group_id' => $group['group_id'], 'user_type' => (string) USER_NORMAL);
        if (!empty($has_login_name)) {
            $row['username'] = $userInfo['username'];
            $row['login_name'] = $username;
        }
        $status = LOGIN_SUCCESS_CREATE_PROFILE;
    } elseif ($row && !$userInfo && isset($errors['NO_SUCH_USER'])) {
        if (phpbb_check_hash($password, $row['user_password'])) {
            $errors = array();
        }
    }
    if (isset($errors['INVALID_PASSWORD'])) {
        return array('status' => LOGIN_ERROR_PASSWORD, 'error_msg' => 'LOGIN_ERROR_PASSWORD', 'user_row' => array('user_id' => ANONYMOUS));
    } elseif (isset($errors['USER_NOT_ACTIVE'])) {
        return array('status' => LOGIN_ERROR_ACTIVE, 'error_msg' => 'ACTIVE_ERROR', 'user_row' => $row);
    } elseif (isset($errors['BANNED_USER'])) {
        define('IN_CHECK_BAN', 1);
        return array('status' => BAN_TRIGGERED_BY_IP, 'error_msg' => 'BAN_TRIGGERED_BY_IP', 'user_row' => $row);
    } elseif ($errors) {
        return array('status' => $errors, 'error_msg' => 'ACTIVE_ERROR', 'user_row' => $row);
    }
    // Successful login... set user_login_attempts to zero...
    return array('status' => $status, 'error_msg' => false, 'user_row' => $row);
}
开发者ID:Maxlander,项目名称:shixi,代码行数:90,代码来源:auth_sjb.php


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