帝國CMS-管理員密碼重置

admin 建站教程評(píng)論9971字?jǐn)?shù) 6541閱讀模式

1.首先新建一個(gè)resetuser.php文件
2.寫入以下代碼

  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. $ecms_config=array();
  4. $do_loginauth='';
  5. require('../class/connect.php');
  6. require('../class/db_sql.php');
  7. require('../class/functions.php');
  8. $link=db_connect();
  9. $empire=new?mysqlquery();
  10. //-------?插件參數(shù)設(shè)置開始?-----
  11. //進(jìn)入重置頁面密碼
  12. $pagepassword='123456';
  13. //-------?插件參數(shù)設(shè)置結(jié)束?-----
  14. @header('Content-Type:?text/html;?charset=gb2312');
  15. //重置密碼
  16. function?user_ResetUser($add){
  17. ????global?$empire,$dbtbpre;
  18. ????user_CheckGotoPagePass();
  19. ????$userid=(int)$add['userid'];
  20. ????$password=RepPostVar($add['password']);
  21. ????if(!$userid||!$password||!$add['repassword'])
  22. ????{
  23. ????????printerror2('請(qǐng)輸入重置的新密碼','');
  24. ????}
  25. ????if($password<>$add['repassword'])
  26. ????{
  27. ????????printerror2('兩次輸入的密碼不一致','');
  28. ????}
  29. ????if(strlen($password)<6)
  30. ????{
  31. ????????printerror2('密碼不能少于6位','');
  32. ????}
  33. ????if(function_exists('DoEmpireCMSAdminPassword'))
  34. ????{
  35. ????????$salt=make_password(8);
  36. ????????$salt2=make_password(20);
  37. ????????$password=DoEmpireCMSAdminPassword($password,$salt,$salt2);
  38. ????????$a="password='$password',salt='$salt',salt2='$salt2'";
  39. ????}
  40. ????else
  41. ????{
  42. ????????$salt=make_password(8);
  43. ????????$password=md5(md5($password).$salt);
  44. ????????$a="password='$password',salt='$salt'";
  45. ????}
  46. ????$sql=$empire->query("update?{$dbtbpre}enewsuser?set?".$a."?where?userid='$userid'");
  47. ????if($add['noquestion']==1)
  48. ????{
  49. ????????$addsql=$empire->query("update?{$dbtbpre}enewsuseradd?set?equestion='0',eanswer=''?where?userid='$userid'");
  50. ????}
  51. ????echo"<script>self.location.href='resetuser.php?ecms=success';</script>";
  52. ????exit();
  53. }
  54. //返回用戶列表
  55. function?user_ReturnUserlist(){
  56. ????global?$empire,$dbtbpre;
  57. ????$users='';
  58. ????$sql=$empire->query("select?userid,username?from?{$dbtbpre}enewsuser");
  59. ????while($r=$empire->fetch($sql))
  60. ????{
  61. ????????$users.="<option?value='".$r[userid]."'>".$r[username]."</option>";
  62. ????}
  63. ????return?$users;
  64. }
  65. //登陸驗(yàn)證
  66. function?user_GotoPagePassword($ckpassword){
  67. ????global?$pagepassword;
  68. ????if($pagepassword<>$ckpassword)
  69. ????{
  70. ????????printerror2('頁面密碼錯(cuò)誤','');
  71. ????}
  72. ????@setcookie('ckecmspagepass',md5($ckpassword));
  73. ????echo"<script>self.location.href='resetuser.php?ecms=resetpage';</script>";
  74. ????exit();
  75. }
  76. //驗(yàn)證信息
  77. function?user_CheckGotoPagePass(){
  78. ????global?$pagepassword;
  79. ????if(md5($pagepassword)<>$_COOKIE['ckecmspagepass'])
  80. ????{
  81. ????????printerror2('您還未驗(yàn)證權(quán)限','resetuser.php');
  82. ????}
  83. }
  84. $ecms=$_POST['ecms'];
  85. if(empty($ecms))
  86. {
  87. ????$ecms=$_GET['ecms'];
  88. }
  89. if($ecms=='GotoPagePassword')//登陸驗(yàn)證
  90. {
  91. ????user_GotoPagePassword($_POST['ckpassword']);
  92. }
  93. elseif($ecms=='ResetUser')//重置密碼
  94. {
  95. ????user_ResetUser($_POST);
  96. }
  97. ?>
  98. <!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">
  99. <html>
  100. <head>
  101. <meta?http-equiv="Content-Type"?content="text/html;?charset=gb2312">
  102. <title>重置管理員密碼</title>
  103. <style>
  104. a???????{?text-decoration:?none;?color:?#002280?}
  105. a:hover?{?text-decoration:?underline?}
  106. body????{?font-size:?10pt;?}
  107. table???{?font-size:?10pt;?color:?#000000?}
  108. </style>
  109. <script>
  110. function?CheckUserInfo(obj){
  111. ????if(obj.userid.value=='')
  112. ????{
  113. ????????alert('請(qǐng)選擇要重置的用戶');
  114. ????????obj.userid.focus();
  115. ????????return?false;
  116. ????}
  117. ????if(obj.password.value=='')
  118. ????{
  119. ????????alert('請(qǐng)輸入重置的新密碼');
  120. ????????obj.password.focus();
  121. ????????return?false;
  122. ????}
  123. ????if(obj.password.value!=obj.repassword.value)
  124. ????{
  125. ????????alert('兩次輸入的密碼不一致');
  126. ????????obj.password.focus();
  127. ????????return?false;
  128. ????}
  129. ????if(obj.password.value.length<6)
  130. ????{
  131. ????????alert('密碼不能少于6位');
  132. ????????obj.password.focus();
  133. ????????return?false;
  134. ????}
  135. ????return?true;
  136. }
  137. </script>
  138. </head>
  139. <body>
  140. <br>
  141. <br>
  142. <br>
  143. <?php
  144. if($ecms=='success')
  145. {
  146. ????user_CheckGotoPagePass();
  147. ?>
  148. <table?width="600"?border="0"?align="center"?cellpadding="3"?cellspacing="1"?bgcolor="#4FB4DE">
  149. ??<tr>
  150. ????<td?height="30"><div?align="center"><strong><font?color="#FFFFFF">已完成重置</font></strong></div></td>
  151. ??</tr>
  152. ??<tr>
  153. ????<td?height="120"?bgcolor="#FFFFFF">
  154. ??????<div?align="center"><font?color="#FF0000"><strong>恭喜!密碼重置完畢,現(xiàn)在您可以用新的密碼登陸后臺(tái)了。</strong><br>
  155. ????????<br>
  156. ????????<br>
  157. ????????</font>(友情提示:建議馬上刪除?/e/update/resetuser.php?文件,防止被重復(fù)使用。)?</div></td>
  158. ??</tr>
  159. </table>
  160. <?php
  161. }
  162. elseif($ecms=='resetpage')
  163. {
  164. ????user_CheckGotoPagePass();
  165. ?>
  166. <form?name="reseteform"?method="post"?action="resetuser.php"?onsubmit="return?CheckUserInfo(document.reseteform);">
  167. ??<table?width="500"?border="0"?align="center"?cellpadding="3"?cellspacing="1"?bgcolor="#4FB4DE">
  168. ????<tr>
  169. ??????<td?height="30"?colspan="2"><strong><font?color="#FFFFFF">重置管理員密碼:</font></strong></td>
  170. ????</tr>
  171. ????<tr>
  172. ??????<td?width="146"?height="25"?bgcolor="#FFFFFF">用戶:</td>
  173. ??????<td?width="339"?bgcolor="#FFFFFF"><select?name="userid"?id="userid">
  174. ????????<?=user_ReturnUserlist()?>
  175. ????????</select></td>
  176. ????</tr>
  177. ????<tr>
  178. ??????<td?height="25"?bgcolor="#FFFFFF">新密碼:</td>
  179. ??????<td?bgcolor="#FFFFFF"><input?name="password"?type="password"?id="password"></td>
  180. ????</tr>
  181. ????<tr>
  182. ??????<td?height="25"?bgcolor="#FFFFFF">重復(fù)新密碼:</td>
  183. ??????<td?bgcolor="#FFFFFF"><input?name="repassword"?type="password"?id="repassword"></td>
  184. ????</tr>
  185. ????<tr>
  186. ??????<td?height="25"?bgcolor="#FFFFFF">安全問題設(shè)為空:</td>
  187. ??????<td?bgcolor="#FFFFFF"><input?name="noquestion"?type="checkbox"?id="noquestion"?value="1"?checked>
  188. ????????清空安全問題</td>
  189. ????</tr>
  190. ????<tr>
  191. ??????<td?height="25"?bgcolor="#FFFFFF">當(dāng)前認(rèn)證碼為:</td>
  192. ??????<td?bgcolor="#FFFFFF"><?=$do_loginauth?$do_loginauth:$ecms_config['esafe']['loginauth']?></td>
  193. ????</tr>
  194. ????<tr>
  195. ??????<td?height="25"?bgcolor="#FFFFFF">&nbsp;</td>
  196. ??????<td?bgcolor="#FFFFFF"><input?type="submit"?name="Submit"?value="馬上重置登錄信息">
  197. ????????<input?name="ecms"?type="hidden"?id="ecms"?value="ResetUser"></td>
  198. ????</tr>
  199. ????<tr>
  200. ??????<td?height="25"?colspan="2"?bgcolor="#FFFFFF"><font?color="#666666">說明:密碼設(shè)置6位以上,且密碼不能包含:$
  201. ????????&amp;?*?#?&lt;?&gt;?'?&quot;?/?\?%?;?空格</font></td>
  202. ????</tr>
  203. ??</table>
  204. </form>
  205. <?php
  206. }
  207. else
  208. {
  209. ?>
  210. <form?name="loginform"?method="post"?action="resetuser.php">
  211. ??<table?width="500"?border="0"?align="center"?cellpadding="3"?cellspacing="1"?bgcolor="#4FB4DE">
  212. ????<tr>
  213. ??????<td?height="30"?colspan="2"><strong><font?color="#FFFFFF">進(jìn)入重置頁面密碼:</font></strong></td>
  214. ????</tr>
  215. ????<tr>
  216. ??????<td?width="146"?height="25"?bgcolor="#FFFFFF">輸入密碼:</td>
  217. ??????<td?width="339"?bgcolor="#FFFFFF"><input?name="ckpassword"?type="password"?id="password"></td>
  218. ????</tr>
  219. ????<tr>
  220. ??????<td?height="25"?bgcolor="#FFFFFF">&nbsp;</td>
  221. ??????<td?bgcolor="#FFFFFF"><input?type="submit"?name="Submit2"?value="進(jìn)入重置登錄頁面">
  222. ????????<input?name="ecms"?type="hidden"?id="ecms"?value="GotoPagePassword"></td>
  223. ????</tr>
  224. ??</table>
  225. </form>
  226. <?php
  227. }
  228. ?>
  229. </body>
  230. </html>
  231. <?php
  232. db_close();
  233. $empire=null;
  234. ?>

然后放入到網(wǎng)站的/e/update/目錄內(nèi)
3.在瀏覽器中執(zhí)行 /e/update/resetuser.php 文件

  1. 修改?/e/update/resetuser.php?文件里的訪問密碼:(防止被他人使用)
  2. 進(jìn)入重置頁面密碼
  3. $pagepassword='123456';

依提示設(shè)置重置密碼信息,重置密碼后刪除 /e/update/resetuser.php 文件
效果如圖
帝國CMS-管理員密碼重置

版權(quán)聲明:文章圖片資源來源于網(wǎng)絡(luò),如有侵權(quán),請(qǐng)留言刪除!!!
廣告也精彩
admin
  • 本文由 發(fā)表于 2021年9月29日 17:22:26
  • 轉(zhuǎn)載請(qǐng)務(wù)必保留本文鏈接:http://yudch.cn/7815.html
匿名

發(fā)表評(píng)論

匿名網(wǎng)友 填寫信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: