国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

95 lines
4.0KB

  1. <?php
  2. /**
  3. * DedeBIZ后台账号密码修改工具,改完即删,别留着过年,老铁们~
  4. *
  5. * @version $id:resetpwd.php tianya $
  6. * @package DedeBIZ.Tools
  7. * @copyright Copyright (c) 2023 DedeBIZ.COM
  8. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  9. * @link https://www.dedebiz.com
  10. */
  11. define('DEDEBIZ_REPWD_VER', '1.0.0');
  12. /**
  13. * ToolAlert
  14. *
  15. * @param mixed $content
  16. * @param mixed $colors
  17. * @return string
  18. */
  19. function ToolAlert($content, $colors = array('#cfe2ff', '#b6d4fe', '#084298'))
  20. {
  21. define('TOOLS_ALERT_TPL', '<div style="position:relative;padding:0.75rem 1.25rem;margin-bottom:1rem;width:auto;font-size:14px;color:~color~;background:~background~;border-color:~border~;border:1px solid transparent;border-radius:0.5rem">~content~</div>');
  22. list($background, $border, $color) = $colors;
  23. return str_replace(array('~color~', '~background~', '~border~', '~content~'), array($color, $background, $border, $content), TOOLS_ALERT_TPL);
  24. }
  25. if (!file_exists(dirname(__FILE__) . '/system/common.inc.php')) {
  26. echo ToolAlert("请把当前文件放置到DedeBIZ根目录下,通过`http://网站域名/dedebiz_repwd.php`进行操作");
  27. exit;
  28. }
  29. require_once dirname(__FILE__) . '/system/common.inc.php';
  30. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  31. $dopost = isset($dopost)? $dopost : '';
  32. $adminname = isset($adminname)? HtmlReplace($adminname, -1) : '';
  33. $newpwd = isset($newpwd)? $newpwd : '';
  34. $renewpwd = isset($renewpwd)? $renewpwd : '';
  35. $dbpwd = isset($dbpwd)? $dbpwd : '';
  36. if ($dopost === 'change') {
  37. if (empty($adminname)) {
  38. ShowMsg("管理员账号不能为空", -1);
  39. exit;
  40. }
  41. if (empty($newpwd) || $newpwd !== $renewpwd) {
  42. ShowMsg("新密码不能为空,且两次输入必须保持一致", -1);
  43. exit;
  44. }
  45. if (empty($dbpwd) || $dbpwd !== $cfg_dbpwd) {
  46. ShowMsg("数据库连接密码不能为空,切必须正确", -1);
  47. exit;
  48. }
  49. $admin = $dsql->GetOne("SELECT * FROM `#@__admin` WHERE `userid` = '$adminname'");
  50. if (empty($admin)) {
  51. ShowMsg("不存在当前输入的管理员账号", -1);
  52. exit;
  53. }
  54. if (function_exists('password_hash')) {
  55. $pwdm = "pwd='',pwd_new='".password_hash($newpwd, PASSWORD_BCRYPT)."'";
  56. $pwd = "pwd='',pwd_new='".password_hash($newpwd, PASSWORD_BCRYPT)."'";
  57. } else {
  58. $pwdm = "pwd='".md5($newpwd)."'";
  59. $pwd = "pwd='".substr(md5($newpwd), 5, 20)."'";
  60. }
  61. $id = $admin['id'];
  62. $query = "UPDATE `#@__admin` SET $pwd WHERE id='$id'";
  63. $dsql->ExecuteNoneQuery($query);
  64. $query = "UPDATE `#@__member` SET $pwdm WHERE mid='$id'";
  65. $dsql->ExecuteNoneQuery($query);
  66. ShowMsg("管理员密码成功修改为<code>{$newpwd}</code>,请务必删除当前文件", 'javascript:;');
  67. exit;
  68. }
  69. $wintitle = "DedeBIZ后台账号密码修改工具";
  70. $wecome_info = "DedeBIZ后台账号密码修改工具 V" . DEDEBIZ_REPWD_VER;
  71. $win = new OxWindow();
  72. $win->Init(basename(__FILE__), 'js/blank.js', 'POST');
  73. $win->AddHidden('dopost', 'change');
  74. $win->AddHidden('token', $_SESSION['token']);
  75. $win->AddTitle("<div class='alert alert-info mb-0'>需要技术服务或商业工具,请<a href='https://www.dedebiz.com/service' target='_blank'>联系官方</a></div>");
  76. $win->AddMsgItem('
  77. <tr>
  78. <td width="260">管理员账号:</td>
  79. <td><input type="text" name="adminname" id="adminname" class="admin-input-lg" placeholder="输入需要修改密码的管理员账号"></td>
  80. </tr>
  81. <tr>
  82. <td width="260">密码:</td>
  83. <td><input type="password" name="newpwd" id="newpwd" class="admin-input-lg" placeholder="新的密码"></td>
  84. </tr>
  85. <tr>
  86. <td width="260">再次输入密码:</td>
  87. <td><input type="password" name="renewpwd" id="renewpwd" class="admin-input-lg" placeholder="重复上面的密码"></td>
  88. </tr>
  89. <tr>
  90. <td width="260">数据库密码:</td>
  91. <td><input type="password" name="dbpwd" id="dbpwd" class="admin-input-lg" placeholder="输入数据库连接密码"> 查看`data/common.inc.php`中的`cfg_dbpwd`</td>
  92. </tr>
  93. ');
  94. $winform = $win->GetWindow('ok');
  95. $win->Display();