favfun.php
5.08 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
<?php
//--------------- 收藏夾函數 ---------------
//增加收藏
function AddFava($id,$classid,$cid,$from){
global $empire,$level_r,$class_r,$dbtbpre;
//是否登陸
$user_r=islogin();
$id=(int)$id;
$cid=(int)$cid;
$classid=(int)$classid;
if(empty($id)||empty($classid))
{
printerror("ErrorUrl","history.go(-1)",1);
}
//表不存在
if(empty($class_r[$classid][tbname]))
{
printerror("ErrorUrl","history.go(-1)",1);
}
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$id' and classid='$classid'");
if(empty($num))
{printerror("ErrorUrl","history.go(-1)",1);}
//是否已收藏
$newsnum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsfava where id='$id' and classid='$classid' and userid='$user_r[userid]'");
if($newsnum)
{
printerror("ReFava","history.go(-1)",1);
}
$favanum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsfava where userid='$user_r[userid]'");
$groupid=$user_r[groupid];
if($level_r[$groupid][favanum]<=$favanum)
{
printerror("MoreFava","history.go(-1)",1);
}
$favatime=date("Y-m-d H:i:s");
$sql=$empire->query("insert into {$dbtbpre}enewsfava(id,favatime,userid,username,classid,cid) values('$id','$favatime','$user_r[userid]','$user_r[username]','$classid','$cid');");
if($sql)
{
printerror("AddFavaSuccess",RepPostStrUrl($from),1);
}
else
{
printerror("DbError","history.go(-1)",1);
}
}
//批量刪除收藏
function DelFava_All($favaid){
global $empire,$dbtbpre;
//是否登陸
$user_r=islogin();
$count=count($favaid);
if(empty($count))
{printerror("NotDelFavaid","history.go(-1)",1);}
for($i=0;$i<$count;$i++)
{
$add.="favaid='".intval($favaid[$i])."' or ";
}
$add=substr($add,0,strlen($add)-4);
$sql=$empire->query("delete from {$dbtbpre}enewsfava where (".$add.") and userid='$user_r[userid]'");
if($sql)
{printerror("DelFavaSuccess","../member/fava/",1);}
else
{printerror("DbError","history.go(-1)",1);}
}
//刪除單個收藏夾
function DelFava($favaid){
global $empire,$dbtbpre;
//是否登陸
$user_r=islogin();
$favaid=(int)$favaid;
if(empty($favaid))
{printerror("NotDelFavaid","history.go(-1)",1);}
$sql=$empire->query("delete from {$dbtbpre}enewsfava where favaid='$favaid' and userid='$user_r[userid]'");
if($sql)
{printerror("DelFavaSuccess","../member/fava/",1);}
else
{printerror("DbError","history.go(-1)",1);}
}
//增加收藏夾分類
function AddFavaClass($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}enewsfavaclass(cname,userid) values('$add[cname]','$user_r[userid]');");
if($sql)
{
printerror('AddFavaClassSuccess','../member/fava/FavaClass/',1);
}
else
{
printerror('DbError','history.go(-1)',1);
}
}
//修改收藏夾分類
function EditFavaClass($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}enewsfavaclass set cname='$add[cname]' where cid='$add[cid]' and userid='$user_r[userid]'");
if($sql)
{
printerror('EditFavaClassSuccess','../member/fava/FavaClass/',1);
}
else
{
printerror('DbError','history.go(-1)',1);
}
}
//刪除收藏夾分類
function DelFavaClass($cid){
global $empire,$dbtbpre;
$cid=(int)$cid;
if(!$cid)
{
printerror('EmptyFavaClassid','history.go(-1)',1);
}
//是否登陸
$user_r=islogin();
$sql=$empire->query("delete from {$dbtbpre}enewsfavaclass where cid='$cid' and userid='$user_r[userid]'");
if($sql)
{
printerror('DelFavaClassSuccess','../member/fava/FavaClass/',1);
}
else
{
printerror('DbError','history.go(-1)',1);
}
}
//返回收藏夾分類
function ReturnFavaclass($userid,$cid){
global $empire,$dbtbpre;
$sql=$empire->query("select cid,cname from {$dbtbpre}enewsfavaclass 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;
}
//批量轉移收藏
function MoveFava_All($favaid,$cid){
global $empire,$dbtbpre;
//是否登陸
$user_r=islogin();
$cid=(int)$cid;
if(!$cid)
{printerror("NotChangeMoveCid","history.go(-1)",1);}
$count=count($favaid);
if(empty($count))
{printerror("NotMoveFavaid","history.go(-1)",1);}
for($i=0;$i<$count;$i++)
{
$add.="favaid='".intval($favaid[$i])."' or ";
}
$add=substr($add,0,strlen($add)-4);
$sql=$empire->query("update {$dbtbpre}enewsfava set cid=$cid where (".$add.") and userid='$user_r[userid]'");
if($sql)
{printerror("MoveFavaSuccess","../member/fava/",1);}
else
{printerror("DbError","history.go(-1)",1);}
}
?>