--- fenglin/bbs/search_user.php 2025/03/09 07:30:10 1.8 +++ fenglin/bbs/search_user.php 2025/04/06 08:16:26 1.21 @@ -1,91 +1,89 @@ -= SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND) + GROUP BY is_guest"; -if (isset($_GET["type"])) - $type=intval($_GET["type"]); -else - $type=2; +$rs = mysqli_query($db_conn, $sql); +if ($rs == false) +{ + echo("Count online user error" . mysqli_error($db_conn)); + exit(); +} -if (isset($_GET["online"])) - $online=($_GET["online"]=="on"); -else - $online=0; +$guest_online = 0; +$user_online = 0; -if (isset($_GET["friend"])) - $friend=($_GET["friend"]=="on"); -else - $friend=0; +while ($row = mysqli_fetch_array($rs)) +{ + if ($row["is_guest"]) + { + $guest_online = $row["u_count"]; + } + else + { + $user_online = $row["u_count"]; + } +} +mysqli_free_result($rs); -if (isset($_GET["search_text"])) - $search_text=trim($_GET["search_text"]); -else - $search_text=""; -$search_author=addslashes(stripslashes($search_text)); +$sql = "SELECT COUNT(user_list.UID) AS rec_count FROM user_list" . + ($online ? " INNER JOIN user_online ON user_list.UID = user_online.UID" : "") . + ($friend ? " INNER JOIN friend_list ON user_list.UID = friend_list.fUID" : "") . + ($type == 1 ? " INNER JOIN user_pubinfo ON user_list.UID = user_pubinfo.UID" : "") . + " WHERE user_list.enable AND ". + ($type == 1 ? "nickname" : "username") . + " LIKE '%" . mysqli_real_escape_string($db_conn, $search_text) . "%'" . + ($online ? " AND last_tm >= SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND)" : ""). + ($friend ? " AND friend_list.UID = " . $_SESSION["BBS_uid"] : ""); -$db_conn=include "./db_open.inc.php"; +$rs = mysqli_query($db_conn, $sql); +if ($rs == false) +{ + echo("Query user error" . mysqli_error($db_conn)); + exit(); +} -$rs=mysql_query("select user_online.SID from user_online". - " where UID=0 and current_action not in". - " ('max_user_limit','max_ip_limit','max_session_limit','exit')". - " group by SID") - or die("Count guest error!"); -$guest_count=mysql_num_rows($rs); -mysql_free_result($rs); - -$rs=mysql_query("select user_online.SID from user_online". - " where UID<>0 and current_action not in". - " ('max_user_limit','max_ip_limit','max_session_limit','exit')". - " group by SID") - or die("Count user error!"); -$user_count=mysql_num_rows($rs); -mysql_free_result($rs); - -$rs=mysql_query("select count(user_list.UID) as rec_count from user_list". - ($online?" inner join user_online on user_list.UID=user_online.UID":""). - ($friend?" inner join friend_list on user_list.UID=friend_list.fUID":""). - " inner join user_pubinfo on user_list.UID=user_pubinfo.UID where". - " user_list.enable and ".($type==1?"user_pubinfo.nickname":"user_list.username"). - " like '%$search_author%'". - ($online ? " and current_action not in". - " ('max_user_limit','max_ip_limit','max_session_limit','exit')":""). - ($friend ? " and friend_list.UID=".$_SESSION["BBS_uid"]:"") - ) - or die("Query user error!"); +if ($row = mysqli_fetch_array($rs)) +{ + $toa = $row["rec_count"]; +} -$row=mysql_fetch_array($rs); -$u_count=$row["rec_count"]; +mysqli_free_result($rs); -mysql_free_result($rs); +if (!in_array($rpp, $BBS_list_rpp_options)) +{ + $rpp = $BBS_list_rpp_options[0]; +} -$toa=$u_count; -if ($toa==0) - $toa=1; +$page_total = ceil($toa / $rpp); +if ($page > $page_total) +{ + $page = $page_total; +} -$page_total=intval($toa/$page_max_record); -if (($toa % $page_max_record)>0) - $page_total++; -if ($page>$page_total) - $page=$page_total; +if ($page <= 0) +{ + $page = 1; +} ?> 用户查找结果 - - + +
@@ -132,14 +153,17 @@ TD.level - - 未找到指定用户未找到指定用户用户查找结果(共位) - (当前在线注册用户位,游客位) +?>用户查找结果(共位) +(当前在线注册用户位,游客位) @@ -159,29 +183,27 @@ TD.level - = SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND)" : ""). + ($friend ? " AND friend_list.UID = " . $_SESSION["BBS_uid"] : "") . + " ORDER BY " . ($type == 1 ? "nickname" : "username") . + " LIMIT " . ($page-1) * $rpp . ", $rpp"; + +$rs = mysqli_query($db_conn, $sql); +if ($rs == false) +{ + echo("Query user error" . mysqli_error($db_conn)); + exit(); +} -while($row=mysql_fetch_array($rs)) +while ($row = mysqli_fetch_array($rs)) { - $color_index=($color_index+1)%$color_count; ?> @@ -189,9 +211,13 @@ while($row=mysql_fetch_array($rs)) if ($row["gender_pub"]) { if ($row["gender"] == 'M') + { echo (""); + } else + { echo (""); + } } else { @@ -199,8 +225,8 @@ while($row=mysql_fetch_array($rs)) } ?> - - )"> + + " target=_blank> @@ -209,23 +235,27 @@ while($row=mysql_fetch_array($rs)) - + setTimezone($_SESSION["BBS_user_tz"])->format("Y-m-d H:i:s"); ?> - ','send_msg',500,300)">发送消息 - ','send_msg',500,300)">发送邮件 +checkpriv(0, S_MSG)) + { +?> + ', 'send_msg', 500, 300);">发送消息 + - - - + - +
@@ -236,48 +266,68 @@ mysql_close($db_conn);
-
- - "> - "> - 分页: /页 -1) -{ -?>&friend=">9&friend=">797 - -&friend=">8&friend=">:8: -
-
- +
+
+ 每页人 + 1) +{ +?> + 9 + 7 + +9 7 + + 第/页 + + 8 + : + +8 : + + + + + >在线 + >好友 + +
-