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

Contents of /fenglin/bbs/search_user.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (show annotations)
Mon Apr 14 11:23:46 2025 UTC (11 months ago) by sysadm
Branch: MAIN
Changes since 1.21: +10 -10 lines
Update page layout

1 <?
2 require_once "../lib/db_open.inc.php";
3 require_once "./session_init.inc.php";
4 require_once "./user_level.inc.php";
5 ?>
6 <?
7 $page = (isset($_GET["page"]) ? intval($_GET["page"]) : 1);
8 $rpp = (isset($_GET["rpp"]) ? intval($_GET["rpp"]) : 20);
9
10 $type = (isset($_GET["type"]) ? intval($_GET["type"]) : 0);
11 $online = (isset($_GET["online"]) && $_GET["online"] == "1" ? 1 : 0);
12 $friend = (isset($_GET["friend"]) && $_GET["friend"] == "1" ? 1 : 0);
13 $search_text = (isset($_GET["search_text"]) ? $_GET["search_text"] : "");
14
15 $sql = "SELECT IF(UID = 0, 1, 0) AS is_guest, COUNT(*) AS u_count FROM user_online
16 WHERE last_tm >= SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND)
17 GROUP BY is_guest";
18
19 $rs = mysqli_query($db_conn, $sql);
20 if ($rs == false)
21 {
22 echo("Count online user error" . mysqli_error($db_conn));
23 exit();
24 }
25
26 $guest_online = 0;
27 $user_online = 0;
28
29 while ($row = mysqli_fetch_array($rs))
30 {
31 if ($row["is_guest"])
32 {
33 $guest_online = $row["u_count"];
34 }
35 else
36 {
37 $user_online = $row["u_count"];
38 }
39 }
40 mysqli_free_result($rs);
41
42 $sql = "SELECT COUNT(user_list.UID) AS rec_count FROM user_list" .
43 ($online ? " INNER JOIN user_online ON user_list.UID = user_online.UID" : "") .
44 ($friend ? " INNER JOIN friend_list ON user_list.UID = friend_list.fUID" : "") .
45 ($type == 1 ? " INNER JOIN user_pubinfo ON user_list.UID = user_pubinfo.UID" : "") .
46 " WHERE user_list.enable AND ".
47 ($type == 1 ? "nickname" : "username") .
48 " LIKE '%" . mysqli_real_escape_string($db_conn, $search_text) . "%'" .
49 ($online ? " AND last_tm >= SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND)" : "").
50 ($friend ? " AND friend_list.UID = " . $_SESSION["BBS_uid"] : "");
51
52 $rs = mysqli_query($db_conn, $sql);
53 if ($rs == false)
54 {
55 echo("Query user error" . mysqli_error($db_conn));
56 exit();
57 }
58
59 if ($row = mysqli_fetch_array($rs))
60 {
61 $toa = $row["rec_count"];
62 }
63
64 mysqli_free_result($rs);
65
66 if (!in_array($rpp, $BBS_list_rpp_options))
67 {
68 $rpp = $BBS_list_rpp_options[0];
69 }
70
71 $page_total = ceil($toa / $rpp);
72 if ($page > $page_total)
73 {
74 $page = $page_total;
75 }
76
77 if ($page <= 0)
78 {
79 $page = 1;
80 }
81 ?>
82 <html>
83 <head>
84 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
85 <title>用户查找结果</title>
86 <link rel="stylesheet" href="css/default.css" type="text/css">
87 <style type="text/css">
88 TD.head,TD.level,TD.login_dt,TD.dark,TD.username
89 {
90 border-right: #d0d3F0 1px solid;
91 border-left: #d0d3F0 1px solid;
92 border-bottom: #d0d3F0 1px solid;
93 }
94 TD.head
95 {
96 font-family: 楷体;
97 color: #909090;
98 }
99 TD.login_dt,TD.level,TD.dark,TD.username
100 {
101 text-align: center;
102 }
103 TD.login_dt,TD.dark
104 {
105 color: #909090;
106 background-color: #eaf0Fa;
107 }
108 TD.head,TD.level
109 {
110 background-color: #fafbfc;
111 }
112 TD.level
113 {
114 color: orange;
115 }
116 TD.username
117 {
118 background-color: #fafbfc;
119 }
120 TD.username:hover
121 {
122 background-color: #eaf0Fa;
123 }
124 </style>
125
126 <script type="text/javascript" src="../js/nw_open.js"></script>
127 <script type="text/javascript">
128 function ch_page(page)
129 {
130 document.change_page.page.value = page;
131 document.change_page.submit();
132 return false;
133 }
134
135 function ch_rpp()
136 {
137 document.change_page.page.value = Math.floor((document.change_page.page.value - 1) * <? echo $rpp; ?> / document.change_page.rpp.value) + 1;
138 document.change_page.submit();
139 return false;
140 }
141 </script>
142 </head>
143 <body>
144 <center>
145 <table cols="2" border="0" cellpadding="0" cellspacing="0" width="1050">
146 <tr>
147 <td colspan="2" style="color:green;">
148 <a class="s2" href="main.php"><? echo $BBS_name; ?></a>&gt;&gt;查找<? echo ($online?"在线":""); ?><? echo ($friend?"好友":"用户"); ?>
149 </td>
150 </tr>
151 <tr bgcolor="#d0d3F0" height="2">
152 <td colspan="2"></td></tr>
153 <tr>
154 <td class="dark" width="3%"></td>
155 <td class="head" width="97%">
156 <?
157 if ($toa==0)
158 {
159 ?>未找到指定用户<?
160 }
161 else
162 {
163 ?>用户查找结果(共<? echo $toa; ?>位)
164 <?
165 }
166 ?>(当前在线注册用户<? echo $user_online; ?>位,游客<? echo $guest_online; ?>位)
167 </td>
168 </tr>
169 </table>
170 <table border="0" cellpadding="1" cellspacing="0" width="1050">
171 <tr height="10">
172 <td>
173 </td>
174 </tr>
175 </table>
176 <table bgcolor="#f0F3Fa" border="0" cellpadding="0" cellspacing="0" width="1050">
177 <tr bgcolor="#d0d3F0" height="20">
178 <td class="title" width="4%"></td>
179 <td class="title" width="15%">用户ID</td>
180 <td class="title" width="20%">昵称</td>
181 <td class="title" width="12%">等级</td>
182 <td class="title" width="18%">最后登陆时间</td>
183 <td class="title" width="27%"></td>
184 <td class="title" width="4%"></td>
185 </tr>
186 <?
187 $sql = "SELECT user_list.UID, username, nickname, exp, gender, gender_pub, last_login_dt FROM user_list" .
188 ($online ? " INNER JOIN user_online ON user_list.UID = user_online.UID" : "") .
189 ($friend ? " INNER JOIN friend_list ON user_list.UID = friend_list.fUID" : "") .
190 " INNER JOIN user_pubinfo ON user_list.UID = user_pubinfo.UID WHERE user_list.enable AND ".
191 ($type == 1 ? "nickname" : "username") .
192 " LIKE '%" . mysqli_real_escape_string($db_conn, $search_text) . "%'" .
193 ($online ? " AND last_tm >= SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND)" : "").
194 ($friend ? " AND friend_list.UID = " . $_SESSION["BBS_uid"] : "") .
195 " ORDER BY " . ($type == 1 ? "nickname" : "username") .
196 " LIMIT " . ($page-1) * $rpp . ", $rpp";
197
198 $rs = mysqli_query($db_conn, $sql);
199 if ($rs == false)
200 {
201 echo("Query user error" . mysqli_error($db_conn));
202 exit();
203 }
204
205 while ($row = mysqli_fetch_array($rs))
206 {
207 ?>
208 <tr height="25">
209 <td class="dark">
210 <?
211 if ($row["gender_pub"])
212 {
213 if ($row["gender"] == 'M')
214 {
215 echo ("<font color=blue>♂</font>");
216 }
217 else
218 {
219 echo ("<font color=red>♀</font>");
220 }
221 }
222 else
223 {
224 echo ("<font color=green>?</font>");
225 }
226 ?>
227 </td>
228 <td class="username">
229 <a class="s2" href="show_profile.php?uid=<? echo $row["UID"]; ?>" target=_blank><? echo $row["username"]; ?></a>
230 </td>
231 <td class="dark">
232 <? echo $row["nickname"]; ?>
233 </td>
234 <td class="level">
235 <? echo user_level($row["exp"]); ?>
236 </td>
237 <td class="login_dt">
238 <? echo (new DateTimeImmutable($row["last_login_dt"]))->setTimezone($_SESSION["BBS_user_tz"])->format("Y-m-d H:i:s"); ?>
239 </td>
240 <td class="level">
241 <?
242 if ($_SESSION["BBS_priv"]->checkpriv(0, S_MSG))
243 {
244 ?>
245 <a class="s2" href="" onclick="return NW_open('send_msg.php?uid=<? echo $row["UID"]; ?>', 'send_msg', 500, 300);">发送消息</a>
246 <?
247 }
248 ?>
249 </td>
250 <td align="center">
251 </td>
252 </tr>
253 <?
254 }
255
256 mysqli_free_result($rs);
257 ?>
258 </table>
259 <table cols="3" border="0" cellpadding="5" cellspacing="0" width="1050">
260 <tr bgcolor="#d0d3F0" height="10">
261 <td colspan="3" >
262 </td>
263 </tr>
264 <tr height="10">
265 <td colspan="3" >
266 </td>
267 </tr>
268 <tr>
269 <form action="search_user.php" method="get" id="change_page" name="change_page">
270 <td width="30%" style="color:#909090">
271 每页<select size="1" id="rpp" name="rpp" onchange="ch_rpp();">
272 <?
273 foreach ($BBS_list_rpp_options as $v)
274 {
275 echo ("<option value=\"$v\"" . ($v == $rpp ? " selected" : "") . ">$v</option>");
276 }
277 ?>
278 </select>人
279 <?
280 if ($page > 1)
281 {
282 ?>
283 <a class="s8" title="首页" href="" onclick="return ch_page(1);">|◀</a>
284 <a class="s8" title="上一页" href="" onclick="return ch_page(<? echo ($page - 1); ?>);">◀</a>
285 <?
286 }
287 else
288 {
289 ?>
290 |◀ ◀
291 <?
292 }
293 ?>
294 第<input id="page" name="page" value="<? echo ($page) ; ?>" style="width: 30px;">/<? echo $page_total; ?>页
295 <?
296 if ($page < $page_total)
297 {
298 ?>
299 <a class="s8" title="下一页" href="" onclick="return ch_page(<? echo ($page + 1); ?>);">▶</a>
300 <a class="s8" title="尾页" href="" onclick="return ch_page(<? echo ($page_total); ?>);">▶|</a>
301 <?
302 }
303 else
304 {
305 ?>
306 ▶ ▶|
307 <?
308 }
309 ?>
310 </td>
311 <td width="50%">
312 <select name="type">
313 <option value="0" <? if ($type==0) echo "selected"; ?> >按用户名</option>
314 <option value="1" <? if ($type==1) echo "selected"; ?> >按昵称</option>
315 </select>
316 <input type="text" id="search_text" name="search_text" size="15" value="<? echo $search_text;?>">
317 <input type="checkbox" id="online" name="online" value="1" <? echo ($online ? "checked" : "");?>><font color=#909090>在线</font>
318 <input type="checkbox" id="friend" name="friend" value="1" <? echo ($friend ? "checked" : "");?>><font color=#909090>好友</font>
319 <input type=image src="images/search.gif" alt="查找用户" border="0" name="image"></a>
320 </td>
321 <td width="10%">
322 </td>
323 </form>
324 </tr>
325 </table>
326 </center>
327 <?
328 mysqli_close($db_conn);
329
330 include "./foot.inc.php";
331 ?>
332 </body>
333 </html>

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