VtigerCRM重置管理员密码

当忘记Vtiger密码导致无法登录时,可以通过邮件重置,但若未配置邮件服务器,可以采取手动方式。创建并运行password.php文件在Vtiger网站根目录,以重置管理员密码。
摘要由CSDN通过智能技术生成

登录Vtiger密码出错,使用邮件重置密码,邮件服务器还没有配置怎么办?
Vtiger密码出错,忘记Vtiger密码,重置Vtiger管理员密码

复制一下代码,并在网站根目录创建password.php文件,粘贴代码。运行
或者下载文件

这里写图片描述
password.php

<?php
#Error Reporting
error_reporting(0);
#Login Details
$Username = ''; //admin
$Password = ''; //admin



$LoginSuccessful = false;
// Check username and password:
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
    if ($Username == $_SERVER['PHP_AUTH_USER'] && $Password == $_SERVER['PHP_AUTH_PW']) {
        $LoginSuccessful = true;
    }
}
if (empty($Username) || empty($Password)){
   $LoginSuccessful = true;
}
// Login passed successful?
if (!$LoginSuccessful) {
    header('WWW-Authenticate: Basic realm="Vtiger Admin Area"');
    header('HTTP/1.0 401 Unauthorized');
    die("Login failed!\n");
} else {


    // Turn on debugging level 
    $Vtiger_Utils_Log = true;
    include_once('vtlib/Vtiger/Menu.php');
    include_once('vtlib/Vtiger/Module.php');

    function encrypt_password($username, $user_password, $crypt_type = '')
    {
        $salt = substr($username, 0, 2);
        if ($crypt_type == '') {
            $crypt_type = 'MD5';
        }
        if ($crypt_type == 'MD5') {
            $salt = '$1$' . $salt . '$';
        } elseif ($crypt_type == 'BLOWFISH') {
            $salt = '$2$' . $salt . '$';
        } elseif ($crypt_type == 'PHP5.3MD5') {
            $salt = '$1$' . str_pad($salt, 9, '0');
        }
        $encrypted_password = crypt($user_password, $salt);
        return $encrypted_password;
    }    

    $adb = PearDatabase::getInstance();
   // var_dump($adb);
    if (isset($_POST['pwd2']) && isset($_POST['pwd1']) && isset($_POST['username']) && $_POST['pwd2'] == $_POST['pwd1'] && !empty($_POST['pwd1'])) {
        $error  = false;
        $status = "sucess";
        $sql    = 'SELECT user_name, crypt_type FROM vtiger_users WHERE status = "Active" and id = "' . $_POST['username'] . '" limit 1';
        $result = $adb->query($sql);
        if ($adb->num_rows($result) > 0) {
            while ($row = $adb->fetchByAssoc($result)) {
                $crypt_type = $row['crypt_type'];
                $user_name  = $row['user_name'];
            }
            $userid            = $_POST['username'];
            $encryptedPassword = encrypt_password($user_name, $_POST['pwd1'], $crypt_type);
            $query             = "UPDATE vtiger_users SET user_password=?, confirm_password=? where id=?";
            $adb->pquery($query, array(
                $encryptedPassword,
                $encryptedPassword,
                $userid
            ));
            if ($adb->hasFailedTransaction()) {
                if ($dieOnError) {
                    $error  = "error setting new password: [" . $adb->database->ErrorNo() . "] " . $adb->database->ErrorMsg();
                    $status = "error";
                }
            }
            if (isset($_POST['recreate']) && $_POST['recreate'] == '1') {
                require_once('modules/Users/CreateUserPrivilegeFile.php');
                createUserPrivilegesfile($userid);
                createUserSharingPrivilegesfile($userid);
                require_once($root_directory . 'user_privileges/user_privileges_' . $userid . '.php');
                require_once($root_directory . 'user_privileges/sharing_privileges_' . $userid . '.php');
            }
        } else {
            $error  = "Invalid User Selected!";
            $status = "error";
        }
        header("Location: " . $_SERVER['PHP_SELF'] . ($status == "error" ? "?status=error&msg=" . $error : "?status=success"));
        exit;
    }




    $sql       = 'SELECT id, user_name, first_name, last_name FROM vtiger_users WHERE status = "Active"';
    $result    = $adb->query($sql);
    $listusers = '<select id="selectbasic" name="username" class="form-control">';
    while ($row = $adb->fetchByAssoc($result)) {
        $listusers .= '<option value="' . $row['id'] . '">' . $row['first_name'] . ' ' . $row['last_name'] . ' - (' . $row['user_name'] . ')</option>';

    }
    $listusers .= '</select>';

echo '<!doctype html>
<html lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Change User\'s Password</title>
<link rel="stylesheet" href="libraries/bootstrap/css/bootstrap.css" type="text/css" media="all" />
<script type="text/javascript" src="libraries/jquery/jquery.min.js"></script>    
<style>
html {
    font-size: 10pt;
}
body {
    background-color: rgba(250,250,250,0.5)
}
input, select, .uneditable-input {
    margin-left: 20px;
    height: 2
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值