/[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.13 - (show annotations)
Fri Mar 28 10:32:21 2025 UTC (11 months, 2 weeks ago) by sysadm
Branch: MAIN
Changes since 1.12: +180 -131 lines
Refact

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

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