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

Diff of /fenglin/bbs/search_user.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.20 by sysadm, Sun Apr 6 03:46:57 2025 UTC Revision 1.25 by sysadm, Wed Apr 23 05:13:56 2025 UTC
# Line 1  Line 1 
1  <?  <?php
2          require_once "../lib/db_open.inc.php";          require_once "../lib/db_open.inc.php";
3          require_once "./session_init.inc.php";          require_once "./session_init.inc.php";
4          require_once "./user_level.inc.php";          require_once "./user_level.inc.php";
5  ?>          require_once "./theme.inc.php";
6  <?  
7  $page = (isset($_GET["page"]) ? intval($_GET["page"]) : 1);          $result_set = array(
8  $rpp = (isset($_GET["rpp"]) ? intval($_GET["rpp"]) : 20);                  "return" => array(
9                            "code" => 0,
10  $type = (isset($_GET["type"]) ? intval($_GET["type"]) : 0);                          "message" => "",
11  $online = (isset($_GET["online"]) && $_GET["online"] == "1" ? 1 : 0);                          "errorFields" => array(),
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          $page = (isset($_GET["page"]) ? intval($_GET["page"]) : 1);
16                  WHERE last_tm >= SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND)          $rpp = (isset($_GET["rpp"]) ? intval($_GET["rpp"]) : 20);
17                  GROUP BY is_guest";  
18            $type = (isset($_GET["type"]) ? intval($_GET["type"]) : 0);
19  $rs = mysqli_query($db_conn, $sql);          $online = (isset($_GET["online"]) && $_GET["online"] == "1" ? 1 : 0);
20  if ($rs == false)          $friend = (isset($_GET["friend"]) && $_GET["friend"] == "1" ? 1 : 0);
21  {          $search_text = (isset($_GET["search_text"]) ? $_GET["search_text"] : "");
22          echo("Count online user error" . mysqli_error($db_conn));  
23          exit();          $sql = "SELECT IF(UID = 0, 1, 0) AS is_guest, COUNT(*) AS u_count FROM user_online
24  }                          WHERE last_tm >= SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND)
25                            GROUP BY is_guest";
26  $guest_online = 0;  
27  $user_online = 0;          $rs = mysqli_query($db_conn, $sql);
28            if ($rs == false)
 while ($row = mysqli_fetch_array($rs))  
 {  
         if ($row["is_guest"])  
         {  
                 $guest_online = $row["u_count"];  
         }  
         else  
29          {          {
30                  $user_online = $row["u_count"];                  echo("Count online user error" . mysqli_error($db_conn));
31                    exit();
32          }          }
 }  
 mysqli_free_result($rs);  
