--- fenglin/bbs/list.php 2025/04/12 05:02:55 1.3 +++ fenglin/bbs/list.php 2025/10/01 12:40:03 1.10 @@ -1,4 +1,4 @@ -checkpriv($sid, S_LIST)) { force_login(); @@ -107,11 +112,6 @@ } mysqli_free_result($rs); - if (!in_array($rpp, $BBS_list_rpp_options)) - { - $rpp = $BBS_list_rpp_options[0]; - } - $page_total = ceil($toa / $rpp); if ($page > $page_total) { @@ -179,7 +179,7 @@ "username" => $row["username"], "major" => $row["major"], )); - } + } mysqli_free_result($rs); // Query articles @@ -218,7 +218,7 @@ array_push($visited_aid_list, $row["AID"]); } } - + mysqli_data_seek($rs, 0); if ($aid_list != "-1") @@ -230,26 +230,43 @@ { $result_set["return"]["code"] = -2; $result_set["return"]["message"] = "Query view_article_log error: " . mysqli_error($db_conn); - + mysqli_close($db_conn); exit(json_encode($result_set)); } - + while ($row_view = mysqli_fetch_array($rs_view)) { array_push($visited_aid_list, $row_view["AID"]); } - + mysqli_free_result($rs_view); } } + $author_list = array(); + while ($row = mysqli_fetch_array($rs)) { + // Rewrite title with "Re: Re: " prefix into "Re: ... " + $title = $row["title"]; + if ($row["TID"] != 0) + { + $j = 0; + while (substr_compare($row["title"], "Re: ", $j, strlen("Re: ")) == 0) + { + $j += strlen("Re: "); + } + if ($j >= strlen("Re: Re: ")) + { + $title = "Re: ... " . substr($row["title"], $j); + } + } + array_push($result_set["data"]["articles"], array( "aid" => $row["AID"], "tid" => $row["TID"], - "title" => $row["title"], + "title" => $title, "sub_dt" => (new DateTimeImmutable($row["sub_dt"]))->setTimezone($_SESSION["BBS_user_tz"]), "length" => $row["length"], "icon" => $row["icon"], @@ -267,11 +284,52 @@ "last_reply_uid" => $row["last_reply_UID"], "last_reply_username" => $row["last_reply_username"], "last_reply_nickname" => $row["last_reply_nickname"], - "visited" => (($_SESSION["BBS_uid"] > 0 && in_array($row["AID"], $visited_aid_list)) ? 1 : 0), + "visited" => (($_SESSION["BBS_uid"] > 0 && ($row["UID"] == $_SESSION["BBS_uid"] || in_array($row["AID"], $visited_aid_list))) ? 1 : 0), )); + + if (!isset($author_list[$row["UID"]])) + { + $author_list[$row["UID"]] = true; + } + if (!isset($author_list[$row["last_reply_UID"]])) + { + $author_list[$row["last_reply_UID"]] = true; + } + + unset($title); + } + mysqli_free_result($rs); + + $uid_list = "-1"; + foreach ($author_list as $uid => $status) + { + $uid_list .= (", " . $uid); + } + unset($author_list); + + $author_list = array(); + + $sql = "SELECT UID FROM user_list WHERE UID IN ($uid_list) AND enable"; + + $rs = mysqli_query($db_conn, $sql); + if ($rs == false) + { + $result_set["return"]["code"] = -2; + $result_set["return"]["message"] = "Query user list error: " . mysqli_error($db_conn); + + mysqli_close($db_conn); + exit(json_encode($result_set)); + } + + while ($row = mysqli_fetch_array($rs)) + { + $author_list[$row["UID"]] = true; } mysqli_free_result($rs); + $result_set["data"]["author_list"] = $author_list; + unset($author_list); + mysqli_close($db_conn); // Cleanup @@ -302,4 +360,3 @@ exit(json_encode($result_set)); // Output data in Json } include $theme_view_file; -?>