登录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