/[LeafOK_CVS]/fenglin/bbs/section_setting.php
ViewVC logotype

Diff of /fenglin/bbs/section_setting.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 by sysadm, Tue Apr 8 09:29:17 2025 UTC Revision 1.3 by sysadm, Wed Apr 9 04:10:57 2025 UTC
# Line 24  Line 24 
24                  exit(json_encode($result_set));                  exit(json_encode($result_set));
25          }          }
26    
27            // Load section setting
28          $sql = "SELECT * FROM section_config WHERE SID = $sid AND enable";          $sql = "SELECT * FROM section_config WHERE SID = $sid AND enable";
29    
30          $rs = mysqli_query($db_conn, $sql);          $rs = mysqli_query($db_conn, $sql);
# Line 36  Line 37 
37                  exit(json_encode($result_set));                  exit(json_encode($result_set));
38          }          }
39    
40          if($row = mysqli_fetch_array($rs))          if ($row = mysqli_fetch_array($rs))
41          {          {
42                  $result_set["return"]["data"] = array(                  $result_set["data"] = array(
43                          "sid" => $sid,                          "sid" => $sid,
                         "sname" => $row["sname"],  
                         "s_title" => $row["title"],  
44                          "announcement" => $row["announcement"],                          "announcement" => $row["announcement"],
45                          "comment" => $row["comment"],                          "comment" => $row["comment"],
46                          "ex_update" => $row["ex_update"],                          "ex_update" => $row["ex_update"],
47                          "ex_dir" => array(),                          "section_hierachy" => array(),
48                            "masters" => array(),
49                  );                  );
50          }          }
51          else          else
# Line 59  Line 59 
59    
60          mysqli_free_result($rs);          mysqli_free_result($rs);
61    
62          $sql = "SELECT * FROM ex_dir WHERE SID = $sid AND enable ORDER BY dir";          // Load section master
63            $sql = "SELECT section_master.UID, username, major, begin_dt, end_dt FROM section_master
64                            INNER JOIN user_list ON section_master.UID = user_list.UID
65                            WHERE SID = $sid AND section_master.enable AND (NOW() BETWEEN begin_dt AND end_dt)
66                            ORDER BY major DESC, begin_dt ASC, end_dt ASC";
67    
68          $rs = mysqli_query($db_conn, $sql);          $rs = mysqli_query($db_conn, $sql);
69          if ($rs == false)          if ($rs == false)
70          {          {
71                  $result_set["return"]["code"] = -2;                  $result_set["return"]["code"] = -2;
72                  $result_set["return"]["message"] = "Query ex_dir error: " . mysqli_error($db_conn);                  $result_set["return"]["message"] = "Query section master error: " . mysqli_error($db_conn);
73    
74                  mysqli_close($db_conn);                  mysqli_close($db_conn);
75                  exit(json_encode($result_set));                  exit(json_encode($result_set));
76          }          }
77    
78          array_push($result_set["return"]["data"]["ex_dir"], array(          while ($row = mysqli_fetch_array($rs))
79                  "dir" => "",          {
80                  "name" => "根目录",                  array_push($result_set["data"]["masters"], array(
81          ));                          "uid" => $row["UID"],
82                            "username" => $row["username"],
83          while($row = mysqli_fetch_array($rs))                          "major" => $row["major"],
84          {                          "begin_dt" => $row["begin_dt"],
85                  array_push($result_set["return"]["data"]["ex_dir"], array(                          "end_dt" => $row["end_dt"],
86                          "dir" => $row["dir"],                  ));
87                          "name" => $row["name"],          }
88            mysqli_free_result($rs);
89    
90            // Load section list
91            $sql = "SELECT SID, section_config.CID, section_config.title AS s_title, section_class.title AS c_title
92                            FROM section_config INNER JOIN section_class ON section_config.CID = section_class.CID
93                            WHERE section_class.enable AND section_config.enable
94                            ORDER BY section_class.sort_order, section_config.sort_order";
95    
96            $rs = mysqli_query($db_conn, $sql);
97            if ($rs == false)
98            {
99                    $result_set["return"]["code"] = -2;
100                    $result_set["return"]["message"] = "Query section error: " . mysqli_error($db_conn);
101    
102                    mysqli_close($db_conn);
103                    exit(json_encode($result_set));
104            }
105    
106            $last_cid = -1;
107            $last_c_title = "";
108            $section_list = array();
109            while ($row = mysqli_fetch_array($rs))
110            {
111                    if ($row["CID"] != $last_cid)
112                    {
113                            if (count($section_list) > 0)
114                            {
115                                    array_push($result_set["data"]["section_hierachy"], array(
116                                            "cid" => $last_cid,
117                                            "title" => $last_c_title,
118                                            "sections" => $section_list,
119                                    ));
120    
121                                    $section_list = array();
122                            }
123    
124                            $last_cid = $row["CID"];
125                            $last_c_title = $row["c_title"];
126                    }
127    
128                    if ($_SESSION["BBS_priv"]->checkpriv($row["SID"], S_POST | S_MAN_S))
129                    {
130                            array_push($section_list, array(
131                                    "sid" => $row["SID"],
132                                    "title" => $row["s_title"],
133                            ));
134                    }
135            }
136    
137            if (count($section_list) > 0)
138            {
139                    array_push($result_set["data"]["section_hierachy"], array(
140                            "cid" => $last_cid,
141                            "title" => $last_c_title,
142                            "sections" => $section_list,
143                  ));                  ));
144          }          }
145    
146          mysqli_free_result($rs);          mysqli_free_result($rs);
147    
148          mysqli_close($db_conn);          mysqli_close($db_conn);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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