/[LeafOK_CVS]/fenglin/bbs/user_section_favor.inc.php
ViewVC logotype

Contents of /fenglin/bbs/user_section_favor.inc.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Tue Apr 29 11:55:32 2025 UTC (10 months, 2 weeks ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -1 lines
Remove redundant PHP closing tag

1 <?php
2 if (!isset($_BBS_S_FAVOR_CLASS_INIT_))
3 {
4 $_BBS_S_FAVOR_CLASS_INIT_=1;
5
6 class section_favorite
7 {
8 var $s_list;
9 var $s_count;
10
11 function __construct($uid = 0, $db_conn = NULL)
12 {
13 $this->load_s_favor($uid, $db_conn);
14 }
15
16 function load_s_favor($uid, $db_conn)
17 {
18 $this->s_list = array();
19
20 if ($uid == 0)
21 {
22 return 0;
23 }
24
25 if ($db_conn == NULL)
26 {
27 return -1;
28 }
29
30 $rs = mysqli_query($db_conn, "SELECT SID FROM section_favorite WHERE UID = $uid");
31 if ($rs == false)
32 {
33 return -2;
34 }
35 while ($row = mysqli_fetch_array($rs))
36 {
37 array_push($this->s_list, $row["SID"]);
38 }
39 mysqli_free_result($rs);
40
41 return 0;
42 }
43
44 function save_s_favor($uid, $db_conn)
45 {
46 if ($db_conn == NULL)
47 {
48 return -1;
49 }
50
51 if (mysqli_query($db_conn, "DELETE FROM section_favorite WHERE UID = $uid") == false)
52 {
53 return -2;
54 }
55
56 foreach ($this->s_list as $sid)
57 {
58 if (mysqli_query($db_conn, "INSERT INTO section_favorite(UID, SID) VALUES($uid, $sid)") == false)
59 {
60 return -3;
61 }
62 }
63
64 return 0;
65 }
66
67 function is_in($sid)
68 {
69 return in_array($sid, $this->s_list);
70 }
71 }
72 }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1