1.首先新建一個(gè)resetuser.php文件
2.寫入以下代碼
- <?php
- define('EmpireCMSAdmin','1');
- $ecms_config=array();
- $do_loginauth='';
- require('../class/connect.php');
- require('../class/db_sql.php');
- require('../class/functions.php');
- $link=db_connect();
- $empire=new?mysqlquery();
- //-------?插件參數(shù)設(shè)置開始?-----
- //進(jìn)入重置頁面密碼
- $pagepassword='123456';
- //-------?插件參數(shù)設(shè)置結(jié)束?-----
- @header('Content-Type:?text/html;?charset=gb2312');
- //重置密碼
- function?user_ResetUser($add){
- ????global?$empire,$dbtbpre;
- ????user_CheckGotoPagePass();
- ????$userid=(int)$add['userid'];
- ????$password=RepPostVar($add['password']);
- ????if(!$userid||!$password||!$add['repassword'])
- ????{
- ????????printerror2('請(qǐng)輸入重置的新密碼','');
- ????}
- ????if($password<>$add['repassword'])
- ????{
- ????????printerror2('兩次輸入的密碼不一致','');
- ????}
- ????if(strlen($password)<6)
- ????{
- ????????printerror2('密碼不能少于6位','');
- ????}
- ????if(function_exists('DoEmpireCMSAdminPassword'))
- ????{
- ????????$salt=make_password(8);
- ????????$salt2=make_password(20);
- ????????$password=DoEmpireCMSAdminPassword($password,$salt,$salt2);
- ????????$a="password='$password',salt='$salt',salt2='$salt2'";
- ????}
- ????else
- ????{
- ????????$salt=make_password(8);
- ????????$password=md5(md5($password).$salt);
- ????????$a="password='$password',salt='$salt'";
- ????}
- ????$sql=$empire->query("update?{$dbtbpre}enewsuser?set?".$a."?where?userid='$userid'");
- ????if($add['noquestion']==1)
- ????{
- ????????$addsql=$empire->query("update?{$dbtbpre}enewsuseradd?set?equestion='0',eanswer=''?where?userid='$userid'");
- ????}
- ????echo"<script>self.location.href='resetuser.php?ecms=success';</script>";
- ????exit();
- }
- //返回用戶列表
- function?user_ReturnUserlist(){
- ????global?$empire,$dbtbpre;
- ????$users='';
- ????$sql=$empire->query("select?userid,username?from?{$dbtbpre}enewsuser");
- ????while($r=$empire->fetch($sql))
- ????{
- ????????$users.="<option?value='".$r[userid]."'>".$r[username]."</option>";
- ????}
- ????return?$users;
- }
- //登陸驗(yàn)證
- function?user_GotoPagePassword($ckpassword){
- ????global?$pagepassword;
- ????if($pagepassword<>$ckpassword)
- ????{
- ????????printerror2('頁面密碼錯(cuò)誤','');
- ????}
- ????@setcookie('ckecmspagepass',md5($ckpassword));
- ????echo"<script>self.location.href='resetuser.php?ecms=resetpage';</script>";
- ????exit();
- }
- //驗(yàn)證信息
- function?user_CheckGotoPagePass(){
- ????global?$pagepassword;
- ????if(md5($pagepassword)<>$_COOKIE['ckecmspagepass'])
- ????{
- ????????printerror2('您還未驗(yàn)證權(quán)限','resetuser.php');
- ????}
- }
- $ecms=$_POST['ecms'];
- if(empty($ecms))
- {
- ????$ecms=$_GET['ecms'];
- }
- if($ecms=='GotoPagePassword')//登陸驗(yàn)證
- {
- ????user_GotoPagePassword($_POST['ckpassword']);
- }
- elseif($ecms=='ResetUser')//重置密碼
- {
- ????user_ResetUser($_POST);
- }
- ?>
- <!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">
- <html>
- <head>
- <meta?http-equiv="Content-Type"?content="text/html;?charset=gb2312">
- <title>重置管理員密碼</title>
- <style>
- a???????{?text-decoration:?none;?color:?#002280?}
- a:hover?{?text-decoration:?underline?}
- body????{?font-size:?10pt;?}
- table???{?font-size:?10pt;?color:?#000000?}
- </style>
- <script>
- function?CheckUserInfo(obj){
- ????if(obj.userid.value=='')
- ????{
- ????????alert('請(qǐng)選擇要重置的用戶');
- ????????obj.userid.focus();
- ????????return?false;
- ????}
- ????if(obj.password.value=='')
- ????{
- ????????alert('請(qǐng)輸入重置的新密碼');
- ????????obj.password.focus();
- ????????return?false;
- ????}
- ????if(obj.password.value!=obj.repassword.value)
- ????{
- ????????alert('兩次輸入的密碼不一致');
- ????????obj.password.focus();
- ????????return?false;
- ????}
- ????if(obj.password.value.length<6)
- ????{
- ????????alert('密碼不能少于6位');
- ????????obj.password.focus();
- ????????return?false;
- ????}
- ????return?true;
- }
- </script>
- </head>
- <body>
- <br>
- <br>
- <br>
- <?php
- if($ecms=='success')
- {
- ????user_CheckGotoPagePass();
- ?>
- <table?width="600"?border="0"?align="center"?cellpadding="3"?cellspacing="1"?bgcolor="#4FB4DE">
- ??<tr>
- ????<td?height="30"><div?align="center"><strong><font?color="#FFFFFF">已完成重置</font></strong></div></td>
- ??</tr>
- ??<tr>
- ????<td?height="120"?bgcolor="#FFFFFF">
- ??????<div?align="center"><font?color="#FF0000"><strong>恭喜!密碼重置完畢,現(xiàn)在您可以用新的密碼登陸后臺(tái)了。</strong><br>
- ????????<br>
- ????????<br>
- ????????</font>(友情提示:建議馬上刪除?/e/update/resetuser.php?文件,防止被重復(fù)使用。)?</div></td>
- ??</tr>
- </table>
- <?php
- }
- elseif($ecms=='resetpage')
- {
- ????user_CheckGotoPagePass();
- ?>
- <form?name="reseteform"?method="post"?action="resetuser.php"?onsubmit="return?CheckUserInfo(document.reseteform);">
- ??<table?width="500"?border="0"?align="center"?cellpadding="3"?cellspacing="1"?bgcolor="#4FB4DE">
- ????<tr>
- ??????<td?height="30"?colspan="2"><strong><font?color="#FFFFFF">重置管理員密碼:</font></strong></td>
- ????</tr>
- ????<tr>
- ??????<td?width="146"?height="25"?bgcolor="#FFFFFF">用戶:</td>
- ??????<td?width="339"?bgcolor="#FFFFFF"><select?name="userid"?id="userid">
- ????????<?=user_ReturnUserlist()?>
- ????????</select></td>
- ????</tr>
- ????<tr>
- ??????<td?height="25"?bgcolor="#FFFFFF">新密碼:</td>
- ??????<td?bgcolor="#FFFFFF"><input?name="password"?type="password"?id="password"></td>
- ????</tr>
- ????<tr>
- ??????<td?height="25"?bgcolor="#FFFFFF">重復(fù)新密碼:</td>
- ??????<td?bgcolor="#FFFFFF"><input?name="repassword"?type="password"?id="repassword"></td>
- ????</tr>
- ????<tr>
- ??????<td?height="25"?bgcolor="#FFFFFF">安全問題設(shè)為空:</td>
- ??????<td?bgcolor="#FFFFFF"><input?name="noquestion"?type="checkbox"?id="noquestion"?value="1"?checked>
- ????????清空安全問題</td>
- ????</tr>
- ????<tr>
- ??????<td?height="25"?bgcolor="#FFFFFF">當(dāng)前認(rèn)證碼為:</td>
- ??????<td?bgcolor="#FFFFFF"><?=$do_loginauth?$do_loginauth:$ecms_config['esafe']['loginauth']?></td>
- ????</tr>
- ????<tr>
- ??????<td?height="25"?bgcolor="#FFFFFF"> </td>
- ??????<td?bgcolor="#FFFFFF"><input?type="submit"?name="Submit"?value="馬上重置登錄信息">
- ????????<input?name="ecms"?type="hidden"?id="ecms"?value="ResetUser"></td>
- ????</tr>
- ????<tr>
- ??????<td?height="25"?colspan="2"?bgcolor="#FFFFFF"><font?color="#666666">說明:密碼設(shè)置6位以上,且密碼不能包含:$
- ????????&?*?#?<?>?'?"?/?\?%?;?空格</font></td>
- ????</tr>
- ??</table>
- </form>
- <?php
- }
- else
- {
- ?>
- <form?name="loginform"?method="post"?action="resetuser.php">
- ??<table?width="500"?border="0"?align="center"?cellpadding="3"?cellspacing="1"?bgcolor="#4FB4DE">
- ????<tr>
- ??????<td?height="30"?colspan="2"><strong><font?color="#FFFFFF">進(jìn)入重置頁面密碼:</font></strong></td>
- ????</tr>
- ????<tr>
- ??????<td?width="146"?height="25"?bgcolor="#FFFFFF">輸入密碼:</td>
- ??????<td?width="339"?bgcolor="#FFFFFF"><input?name="ckpassword"?type="password"?id="password"></td>
- ????</tr>
- ????<tr>
- ??????<td?height="25"?bgcolor="#FFFFFF"> </td>
- ??????<td?bgcolor="#FFFFFF"><input?type="submit"?name="Submit2"?value="進(jìn)入重置登錄頁面">
- ????????<input?name="ecms"?type="hidden"?id="ecms"?value="GotoPagePassword"></td>
- ????</tr>
- ??</table>
- </form>
- <?php
- }
- ?>
- </body>
- </html>
- <?php
- db_close();
- $empire=null;
- ?>
然后放入到網(wǎng)站的/e/update/目錄內(nèi)
3.在瀏覽器中執(zhí)行 /e/update/resetuser.php 文件
- 修改?/e/update/resetuser.php?文件里的訪問密碼:(防止被他人使用)
- 進(jìn)入重置頁面密碼
- $pagepassword='123456';
版權(quán)聲明:文章圖片資源來源于網(wǎng)絡(luò),如有侵權(quán),請(qǐng)留言刪除!!!
評(píng)論