33    
34  $sql = "SELECT COUNT(user_list.UID) AS rec_count FROM user_list" .          $guest_online = 0;
35                  ($online ? " INNER JOIN user_online ON user_list.UID = user_online.UID" : "") .          $user_online = 0;
                 ($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"] : "");  
   
 $rs = mysqli_query($db_conn, $sql);  
 if ($rs == false)  
 {  
         echo("Query user error" . mysqli_error($db_conn));  
         exit();  
 }  
   
 if ($row = mysqli_fetch_array($rs))  
 {  
         $toa = $row["rec_count"];  
 }  
   
 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)  
 {  
         $page = $page_total;  
 }  
   
 if ($page <= 0)  
 {  
         $page = 1;  
 }  
 ?>  
 <html>  
         <head>  
                 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
                 <title>用户查找结果</title>  
                 <link rel="stylesheet" href="css/default.css" type="text/css">  
 <style type="text/css">  
 TD.head,TD.level,TD.login_dt,TD.dark,TD.username  
 {  
         border-right: #d0d3F0 1px solid;  
         border-left: #d0d3F0 1px solid;  
         border-bottom: #d0d3F0 1px solid;  
 }  
 TD.head  
 {  
         font-family: 楷体;  
         color: #909090;  
 }  
 TD.login_dt,TD.level,TD.dark,TD.username  
 {  
         text-align: center;  
 }  
 TD.login_dt,TD.dark  
 {  
         color: #909090;  
         background-color: #eaf0Fa;  
 }  
 TD.head,TD.level  
 {  
         background-color: #fafbfc;  
 }  
 TD.level  
 {  
         color: orange;  
 }  
 TD.username  
 {  
         background-color: #fafbfc;  
 }  
 TD.username:hover  
 {  
         background-color: #eaf0Fa;  
 }  
 </style>  
   
 <script type="text/javascript" src="../js/nw_open.js"></script>  
 <script type="text/javascript">  
 function ch_page(page)  
 {  
         document.change_page.page.value = page;  
         document.change_page.submit();  
         return false;  
 }  
   
 function ch_rpp()  
 {  
         document.change_page.page.value = Math.floor((document.change_page.page.value - 1) * <? echo $rpp; ?> / document.change_page.rpp.value) + 1;  
         document.change_page.submit();  
         return false;  
 }  
 </script>  
         </head>  
         <body>  
                 <center>  
                         <table cols="2" border="0" cellpadding="0" cellspacing="0" width="770">  
                                 <tr>  
                                         <td colspan="2" style="color:green;">  
                                                 <a class="s2" href="main.php"><? echo $BBS_name; ?></a>&gt;&gt;查找<? echo ($online?"在线":""); ?><? echo ($friend?"好友":"用户"); ?>  
                                         </td>  
                                 </tr>  
                                 <tr bgcolor="#d0d3F0" height="2">  
                                         <td colspan="2"></td></tr>  
                                 <tr>  
                                         <td class="dark" width="3%"></td>  
                                         <td class="head" width="97%">  
 <?  
 if ($toa==0)  
 {  
 ?>未找到指定用户<?  
 }  
 else  
 {  
 ?>用户查找结果(共<? echo $toa; ?>位)  
 <?  
 }  
 ?>(当前在线注册用户<? echo $user_online; ?>位,游客<? echo $guest_online; ?>位)  
                                         </td>  
                                 </tr>  
                         </table>  
                         <table border="0" cellpadding="1" cellspacing="0" width="770">  
                                 <tr height="10">  
                                         <td>  
                                         </td>  
                                 </tr>  
                         </table>  
                         <table bgcolor="#f0F3Fa" border="0" cellpadding="0" cellspacing="0" width="770">  
                                 <tr bgcolor="#d0d3F0" height="20">  
                                         <td class="title" width="4%"></td>  
                                         <td class="title" width="15%">用户ID</td>  
                                         <td class="title" width="20%">昵称</td>  
                                         <td class="title" width="12%">等级</td>  
                                         <td class="title" width="18%">最后登陆时间</td>  
                                         <td class="title" width="27%"></td>  
                                         <td class="title" width="4%"></td>  
                                 </tr>  
 <?  
 $sql = "SELECT user_list.UID, username, nickname, exp, gender, gender_pub, last_login_dt 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 ? "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"] : "") .  
                 " 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();  
 }  
