国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sys_admin_user_edit.php 4.8KB

2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * 编辑系统管理员
  4. *
  5. * @version $Id: sys_admin_user_edit.php 1 16:22 2010年7月20日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__).'/config.php');
  12. CheckPurview('sys_User');
  13. require_once(DEDEINC.'/typelink/typelink.class.php');
  14. if (empty($dopost)) $dopost = '';
  15. $id = preg_replace("#[^0-9]#", '', $id);
  16. if ($dopost == 'saveedit') {
  17. CheckCSRF();
  18. $pwd = trim($pwd);
  19. if ($pwd != '' && preg_match("#[^0-9a-zA-Z_@!\.-]#", $pwd)) {
  20. ShowMsg('密码不合法,请使用[0-9a-zA-Z_@!.-]内的字符', '-1', 0, 3000);
  21. exit();
  22. }
  23. $safecodeok = substr(md5($cfg_cookie_encode.$randcode), 0, 24);
  24. if ($safecodeok != $safecode) {
  25. ShowMsg("请填写正确的安全验证串", "sys_admin_user_edit.php?id={$id}&dopost=edit");
  26. exit();
  27. }
  28. $pwdm = '';
  29. if ($pwd != '') {
  30. $pwdm = ",pwd='".md5($pwd)."'";
  31. $pwd = ",pwd='".substr(md5($pwd), 5, 20)."'";
  32. if (function_exists('password_hash')) {
  33. $pwdm = ",pwd_new='".password_hash($pwd, PASSWORD_BCRYPT)."'";
  34. $pwd = ",pwd_new='".password_hash($pwd, PASSWORD_BCRYPT)."'";
  35. }
  36. }
  37. if (empty($typeids)) {
  38. $typeid = '';
  39. } else {
  40. $typeid = join(',', $typeids);
  41. if ($typeid == '0') $typeid = '';
  42. }
  43. if ($id != 1) {
  44. $query = "UPDATE `#@__admin` SET uname='$uname',usertype='$usertype',tname='$tname',email='$email',typeid='$typeid' $pwd WHERE id='$id'";
  45. } else {
  46. $query = "UPDATE `#@__admin` SET uname='$uname',tname='$tname',email='$email',typeid='$typeid' $pwd WHERE id='$id'";
  47. }
  48. $dsql->ExecuteNoneQuery($query);
  49. $query = "UPDATE `#@__member` SET uname='$uname',email='$email'$pwdm WHERE mid='$id'";
  50. $dsql->ExecuteNoneQuery($query);
  51. ShowMsg("成功修改一个帐户", "sys_admin_user.php");
  52. exit();
  53. } else if ($dopost == 'delete') {
  54. if (empty($userok)) $userok = "";
  55. if ($userok != "yes") {
  56. $randcode = mt_rand(10000, 99999);
  57. $safecode = substr(md5($cfg_cookie_encode.$randcode), 0, 24);
  58. require_once(DEDEINC."/libraries/oxwindow.class.php");
  59. $wintitle = "删除用户";
  60. $wecome_info = "<a href='sys_admin_user.php'>系统帐号管理</a>::删除用户";
  61. $win = new OxWindow();
  62. $win->Init("sys_admin_user_edit.php", "js/blank.js", "POST");
  63. $win->AddHidden("dopost", $dopost);
  64. $win->AddHidden("userok", "yes");
  65. $win->AddHidden("randcode", $randcode);
  66. $win->AddHidden("safecode", $safecode);
  67. $win->AddHidden("id", $id);
  68. $win->AddTitle("系统提示");
  69. $win->AddMsgItem("您确定要删除用户:$userid 吗", "50");
  70. $win->AddMsgItem("安全验证串:<input name='safecode' type='text' id='safecode' style='width:260px'>(复制本代码:<span class='text-danger'>$safecode</span>)", "30");
  71. $winform = $win->GetWindow("ok");
  72. $win->Display();
  73. exit();
  74. }
  75. $safecodeok = substr(md5($cfg_cookie_encode.$randcode), 0, 24);
  76. if ($safecodeok != $safecode) {
  77. ShowMsg("请填写正确的安全验证串", "sys_admin_user.php");
  78. exit();
  79. }
  80. //不能删除id为1的创建人帐号,不能删除自己
  81. $rs = $dsql->ExecuteNoneQuery2("DELETE FROM `#@__admin` WHERE id='$id' AND id<>1 AND id<>'".$cuserLogin->getUserID()."' ");
  82. if ($rs > 0) {
  83. //更新前台用户信息
  84. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET matt='0' WHERE mid='$id' LIMIT 1");
  85. ShowMsg("成功删除一个帐户", "sys_admin_user.php");
  86. } else {
  87. ShowMsg("不能删除id为1的创建人帐号,不能删除自己", "sys_admin_user.php", 0, 3000);
  88. }
  89. exit();
  90. }
  91. //显示用户信息
  92. $randcode = mt_rand(10000, 99999);
  93. $safecode = substr(md5($cfg_cookie_encode.$randcode), 0, 24);
  94. $typeOptions = '';
  95. $row = $dsql->GetOne("SELECT * FROM `#@__admin` WHERE id='$id'");
  96. $typeids = explode(',', $row['typeid']);
  97. $dsql->SetQuery("SELECT id,typename FROM `#@__arctype` WHERE reid=0 AND (ispart=0 OR ispart=1)");
  98. $dsql->Execute('op');
  99. while ($nrow = $dsql->GetObject('op')) {
  100. $typeOptions .= "<option value='{$nrow->id}' class='btype'".(in_array($nrow->id, $typeids) ? ' selected' : '').">{$nrow->typename}</option>\r\n";
  101. $dsql->SetQuery("SELECT id,typename FROM #@__arctype WHERE reid={$nrow->id} AND (ispart=0 OR ispart=1)");
  102. $dsql->Execute('s');
  103. while ($nrow = $dsql->GetObject('s')) {
  104. $typeOptions .= "<option value='{$nrow->id}' class='stype'".(in_array($nrow->id, $typeids) ? ' selected' : '').">—{$nrow->typename}</option>\r\n";
  105. }
  106. }
  107. make_hash();
  108. include DedeInclude('templets/sys_admin_user_edit.htm');