自己写的一个修改discuz管理员密码的文件
时间:2008-11-21
来源:互联网
那天朋友跟我说他把discuz管理员密码忘记了,于是试着写了个改密码的文件。比较简单,呵呵,见笑了。
[php]
<?php
//author: 荒野无灯 http://fyt.netgeek.cn
// filename: resetpwd.php
//usage : 直接访问resetpwd.php或通过调用: resetpwd.php?uid=1&pwd=123465
// discuz管理员密码修改工具,同样可以用于修改任何会员的密码。假如discuz安装在 /bbs/下,则把此文件放在/bbs/下,总之要与discuz的config.inc.php在一个目录下。
////////////////////////////////////////////////////
define('IN_DISCUZ', TRUE);
require './config.inc.php';
require './include/db_'.$database.'.class.php';
$log=$_REQUEST['log']; //是否记录密码到文件,若选是的话,用完后别忘了删除这个文件。
$pwdfile='newpwd.txt';
////////////////////////////////////
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$db->select_db($dbname);
//////////////////////////////////////////////////////
function random($length, $numeric = 0)
{
PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
if($numeric) {
$hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
} else {
$hash = '';
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($chars) - 1;
for($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
}
return $hash;
}
////////////////////////////////////////////
$uid=$_REQUEST['uid'];
if($_REQUEST['pwd'] && $_REQUEST['uid'])
{
$salt = substr(uniqid(rand()), -6);
$password=$_REQUEST['pwd'];
$uc_members_password=md5(md5($password).$salt);
echo '<p align=center><font color=red>uc_members_password:</font><br><br>';
echo $uc_members_password;
echo '<br><br><br><br>';
$cdb_members_password = md5(random(10));
echo '<font color=red>cdb_members_password</font>:<br><br>';
echo $cdb_members_password;
echo '<br><br><br><br>';
echo '<font color=red>uc_members_salt:</font><br><br>';
echo $salt;
echo '<br><br><br><br></p>';
$str='uc_members_password:'.$uc_members_password."\r".'cdb_members_password'.$cdb_members_password."\r".'uc_members_salt:'.$salt."\r".'uid:'.$uid."\r" .'password:'.$password."\r\r\r\r";
//////////////////////////////
$cdb=$db->query("UPDATE {$tablepre}members SET `password` = '$cdb_members_password' WHERE `uid` ='$uid' LIMIT 1");
$uc=$db->query("UPDATE ".UC_DBTABLEPRE."members SET password='$uc_members_password', salt='$salt' WHERE `uid` ='$uid' LIMIT 1");
echo "<p align=center>num of affected rows in table {$tablepre}members is <br>";
echo $db->affected_rows($cdb);
echo '<br></br>';
echo "num of affected rows in table".UC_DBTABLEPRE."members is <br>";
echo $db->affected_rows($uc);
echo '<br></br>';
echo " uid为 <font color=green>{$uid}</font> 的用户的密码已经被设置为:<font color=red>{$password}</font>";
echo '<br></br></p>';
//////////////////////////
///////////////////////////
if($log=='true')
{
$fp=!file_exists('$pwdfile')?fopen('$pwdfile',w):fopen('$pwdfile',a);
if(@fwrite($fp,$str))
echo "<p align=center>Good luck!INFO has been write to <a href=$pwdfile>$pwdfile</a></p>";
else
die('write to file failed!');
@fclose($fp);
}
}
else
{
echo "<table border=0 align=center><form action={$_SERVER['PHP_SELF']} method=post>
<tr>
<td>UID:</td>
<td><input type=text name=uid size=4 maxlenth=8></td>
</tr>
<tr>
<td> password:</td>
<td><input type=text name=pwd size=50 maxlenth=16></td>
</tr>
<tr>
<td>log to {$pwdfile} ? :</td>
<td><input type=radio name=log value=true></td>
</tr>
<tr>
<td> <input type=submit name=submit value=submit></td>
<td><input type=reset name=reset value=clear> </td>
</tr>
</form></tale>";
}
?>
[/php]
[php]
<?php
//author: 荒野无灯 http://fyt.netgeek.cn
// filename: resetpwd.php
//usage : 直接访问resetpwd.php或通过调用: resetpwd.php?uid=1&pwd=123465
// discuz管理员密码修改工具,同样可以用于修改任何会员的密码。假如discuz安装在 /bbs/下,则把此文件放在/bbs/下,总之要与discuz的config.inc.php在一个目录下。
////////////////////////////////////////////////////
define('IN_DISCUZ', TRUE);
require './config.inc.php';
require './include/db_'.$database.'.class.php';
$log=$_REQUEST['log']; //是否记录密码到文件,若选是的话,用完后别忘了删除这个文件。
$pwdfile='newpwd.txt';
////////////////////////////////////
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$db->select_db($dbname);
//////////////////////////////////////////////////////
function random($length, $numeric = 0)
{
PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
if($numeric) {
$hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
} else {
$hash = '';
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($chars) - 1;
for($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
}
return $hash;
}
////////////////////////////////////////////
$uid=$_REQUEST['uid'];
if($_REQUEST['pwd'] && $_REQUEST['uid'])
{
$salt = substr(uniqid(rand()), -6);
$password=$_REQUEST['pwd'];
$uc_members_password=md5(md5($password).$salt);
echo '<p align=center><font color=red>uc_members_password:</font><br><br>';
echo $uc_members_password;
echo '<br><br><br><br>';
$cdb_members_password = md5(random(10));
echo '<font color=red>cdb_members_password</font>:<br><br>';
echo $cdb_members_password;
echo '<br><br><br><br>';
echo '<font color=red>uc_members_salt:</font><br><br>';
echo $salt;
echo '<br><br><br><br></p>';
$str='uc_members_password:'.$uc_members_password."\r".'cdb_members_password'.$cdb_members_password."\r".'uc_members_salt:'.$salt."\r".'uid:'.$uid."\r" .'password:'.$password."\r\r\r\r";
//////////////////////////////
$cdb=$db->query("UPDATE {$tablepre}members SET `password` = '$cdb_members_password' WHERE `uid` ='$uid' LIMIT 1");
$uc=$db->query("UPDATE ".UC_DBTABLEPRE."members SET password='$uc_members_password', salt='$salt' WHERE `uid` ='$uid' LIMIT 1");
echo "<p align=center>num of affected rows in table {$tablepre}members is <br>";
echo $db->affected_rows($cdb);
echo '<br></br>';
echo "num of affected rows in table".UC_DBTABLEPRE."members is <br>";
echo $db->affected_rows($uc);
echo '<br></br>';
echo " uid为 <font color=green>{$uid}</font> 的用户的密码已经被设置为:<font color=red>{$password}</font>";
echo '<br></br></p>';
//////////////////////////
///////////////////////////
if($log=='true')
{
$fp=!file_exists('$pwdfile')?fopen('$pwdfile',w):fopen('$pwdfile',a);
if(@fwrite($fp,$str))
echo "<p align=center>Good luck!INFO has been write to <a href=$pwdfile>$pwdfile</a></p>";
else
die('write to file failed!');
@fclose($fp);
}
}
else
{
echo "<table border=0 align=center><form action={$_SERVER['PHP_SELF']} method=post>
<tr>
<td>UID:</td>
<td><input type=text name=uid size=4 maxlenth=8></td>
</tr>
<tr>
<td> password:</td>
<td><input type=text name=pwd size=50 maxlenth=16></td>
</tr>
<tr>
<td>log to {$pwdfile} ? :</td>
<td><input type=radio name=log value=true></td>
</tr>
<tr>
<td> <input type=submit name=submit value=submit></td>
<td><input type=reset name=reset value=clear> </td>
</tr>
</form></tale>";
}
?>
[/php]
作者: sejie10011 发布时间: 2008-11-21
截图1
//////////////////////////////////////////////////////////////////////////////
截图2
截图3
//////////////////////////////////////////////////////////////////////////////
截图2
截图3
作者: sejie10011 发布时间: 2008-11-21
你好,我想修改discuz的注册方式,规定用户名必须为邮箱格式,请问应该修改哪些文件?
作者: lxpicq 发布时间: 2008-11-21
呵呵,这个东东比较复杂,不是改一处两处就能解决问题的。个人认为这样改工作量比较大,而且没有必要。因为你可以在后台启用email验证会员。这样也能保证用户注册用的email是正确的。
首先从注册来说就有最首先的select 出,看是否有重复的用户名,
if(!$activation) {
$username = addslashes(trim(stripslashes($username)));
if(uc_get_user($username) && !$db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$username'")) {
showmessage('register_activation_message', 'logging.php?action=login');
再就是 function check_emailformat($email) {
return strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email);
}
和
function check_emailexists($email, $username = '') {
$sqladd = $username !== '' ? "AND username<>'$username'" : '';
$email = $this->db->result_first("SELECT email FROM ".UC_DBTABLEPRE."members WHERE email='$email' $sqladd");
return $email;
}
然后 function onregister($arr) {
@extract($arr, EXTR_SKIP);//username, password, email
if(($status = $this->_check_username($username)) < 0) {
return $status;
}
if(($status = $this->_check_email($email)) < 0) {
return $status;
}
$uid = $_ENV['user']->add_user($username, $password, $email);
return $uid;
}
这里又涉及到类的成员函数_check_username() ,_check_email 和add_user()
还要改下数据库,这还是只单从注册来说,还有后台对用户的管理相应的地方也要修改,ucenter也要修改。
今天没时间了,改天我再看下。这个东东比较费时间。
首先从注册来说就有最首先的select 出,看是否有重复的用户名,
if(!$activation) {
$username = addslashes(trim(stripslashes($username)));
if(uc_get_user($username) && !$db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$username'")) {
showmessage('register_activation_message', 'logging.php?action=login');
再就是 function check_emailformat($email) {
return strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email);
}
和
function check_emailexists($email, $username = '') {
$sqladd = $username !== '' ? "AND username<>'$username'" : '';
$email = $this->db->result_first("SELECT email FROM ".UC_DBTABLEPRE."members WHERE email='$email' $sqladd");
return $email;
}
然后 function onregister($arr) {
@extract($arr, EXTR_SKIP);//username, password, email
if(($status = $this->_check_username($username)) < 0) {
return $status;
}
if(($status = $this->_check_email($email)) < 0) {
return $status;
}
$uid = $_ENV['user']->add_user($username, $password, $email);
return $uid;
}
这里又涉及到类的成员函数_check_username() ,_check_email 和add_user()
还要改下数据库,这还是只单从注册来说,还有后台对用户的管理相应的地方也要修改,ucenter也要修改。
今天没时间了,改天我再看下。这个东东比较费时间。
作者: sejie10011 发布时间: 2008-11-22
路过这里,学习一下噢!
作者: 山里的花猫 发布时间: 2008-11-22
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28