36    
37  while ($row = mysqli_fetch_array($rs))          while ($row = mysqli_fetch_array($rs))
 {  
 ?>  
                                 <tr height="25">  
                                         <td class="dark">  
 <?  
         if ($row["gender_pub"])  
38          {          {
39                  if ($row["gender"] == 'M')                  if ($row["is_guest"])
40                  {                  {
41                          echo ("<font color=blue>♂</font>");                          $guest_online = $row["u_count"];
42                  }                  }
43                  else                  else
44                  {                  {
45                          echo ("<font color=red>♀</font>");                          $user_online = $row["u_count"];
46                  }                  }
47          }          }
48          else          mysqli_free_result($rs);
49    
50            $sql = "SELECT COUNT(user_list.UID) AS rec_count FROM user_list" .
51                            ($online ? " INNER JOIN user_online ON user_list.UID = user_online.UID" : "") .
52                            ($friend ? " INNER JOIN friend_list ON user_list.UID = friend_list.fUID" : "") .
53                            ($type == 1 ? " INNER JOIN user_pubinfo ON user_list.UID = user_pubinfo.UID" : "") .
54                            " WHERE user_list.enable AND ".
55                            ($type == 1 ? "nickname" : "username") .
56                            " LIKE '%" . mysqli_real_escape_string($db_conn, $search_text) . "%'" .
57                            ($online ? " AND last_tm >= SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND)" : "").
58                            ($friend ? " AND friend_list.UID = " . $_SESSION["BBS_uid"] : "");
59    
60            $rs = mysqli_query($db_conn, $sql);
61            if ($rs == false)
62          {          {
63                  echo ("<font color=green>?</font>");                  echo("Query user error" . mysqli_error($db_conn));
64                    exit();
65          }          }
66  ?>  
67                                          </td>          if ($row = mysqli_fetch_array($rs))
                                         <td class="username">  
                                                 <a class="s2" href="show_profile.php?uid=<? echo $row["UID"]; ?>" target=_blank><? echo $row["username"]; ?></a>  
                                         </td>  
                                         <td class="dark">  
                                                 <? echo $row["nickname"]; ?>  
                                         </td>  
                                         <td class="level">  
                                                 <? echo user_level($row["exp"]); ?>  
                                         </td>  
                                         <td class="login_dt">  
                                                 <? echo $row["last_login_dt"]; ?>  
                                         </td>  
                                         <td class="level">  
 <?  
         if ($_SESSION["BBS_priv"]->checkpriv(0, S_MSG))  
68          {          {
69  ?>                  $toa = $row["rec_count"];
                                                 <a class="s2" href="" onclick="return NW_open('send_msg.php?uid=<? echo $row["UID"]; ?>', 'send_msg', 500, 300);">发送消息</a>  
 <?  
70          }          }
 ?>  
                                         </td>  
                                         <td align="center">  
                                         </td>  
                                 </tr>  
 <?  
 }  
71    
72  mysqli_free_result($rs);          mysqli_free_result($rs);
73  ?>  
74                          </table>          if (!in_array($rpp, $BBS_list_rpp_options))
                         <table cols="3" border="0" cellpadding="5" cellspacing="0" width="770">  
                                 <tr bgcolor="#d0d3F0" height="10">  
                                         <td colspan="3" >  
                                         </td>  
                                 </tr>  
                                 <tr height="10">  
                                         <td colspan="3" >  
                                         </td>  
                                 </tr>  
                                 <tr>  
                                 <form action="search_user.php" method="get" id="change_page" name="change_page">  
                                         <td width="30%" style="color:#909090">  
                                         每页<select size="1" id="rpp" name="rpp" onchange="ch_rpp();">  
 <?  
         foreach ($BBS_list_rpp_options as $v)  
75          {          {
76                  echo ("<option value=\"$v\"" . ($v == $rpp ? " selected" : "") . ">$v</option>");                  $rpp = $BBS_list_rpp_options[0];
77          }          }
 ?>  
                         </select>人  
                         <?  
 if ($page > 1)  
 {  
 ?>  
                         <a class="s8" title="首页" href="" onclick="return ch_page(1);"><font face=webdings>9</font></a>  
                         <a class="s8" title="上一页" href="" onclick="return ch_page(<? echo ($page - 1); ?>);"><font face=webdings>7</font></a>  
 <?  
 }  
 else  
 {  
 ?>  
 <font face=webdings>9 7</font>  
 <?  
 }  
 ?>  
                 第<input id="page" name="page" value="<? echo ($page) ; ?>" style="width: 30px;">/<? echo $page_total; ?>页  
 <?  
 if ($page < $page_total)  
 {  
 ?>  
                         <a class="s8" title="下一页" href="" onclick="return ch_page(<? echo ($page + 1); ?>);"><font face=webdings>8</font></a>  
                         <a class="s8" title="尾页" href="" onclick="return ch_page(<? echo ($page_total); ?>);"><font face=webdings>:</font></a>  
 <?  
 }  
 else  
 {  
 ?>  
 <font face=webdings>8 :</font>  
 <?  
 }  
 ?>  
                                         </td>  
                                         <td width="50%">  
                                                 <select name="type">  
                                                         <option value="0" <? if ($type==0) echo "selected"; ?> >按用户名</option>  
                                                         <option value="1" <? if ($type==1) echo "selected"; ?> >按昵称</option>  
                                                 </select>  
                                                 <input type="text" id="search_text" name="search_text" size="15" value="<? echo $search_text;?>">  
                                                 <input type="checkbox" id="online" name="online" value="1" <? echo ($online ? "checked" : "");?>><font color=#909090>在线</font>  
                                                 <input type="checkbox" id="friend" name="friend" value="1" <? echo ($friend ? "checked" : "");?>><font color=#909090>好友</font>  
                                                 <input type=image src="images/search.gif" alt="查找用户" border="0" name="image"></a>  
                                         </td>  
                                         <td width="10%">  
                                         </td>  
                                         </form>  
                                 </tr>  
                         </table>  
                 </center>  
 <?  
 mysqli_close($db_conn);  
