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