国内流行的内容管理系统(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.

116 lines
4.4KB

  1. <?php
  2. /**
  3. * 修改资料
  4. *
  5. * @version $id:edit_baseinfo.php 8:38 2010年7月9日 tianya $
  6. * @package DedeBIZ.User
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckRank(0, 0);//禁止游客操作
  13. $menutype = 'config';
  14. if (!isset($dopost)) $dopost = '';
  15. $pwd2 = (empty($pwd2)) ? "" : $pwd2;
  16. $row = $dsql->GetOne("SELECT * FROM `#@__member` WHERE mid='".$cfg_ml->M_ID."'");
  17. $face = $row['face'];
  18. $newface = isset($newface)? $newface : '';
  19. if ($dopost == 'save') {
  20. //校验CSRF
  21. CheckCSRF();
  22. if ($userpwd != $userpwdok) {
  23. ShowMsg('您两次输入的新密码不一致', 'edit_baseinfo.php');
  24. exit();
  25. }
  26. $addupquery = '';
  27. $admaddupquery = '';
  28. $pp = "pwd";
  29. $pwd = '';
  30. if ($userpwd == '') {
  31. if (function_exists('password_hash')) {
  32. $pp = "pwd_new";
  33. $pwd = $row['pwd_new'];
  34. $addupquery = ',pwd=\'\'';
  35. } else {
  36. $pwd = $row['pwd'];
  37. }
  38. } else {
  39. if (function_exists('password_hash'))
  40. {
  41. $pp = "pwd_new";
  42. $pwd = password_hash($userpwd, PASSWORD_BCRYPT);
  43. $pwd2 = password_hash($userpwd, PASSWORD_BCRYPT);
  44. $addupquery = ',pwd=\'\'';
  45. $admaddupquery = ',pwd=\'\'';
  46. } else {
  47. $pwd = md5($userpwd);
  48. $pwd2 = substr(md5($userpwd), 5, 20);
  49. }
  50. }
  51. //修改头像
  52. $target_file = $cfg_basedir.$cfg_user_dir."/{$cfg_ml->M_ID}/newface.png";
  53. if (!empty($newface) && file_exists($target_file)) {
  54. $rnd = mt_rand(10000, 99999);
  55. rename($target_file, $cfg_basedir.$cfg_user_dir."/{$cfg_ml->M_ID}/face{$rnd}.png");
  56. $target_url = $cfg_mediasurl.'/userup'."/{$cfg_ml->M_ID}/face{$rnd}.png";
  57. $addupquery = ",face='{$target_url}'";
  58. @unlink($target_file);
  59. }
  60. //修改安全问题或邮箱
  61. if ($email != $row['email'] || ($newsafequestion != 0 && $newsafeanswer != '')) {
  62. if ($row['safequestion'] != 0 && ($row['safequestion'] != $safequestion || $row['safeanswer'] != $safeanswer)) {
  63. ShowMsg('您的旧安全问题及答案不正确,不能修改邮箱或安全问题', 'edit_baseinfo.php');
  64. exit();
  65. }
  66. //修改邮箱
  67. if (!empty($email)) {
  68. if ($email != $row['email']) {
  69. if (!CheckEmail($email)) {
  70. ShowMsg('邮箱格式不正确', 'edit_baseinfo.php');
  71. exit();
  72. } else {
  73. $addupquery .= ",email='$email',spacesta='-10'";
  74. }
  75. }
  76. }
  77. //修改安全问题
  78. if ($newsafequestion != 0 && $newsafeanswer != '') {
  79. if (strlen($newsafeanswer) > 30) {
  80. ShowMsg('您的新安全问题的答案太长了,请保持在30字节以内', 'edit_baseinfo.php');
  81. exit();
  82. } else {
  83. $newsafequestion = HtmlReplace($newsafequestion, 1);
  84. $newsafeanswer = HtmlReplace($newsafeanswer, 1);
  85. $addupquery .= ",safequestion='$newsafequestion',safeanswer='$newsafeanswer'";
  86. }
  87. }
  88. }
  89. //修改uname
  90. if ($uname != $row['uname']) {
  91. $rs = CheckUserID($uname, '昵称或公司名称', FALSE);
  92. if ($rs != 'ok') {
  93. ShowMsg($rs, 'edit_baseinfo.php');
  94. exit();
  95. }
  96. $addupquery .= ",uname='$uname'";
  97. }
  98. //性别
  99. if (!in_array($sex, array('男', '女', '保密'))) {
  100. ShowMsg('请选择正常的性别', 'edit_baseinfo.php');
  101. exit();
  102. }
  103. $query1 = "UPDATE `#@__member` SET $pp='$pwd',sex='$sex'{$addupquery} WHERE mid='".$cfg_ml->M_ID."' ";
  104. $dsql->ExecuteNoneQuery($query1);
  105. //如果是管理员,修改其后台密码
  106. if ($cfg_ml->fields['matt'] == 10 && $pwd2 != "") {
  107. $query2 = "UPDATE `#@__admin` SET $pp='$pwd2'{$admaddupquery} WHERE id='".$cfg_ml->M_ID."' ";
  108. $dsql->ExecuteNoneQuery($query2);
  109. }
  110. //清除会员缓存
  111. $cfg_ml->DelCache($cfg_ml->M_ID);
  112. ShowMsg('成功更新您的基本资料', 'edit_baseinfo.php', 0, 5000);
  113. exit();
  114. }
  115. include(DEDEMEMBER."/templets/edit_baseinfo.htm");
  116. ?>