friendfun.php
4.9 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
//--------------- 會員好友函數 ---------------
//增加好友
function AddFriend($add){
global $empire,$dbtbpre;
//是否登陸
$user_r=islogin();
$fname=RepPostVar(trim($add['fname']));
$add['fcid']=(int)$add['fcid'];
if(!$fname)
{
printerror("EmptyFriend","",1);
}
//加自己為好友
if($fname==$user_r['username'])
{
printerror("NotAddFriendSelf","",1);
}
$num=$empire->gettotal("select count(*) as total from ".eReturnMemberTable()." where ".egetmf('username')."='$fname' limit 1");
if(!$num)
{
printerror("NotFriendUsername","",1);
}
//重複提交
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewshy where fname='$fname' and userid='$user_r[userid]' limit 1");
if($num)
{
printerror("ReAddFriend","",1);
}
$cid=(int)$add['cid'];
$fsay=RepPostStr($add['fsay']);
$sql=$empire->query("insert into {$dbtbpre}enewshy(userid,fname,cid,fsay) values('$user_r[userid]','".addslashes($fname)."',$cid,'".addslashes($fsay)."');");
if($sql)
{
printerror("AddFriendSuccess","../member/friend/?cid=$add[fcid]",1);
}
else
{
printerror("DbError","",1);
}
}
//修改好友
function EditFriend($add){
global $empire,$dbtbpre;
//是否登陸
$user_r=islogin();
$fid=(int)$add['fid'];
$fname=RepPostVar(trim($add['fname']));
$add['fcid']=(int)$add['fcid'];
if(!$fname||!$fid)
{
printerror("EmptyFriend","",1);
}
//加自己為好友
if($fname==$user_r['username'])
{
printerror("NotAddFriendSelf","",1);
}
$num=$empire->gettotal("select count(*) as total from ".eReturnMemberTable()." where ".egetmf('username')."='$fname' limit 1");
if(!$num)
{
printerror("NotFriendUsername","",1);
}
//重複提交
if($fname!=$add['oldfname'])
{
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewshy where fname='$fname' and userid='$user_r[userid]' limit 1");
if($num)
{
printerror("ReAddFriend","",1);
}
}
$cid=(int)$add['cid'];
$fsay=RepPostStr($add['fsay']);
$sql=$empire->query("update {$dbtbpre}enewshy set fname='".addslashes($fname)."',cid=$cid,fsay='".addslashes($fsay)."' where fid=$fid and userid='$user_r[userid]'");
if($sql)
{
printerror("EditFriendSuccess","../member/friend/?cid=$add[fcid]",1);
}
else
{
printerror("DbError","",1);
}
}
//刪除好友
function DelFriend($add){
global $empire,$dbtbpre;
//是否登陸
$user_r=islogin();
$fid=(int)$add['fid'];
$add['fcid']=(int)$add['fcid'];
if(!$fid)
{
printerror("EmptyFriendId","",1);
}
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewshy where fid=$fid and userid='$user_r[userid]'");
if(!$num)
{
printerror("EmptyFriendId","",1);
}
$sql=$empire->query("delete from {$dbtbpre}enewshy where fid=$fid and userid='$user_r[userid]'");
if($sql)
{
printerror("DelFriendSuccess","../member/friend/?cid=$add[fcid]",1);
}
else
{
printerror("DbError","",1);
}
}
//增加好友分類
function AddFriendClass($add){
global $empire,$dbtbpre;
if(!trim($add[cname]))
{
printerror('EmptyFavaClassname','history.go(-1)',1);
}
//是否登陸
$user_r=islogin();
$add[cname]=RepPostStr($add[cname]);
$sql=$empire->query("insert into {$dbtbpre}enewshyclass(cname,userid) values('$add[cname]','$user_r[userid]');");
if($sql)
{
printerror('AddFavaClassSuccess','../member/friend/FriendClass/',1);
}
else
{
printerror('DbError','history.go(-1)',1);
}
}
//修改好友分類
function EditFriendClass($add){
global $empire,$dbtbpre;
$add[cid]=(int)$add[cid];
if(!trim($add[cname])||!$add[cid])
{
printerror('EmptyFavaClassname','history.go(-1)',1);
}
//是否登陸
$user_r=islogin();
$add[cname]=RepPostStr($add[cname]);
$sql=$empire->query("update {$dbtbpre}enewshyclass set cname='$add[cname]' where cid='$add[cid]' and userid='$user_r[userid]'");
if($sql)
{
printerror('EditFavaClassSuccess','../member/friend/FriendClass/',1);
}
else
{
printerror('DbError','history.go(-1)',1);
}
}
//刪除好友分類
function DelFriendClass($cid){
global $empire,$dbtbpre;
$cid=(int)$cid;
if(!$cid)
{
printerror('EmptyFavaClassid','history.go(-1)',1);
}
//是否登陸
$user_r=islogin();
$sql=$empire->query("delete from {$dbtbpre}enewshyclass where cid='$cid' and userid='$user_r[userid]'");
if($sql)
{
printerror('DelFavaClassSuccess','../member/friend/FriendClass/',1);
}
else
{
printerror('DbError','history.go(-1)',1);
}
}
//返回好友分類
function ReturnFriendclass($userid,$cid){
global $empire,$dbtbpre;
$sql=$empire->query("select cid,cname from {$dbtbpre}enewshyclass where userid='$userid' order by cid");
$select='';
while($r=$empire->fetch($sql))
{
if($r[cid]==$cid)
{$selected=' selected';}
else
{$selected='';}
$select.='<option value="'.$r[cid].'"'.$selected.'>'.$r[cname].'</option>';
}
return $select;
}
?>