78    
79  include "./foot.inc.php";          $page_total = ceil($toa / $rpp);
80            if ($page > $page_total)
81            {
82                    $page = $page_total;
83            }
84    
85            if ($page <= 0)
86            {
87                    $page = 1;
88            }
89    
90            // Fill up result data
91            $result_set["data"] = array(
92                    "type" => $type,
93                    "online" => $online,
94                    "friend" => $friend,
95                    "search_text" => $search_text,
96                    "page" => $page,
97                    "rpp" => $rpp,
98                    "page_total" => $page_total,
99                    "toa" => $toa,
100                    "user_online" => $user_online,
101                    "guest_online" => $guest_online,
102    
103                    "users" => array(),
104            );
105    
106            $sql = "SELECT user_list.UID, username, nickname, exp, gender, gender_pub, last_login_dt FROM user_list" .
107                            ($online ? " INNER JOIN user_online ON user_list.UID = user_online.UID" : "") .
108                            ($friend ? " INNER JOIN friend_list ON user_list.UID = friend_list.fUID" : "") .
109                            " INNER JOIN user_pubinfo ON user_list.UID = user_pubinfo.UID WHERE user_list.enable AND ".
110                            ($type == 1 ? "nickname" : "username") .
111                            " LIKE '%" . mysqli_real_escape_string($db_conn, $search_text) . "%'" .
112                            ($online ? " AND last_tm >= SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND)" : "").
113                            ($friend ? " AND friend_list.UID = " . $_SESSION["BBS_uid"] : "") .
114                            " ORDER BY " . ($type == 1 ? "nickname" : "username") .
115                            " LIMIT " . ($page - 1) * $rpp . ", $rpp";
116    
117            $rs = mysqli_query($db_conn, $sql);
118            if ($rs == false)
119            {
120                    echo("Query user error" . mysqli_error($db_conn));
121                    exit();
122            }
123    
124            while ($row = mysqli_fetch_array($rs))
125            {
126                    array_push($result_set["data"]["users"], array(
127                            "uid" => $row["UID"],
128                            "username" => $row["username"],
129                            "nickname" => $row["nickname"],
130                            "exp" => $row["exp"],
131                            "gender" => $row["gender"],
132                            "gender_pub" => $row["gender_pub"],
133                            "last_login_dt" => (new DateTimeImmutable($row["last_login_dt"]))->setTimezone($_SESSION["BBS_user_tz"]),
134                    ));
135            }
136            mysqli_free_result($rs);
137    
138            // Cleanup
139            unset($type);
140            unset($online);
141            unset($friend);
142            unset($search_text);
143            unset($page);
144            unset($rpp);
145            unset($page_total);
146            unset($toa);
147            unset($user_online);
148            unset($guest_online);
149    
150            // Output with theme view
151            $theme_view_file = get_theme_file("view/search_user", $_SESSION["BBS_theme_name"]);
152            if ($theme_view_file == null)
153            {
154                    exit(json_encode($result_set)); // Output data in Json
155            }
156            include $theme_view_file;
157  ?>  ?>
         </body>  
 </html>  


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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