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

Contents of /fenglin/bbs/list.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Fri Apr 11 12:51:13 2025 UTC (11 months ago) by sysadm
Branch: MAIN
Rename bbs.php to list.php

1 <?
2 require_once "../lib/db_open.inc.php";
3 require_once "../lib/lml.inc.php";
4 require_once "../lib/str_process.inc.php";
5 require_once "./session_init.inc.php";
6 require_once "./message.inc.php";
7 ?>
8 <?
9 $redir = $_SERVER["SCRIPT_NAME"] .
10 (isset($_SERVER["QUERY_STRING"]) ? "?" . urlencode($_SERVER["QUERY_STRING"]) : "");
11
12 $sid = (isset($_GET["sid"]) ? intval($_GET["sid"]) : $BBS_default_sid);
13 $ex = (isset($_GET["ex"]) && $_GET["ex"] == "1" ? 1 : 0);
14 $reply = (isset($_GET["reply"]) && $_GET["reply"] == "1" ? 1 : 0);
15 $use_nick = (isset($_GET["use_nick"]) && $_GET["use_nick"] == "0" ? 0 : 1);
16 $sort = (isset($_GET["sort"]) ? $_GET["sort"] : "topic");
17 $search_text = (isset($_GET["search_text"]) ? $_GET["search_text"] : "");
18 $page = (isset($_GET["page"]) ? intval($_GET["page"]) : 1);
19 $rpp = (isset($_GET["rpp"]) ? intval($_GET["rpp"]) : 20);
20
21 if (!$_SESSION["BBS_priv"]->checkpriv($sid, S_LIST))
22 {
23 force_login();
24
25 echo ("您无权访问该版块!");
26 exit();
27 }
28
29 switch($sort)
30 {
31 case "topic":
32 $sort_sql = "sub_dt DESC"; //sub_dt
33 break;
34 case "reply":
35 $sort_sql = "last_reply_dt DESC";
36 break;
37 case "hot":
38 $sort_sql = "(view_count + reply_count) DESC";
39 break;
40 default:
41 echo ("不支持的排序方式!");
42 exit();
43 }
44
45 $sql = "SELECT section_config.sname, section_config.title AS s_title,
46 section_config.announcement, section_class.title AS c_title, section_class.cname
47 FROM section_config INNER JOIN section_class ON section_config.CID = section_class.CID
48 WHERE section_config.SID = $sid AND section_config.enable AND section_class.enable";
49
50 $rs = mysqli_query($db_conn, $sql);
51 if ($rs == false)
52 {
53 echo("数据查询错误:" . mysqli_error($db_conn));
54 exit();
55 }
56
57 if($row = mysqli_fetch_array($rs))
58 {
59 $class_title = $row["c_title"];
60 $class_name = $row["cname"];
61 $section_name = $row["sname"];
62 $section_title = $row["s_title"];
63 $announcement = $row["announcement"];
64 }
65 else
66 {
67 echo("版块不存在!");
68 exit();
69 }
70
71 mysqli_free_result($rs);
72
73 $search_topic = mysqli_real_escape_string($db_conn, $search_text);
74
75 $sql = "SELECT count(*) AS article_count FROM bbs WHERE SID = $sid AND visible AND " .
76 ($reply ? "" : " TID = 0 AND ") .
77 ($ex ? " excerption AND " : "") .
78 " title LIKE '%" . $search_topic . "%'";
79
80 $rs = mysqli_query($db_conn, $sql);
81 if ($rs == false)
82 {
83 echo("数据查询错误:" . mysqli_error($db_conn));
84 exit();
85 }
86
87 $toa = 0;
88 if ($row = mysqli_fetch_array($rs))
89 {
90 $toa = $row["article_count"];
91 }
92
93 mysqli_free_result($rs);
94
95 if (!in_array($rpp, $BBS_list_rpp_options))
96 {
97 $rpp = $BBS_list_rpp_options[0];
98 }
99
100 $page_total = ceil($toa / $rpp);
101 if ($page > $page_total)
102 {
103 $page = $page_total;
104 }
105
106 if ($page <= 0)
107 {
108 $page = 1;
109 }
110
111 if ($_SESSION["BBS_uid"] > 0 && time() - $_SESSION["BBS_last_msg_check"] >= $BBS_check_msg_interval)
112 {
113 $_SESSION["BBS_new_msg"] = check_new_msg($_SESSION["BBS_uid"], $db_conn);
114 $_SESSION["BBS_last_msg_check"] = time();
115 }
116 ?>
117 <html>
118 <head>
119 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
120 <title><? echo $section_title . "——" . ($ex ? "文摘区" : "讨论区"); ?></title>
121 <link rel="stylesheet" href="css/default.css" type="text/css">
122 <style type="text/css">
123 TD.head,TD.favor,TD.reply,TD.dark,TD.topic
124 {
125 border-right: #d0d3F0 1px solid;
126 border-left: #d0d3F0 1px solid;
127 border-bottom: #d0d3F0 1px solid;
128 }
129 TD.head
130 {
131 font-family: 楷体;
132 color: blue;
133 }
134 TD.favor,TD.dark
135 {
136 text-align: center;
137 }
138 TD.reply,TD.dark
139 {
140 color: #909090;
141 background-color: #eaf0Fa;
142 }
143 TD.head,TD.favor
144 {
145 background-color: #fafbfc;
146 }
147 TD.favor
148 {
149 color: #c0c3f0;
150 font-weight: bold;
151 }
152 TD.topic
153 {
154 background-color: #fafbfc;
155 }
156 TD.topic:hover
157 {
158 background-color: #eaf0Fa;
159 }
160 </style>
161
162 <script type="text/javascript" src="../js/nw_open.js"></script>
163 <script type="text/javascript" src="../js/bbs_article.js"></script>
164 <script type="text/javascript">
165 function ch_page(page)
166 {
167 document.change_page.page.value = page;
168 document.change_page.submit();
169 return false;
170 }
171
172 function ch_rpp()
173 {
174 document.change_page.page.value = Math.floor((document.change_page.page.value - 1) * <? echo $rpp; ?> / document.change_page.rpp.value) + 1;
175 document.change_page.submit();
176 return false;
177 }
178
179 function ch_sect(sid)
180 {
181 if (sid > 0)
182 {
183 document.change_page.sid.value = sid;
184 document.change_page.page.value = 1;
185 document.change_page.submit();
186 }
187 return false;
188 }
189
190 function ch_ex(ex)
191 {
192 document.change_page.ex.value = ex;
193 document.change_page.submit();
194 return false;
195 }
196
197 function ch_reply(reply)
198 {
199 document.change_page.reply.value = reply;
200 document.change_page.submit();
201 return false;
202 }
203
204 function use_nick(use)
205 {
206 document.change_page.use_nick.value = use;
207 document.change_page.submit();
208 return false;
209 }
210
211 function ch_sort(type)
212 {
213 document.change_page.sort.value = type;
214 document.change_page.submit();
215 return false;
216 }
217
218 window.addEventListener("load", () => {
219 var s = document.change_section.sid;
220 for (i = 0; i < s.options.length; i++)
221 {
222 if (s.options[i].value == <? echo $sid; ?>)
223 {
224 s.selectedIndex = i;
225 break;
226 }
227 }
228 });
229
230 </script>
231 </head>
232 <body>
233 <center>
234 <table cols="2" border="0" cellpadding="0" cellspacing="0" width="770">
235 <tr>
236 <td width="60%" style="color: green;">
237 <a class="s2" href="main.php?sid=<? echo $sid; ?>"><? echo $BBS_name; ?></a>&gt;&gt;<? echo ($class_title . "[" . $class_name . "]"); ?>&gt;&gt;<? echo ($section_title."[".$section_name."]"); ?>&gt;&gt;<? echo ($ex ? "文摘区" : "讨论区"); ?>
238 </td>
239 <td width="40%" align="right" style="color: gray;">
240 <?
241 if ($_SESSION["BBS_uid"] == 0)
242 {
243 ?>
244 [<a class="s2" href="index.php?redir=<? echo $redir; ?>">登录</a>]
245 <?
246 }
247 else
248 {
249 if ($_SESSION["BBS_new_msg"] > 0)
250 {
251 ?>
252 [<a class="s6" href="read_msg.php" target=_blank><? echo $_SESSION["BBS_new_msg"]; ?>条新消息</a>]
253 <?
254 }
255 ?>
256 欢迎回来&nbsp;<font color=blue><? echo ($_SESSION["BBS_username"]); ?></font>
257 [<a class="s6" href="logout.php">退出</a>]
258 <?
259 }
260 ?>
261 </td>
262 </tr>
263 </table>
264 <table cols="2" border="0" cellpadding="0" cellspacing="0" width="770">
265 <tr bgcolor="#d0d3F0" height="2">
266 <td colspan="2"></td>
267 </tr>
268 <tr>
269 <td class="dark" width="3%"><img src="images/master.gif" width="16" height="16" alt="本版版主"></td>
270 <td class="head" width="97%">
271 <?
272 $sql = "SELECT user_list.UID, user_list.username, section_master.major FROM section_master
273 INNER JOIN user_list ON section_master.UID = user_list.UID
274 WHERE SID = $sid AND section_master.enable AND (NOW() BETWEEN begin_dt AND end_dt)
275 ORDER BY major DESC";
276
277 $rs = mysqli_query($db_conn, $sql);
278 if ($rs == false)
279 {
280 echo "版主数据查询错误:" . mysqli_error($db_conn);
281 exit();
282 }
283
284 while($row = mysqli_fetch_array($rs))
285 {
286 ?>
287 <img src="images/<? echo ($row["major"] ? "master_major.gif" : "master_minor.gif"); ?>" width="12" height="11" alt="<? echo ($row["major"] ? "正版主" : "副版主"); ?>"><a class="s3" href="show_profile.php?uid=<? echo $row['UID']; ?>" target=_blank title="查看版主资料"><? echo $row["username"]; ?></a>&nbsp;&nbsp;
288 <?
289 }
290
291 mysqli_free_result($rs);
292 ?>
293 </td>
294 </tr>
295 <?
296 if ($announcement != "")
297 {
298 ?>
299 <tr>
300 <td class="dark"><img src="images/announce.gif" width="18" height="18" alt="本版公告"></td>
301 <td class="head">
302 <?
303 echo (LML(htmlspecialchars($announcement, ENT_HTML401, 'UTF-8'), true));
304 ?>
305 </td>
306 </tr>
307 <?
308 }
309 ?>
310 <tr>
311 <td class="dark"></td>
312 <td class="head" align="right">
313 <?
314 if ($_SESSION["BBS_priv"]->checkpriv($sid, S_POST))
315 {
316 ?>
317 <a class="s4" href="post.php?sid=<? echo $sid; ?>" title="发表新文章">发帖</a>&nbsp;
318 <?
319 }
320 ?>
321 <a class="s4" href="" onclick="return ch_ex(<? echo ($ex ? 0 : 1); ?>);" title="切换"><? echo ($ex ? "讨论区" : "文摘区"); ?></a>&nbsp;
322 <a class="s4" href="/gen_ex/<? echo $sid; ?>/" title="浏览本版块精华区" target=_blank>精华区</a>&nbsp;
323 <a class="s4" href="" onclick="return ch_reply(<? echo ($reply ? 0 : 1); ?>);" title="切换文章显示模式"><? echo ($reply ? "主题" : "普通"); ?></a>&nbsp;
324 </td>
325 </tr>
326 <tr height="10">
327 <td colspan="2"></td>
328 </tr>
329 </table>
330 <table cols="5" border="0" cellpadding="0" cellspacing="0" width="770">
331 <tr bgcolor="#d0d3F0" height="20">
332 <td width="4%" class="title">状态</td>
333 <td width="39%" class="title"><a class="s10" href="" onclick="return ch_sort('topic');" title="按主题发表时间排序">标题</a></td>
334 <td width="16%" class="title"><a class="s10" href="" onclick="return use_nick(<? echo ($use_nick ? 0 : 1); ?>);" title="切换用户显示模式">作者</a></td>
335 <td width="10%" class="title"><a class="s10" href="" onclick="return ch_sort('hot');" title="按人气回复排序">回复/人气</a></td>
336 <td width="31%" class="title"><a class="s10" href="" onclick="return ch_sort('reply');" title="按最后回复时间排序">最后更新 | 回复人</a></td>
337 </tr>
338 </table>
339 <div id="article_list"></div>
340 <?
341 $sql = "SELECT * FROM bbs WHERE SID = $sid AND visible AND ".
342 ($reply ? "" : " TID = 0 AND ") .
343 ($ex ? " excerption AND " : "") .
344 " title LIKE '%" . $search_topic . "%'".
345 " ORDER BY ontop DESC, ".
346 ($reply ? "sub_dt DESC" : $sort_sql).
347 " LIMIT " . (($page - 1) * $rpp) . ", $rpp";
348
349 $rs = mysqli_query($db_conn, $sql);
350 if ($rs == false)
351 {
352 echo "文章列表查询错误:" . mysqli_error($db_conn);
353 exit();
354 }
355
356 echo ("<script language=\"JavaScript\">\n");
357
358 $visited_aid_list = array();
359
360 if ($_SESSION["BBS_uid"] > 0)
361 {
362 $aid_list = "-1";
363
364 while ($row = mysqli_fetch_array($rs))
365 {
366 if ((new DateTimeImmutable("-" . $BBS_new_article_period . " day")) < (new DateTimeImmutable($row["sub_dt"])))
367 {
368 $aid_list .= (", " . $row["AID"]);
369 }
370 else
371 {
372 array_push($visited_aid_list, $row["AID"]);
373 }
374 }
375
376 mysqli_data_seek($rs, 0);
377
378 if ($aid_list != "-1")
379 {
380 $sql = "SELECT AID FROM view_article_log WHERE AID IN ($aid_list) AND UID = " . $_SESSION["BBS_uid"];
381
382 $rs_view = mysqli_query($db_conn, $sql);
383 if ($rs_view == false)
384 {
385 echo "文章查看记录查询错误:" . mysqli_error($db_conn);
386 exit();
387 }
388
389 while ($row_view = mysqli_fetch_array($rs_view))
390 {
391 array_push($visited_aid_list, $row_view["AID"]);
392 }
393
394 mysqli_free_result($rs_view);
395 }
396 }
397
398 while ($row = mysqli_fetch_array($rs))
399 {
400 $length = $row["length"];
401 $sub_dt = (new DateTimeImmutable($row["sub_dt"]))->setTimezone($_SESSION["BBS_user_tz"])->format("Y-m-d H:i");
402 $last_reply_dt = (new DateTimeImmutable($row["last_reply_dt"]))->setTimezone($_SESSION["BBS_user_tz"])->format("Y-m-d H:i");
403 $visited = (($_SESSION["BBS_uid"] > 0 && in_array($row["AID"], $visited_aid_list)) ? 1 : 0);
404 $status = ($row["ontop"] ? "B" : ($row["gen_ex"] ? "G" : ($row["excerption"] ? "M" : ($row["reply_count"] < 10 ? "N" : "H"))));
405 $status = ($visited ? strtolower($status) : strtoupper($status));
406
407 echo ("show_article(" .
408 $row["TID"] . ", " . //tid
409 $row["AID"] . ", " . //aid
410 "'" . split_line(htmlspecialchars($row["title"], ENT_QUOTES | ENT_HTML401, 'UTF-8'), "", 42, 2, "<br />") . "', " . //title
411 "$ex, " . //ex
412 "'$status', " . //status
413 "'" . $sub_dt . "', " . //sub_dt
414 "'$length', " . //length
415 $row["icon"] . ", " . //icon
416 $row["UID"] . ", " . //uid
417 "'" . htmlspecialchars($row["username"], ENT_QUOTES | ENT_HTML401, 'UTF-8') . "', " . //username
418 "'" . htmlspecialchars($row["nickname"], ENT_QUOTES | ENT_HTML401, 'UTF-8') . "', " . //nickname
419 $row["reply_count"] . ", " . //reply_count
420 $row["view_count"] . ", " . //view_count
421 $row["transship"] . ", " . //transship
422 $row["lock"] . ", " . //lock
423 "'" . $last_reply_dt . "', " . //last_reply_dt
424 $row["last_reply_UID"] . ", " . //last_reply_uid
425 "'" . htmlspecialchars($row["last_reply_username"], ENT_QUOTES | ENT_HTML401, 'UTF-8') . "', " . //last_reply_username
426 "'" . htmlspecialchars($row["last_reply_nickname"], ENT_QUOTES | ENT_HTML401, 'UTF-8') . "', " . //last_reply_nickname
427 "0, " . //visible_mode
428 $use_nick . //use_nick
429 ");\n");
430 }
431
432 mysqli_free_result($rs);
433
434 echo ("</script>\n");
435 ?>
436 <table cols="3" border="0" cellpadding="0" cellspacing="0" width="770">
437 <tr bgcolor="#d0d3F0" height="5">
438 <td colspan="3"></td></tr>
439 <tr height="10">
440 <td colspan="3"></td></tr>
441 <tr valign="top">
442 <form action="bbs.php" method="get" id="change_page" name="change_page">
443 <td width="40%" style="color:#909090">
444 <input type="hidden" id="sid" name="sid" value="<? echo $sid; ?>">
445 <input type="hidden" id="reply" name="reply" value="<? echo $reply; ?>">
446 <input type="hidden" id="ex" name="ex" value="<? echo $ex; ?>">
447 <input type="hidden" id="use_nick" name="use_nick" value="<? echo $use_nick; ?>">
448 <input type="hidden" id="sort" name="sort" value="<? echo $sort; ?>">
449 每页<select size="1" id="rpp" name="rpp" onchange="ch_rpp();">
450 <?
451 foreach ($BBS_list_rpp_options as $v)
452 {
453 echo ("<option value=\"$v\"" . ($v == $rpp ? " selected" : "") . ">$v</option>");
454 }
455 ?>
456 </select>篇
457 <?
458 if ($page > 1)
459 {
460 ?>
461 <a class="s8" title="首页" href="" onclick="return ch_page(1);"><font face=webdings>9</font></a>
462 <a class="s8" title="上一页" href="" onclick="return ch_page(<? echo ($page - 1); ?>);"><font face=webdings>7</font></a>
463 <?
464 }
465 else
466 {
467 ?>
468 <font face=webdings>9 7</font>
469 <?
470 }
471 ?>
472 第<input id="page" name="page" value="<? echo ($page) ; ?>" style="width: 30px;">/<? echo $page_total; ?>页
473 <?
474 if ($page < $page_total)
475 {
476 ?>
477 <a class="s8" title="下一页" href="" onclick="return ch_page(<? echo ($page + 1); ?>);"><font face=webdings>8</font></a>
478 <a class="s8" title="尾页" href="" onclick="return ch_page(<? echo ($page_total); ?>);"><font face=webdings>:</font></a>
479 <?
480 }
481 else
482 {
483 ?>
484 <font face=webdings>8 :</font>
485 <?
486 }
487 ?>
488 </td>
489 <td width="35%">
490 <font color=#909090>查找文章</font>
491 <input type="text" id="search_text" name="search_text" value="<? echo $search_text;?>" size="15"> <input type=image src="images/search.gif" alt="按主题内容查找文章" border="0"></a>
492 <a class="s8" href="search_form.php?sid=<? echo $sid; ?>" target=_blank title="全功能检索">高级</a>&nbsp;
493 </td>
494 </form>
495 <td width="25%" align="right">
496 <form action="" method="get" id="change_section" name="change_section">
497 <select size="1" id="sid" name="sid" onchange="ch_sect(this.value);">
498 <?
499 include "section_list_gen.inc.php";
500 ?>
501 </select>
502 </form>
503 </td>
504 </tr>
505 </table>
506 </center>
507 <?
508 mysqli_close($db_conn);
509 ?>
510 <?
511 include "./foot.inc.php";
512 ?>
513 </body>
514 </html>

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