member_editinfofun.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. //--------------- 修改信息函数 ---------------
  3. //修改安全信息
  4. function EditSafeInfo($add){
  5. global $empire,$dbtbpre,$public_r;
  6. $user_r=islogin();//是否登陆
  7. $userid=$user_r[userid];
  8. $username=$user_r[username];
  9. $rnd=$user_r[rnd];
  10. //邮箱
  11. $email=trim($add['email']);
  12. if(!$email||!chemail($email))
  13. {
  14. printerror("EmailFail","history.go(-1)",1);
  15. }
  16. $email=addslashes(RepPostStr($email));
  17. $email=RepPostVar($email);
  18. //验证原密码
  19. $oldpassword=RepPostVar($add[oldpassword]);
  20. if(!$oldpassword)
  21. {
  22. printerror('FailOldPassword','',1);
  23. }
  24. $add[password]=RepPostVar($add[password]);
  25. $num=0;
  26. $ur=$empire->fetch1("select ".eReturnSelectMemberF('userid,password,salt')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid'");
  27. if(empty($ur['userid']))
  28. {
  29. printerror('FailOldPassword','',1);
  30. }
  31. if(!eDoCkMemberPw($oldpassword,$ur['password'],$ur['salt']))
  32. {
  33. printerror('FailOldPassword','',1);
  34. }
  35. //邮箱
  36. $pr=$empire->fetch1("select regemailonly from {$dbtbpre}enewspublic limit 1");
  37. if($pr['regemailonly'])
  38. {
  39. $num=$empire->gettotal("select count(*) as total from ".eReturnMemberTable()." where ".egetmf('email')."='$email' and ".egetmf('userid')."<>'$userid' limit 1");
  40. if($num)
  41. {
  42. printerror("ReEmailFail","history.go(-1)",1);
  43. }
  44. }
  45. //密码
  46. $a='';
  47. $salt='';
  48. $truepassword='';
  49. if($add[password])
  50. {
  51. if($add[password]!==$add[repassword])
  52. {
  53. printerror('NotRepassword','history.go(-1)',1);
  54. }
  55. $salt=eReturnMemberSalt();
  56. $password=eDoMemberPw($add[password],$salt);
  57. $a=",".egetmf('password')."='$password',".egetmf('salt')."='$salt'";
  58. $truepassword=$add[password];
  59. }
  60. $sql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('email')."='$email'".$a." where ".egetmf('userid')."='$userid'");
  61. if($sql)
  62. {
  63. //易通行系统
  64. DoEpassport('editpassword',$userid,$username,$truepassword,$salt,$email,$user_r['groupid'],'');
  65. printerror("EditInfoSuccess","../member/EditInfo/EditSafeInfo.php",1);
  66. }
  67. else
  68. {
  69. printerror("DbError","history.go(-1)",1);
  70. }
  71. }
  72. //信息修改
  73. function EditInfo($post){
  74. global $empire,$dbtbpre,$public_r;
  75. $user_r=islogin();//是否登陆
  76. $userid=$user_r[userid];
  77. $username=$user_r[username];
  78. $dousername=$username;
  79. $rnd=$user_r[rnd];
  80. $groupid=$user_r[groupid];
  81. if(!$userid||!$username)
  82. {
  83. printerror("NotEmpty","history.go(-1)",1);
  84. }
  85. //验证附加表必填项
  86. $addr=$empire->fetch1("select * from {$dbtbpre}enewsmemberadd where userid='$userid'");
  87. $user_r=$empire->fetch1("select ".eReturnSelectMemberF('groupid')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid'");
  88. $fid=GetMemberFormId($user_r['groupid']);
  89. if(empty($addr[userid]))
  90. {
  91. $mr['add_filepass']=$userid;
  92. $member_r=ReturnDoMemberF($fid,$post,$mr,0,$dousername);
  93. }
  94. else
  95. {
  96. $addr['add_filepass']=$userid;
  97. $member_r=ReturnDoMemberF($fid,$post,$addr,1,$dousername);
  98. }
  99. //附加表
  100. if(empty($addr[userid]))
  101. {
  102. //IP
  103. $regip=egetip();
  104. $regipport=egetipport();
  105. $lasttime=time();
  106. $sql=$empire->query("insert into {$dbtbpre}enewsmemberadd(userid,regip,lasttime,lastip,loginnum,regipport,lastipport".$member_r[0].") values('$userid','$regip','$lasttime','$regip',1,'$regipport','$regipport'".$member_r[1].");");
  107. }
  108. else
  109. {
  110. $sql=$empire->query("update {$dbtbpre}enewsmemberadd set userid='$userid'".$member_r[0]." where userid='$userid'");
  111. }
  112. //更新附件
  113. UpdateTheFileEditOther(6,$userid,'member');
  114. if($sql)
  115. {
  116. printerror("EditInfoSuccess","../member/EditInfo/",1);
  117. }
  118. else
  119. {
  120. printerror("DbError","history.go(-1)",1);
  121. }
  122. }
  123. ?>