| 1 |
<? |
<? |
| 2 |
|
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"; |
| 5 |
<? |
require_once "./theme.inc.php"; |
|
$page_max_record=60; |
|
| 6 |
|
|
| 7 |
if (isset($_GET["page"])) |
$result_set = array( |
| 8 |
$page=intval($_GET["page"]); |
"return" => array( |
| 9 |
else |
"code" => 0, |
| 10 |
$page=1; |
"message" => "", |
| 11 |
if ($page<1) |
"errorFields" => array(), |
| 12 |
$page=1; |
) |
| 13 |
|
); |
| 14 |
if (isset($_GET["type"])) |
|
| 15 |
$type=intval($_GET["type"]); |
$page = (isset($_GET["page"]) ? intval($_GET["page"]) : 1); |
| 16 |
else |
$rpp = (isset($_GET["rpp"]) ? intval($_GET["rpp"]) : 20); |
| 17 |
$type=1; |
|
| 18 |
if (!($_SESSION["BBS_priv"]->checklevel(P_ADMIN_M) || |
$type = (isset($_GET["type"]) ? intval($_GET["type"]) : 0); |
| 19 |
$_SESSION["BBS_priv"]->checklevel(P_ADMIN_S) || |
$online = (isset($_GET["online"]) && $_GET["online"] == "1" ? 1 : 0); |
| 20 |
$_SESSION["BBS_priv"]->checklevel(P_MAN_C))) |
$friend = (isset($_GET["friend"]) && $_GET["friend"] == "1" ? 1 : 0); |
| 21 |
{ |
$search_text = (isset($_GET["search_text"]) ? $_GET["search_text"] : ""); |
| 22 |
$type=1; |
|
| 23 |
} |
$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 |
if (isset($_GET["search_text"])) |
GROUP BY is_guest"; |
| 26 |
$search_text=trim($_GET["search_text"]); |
|
| 27 |
else |
$rs = mysqli_query($db_conn, $sql); |
| 28 |
$search_text=""; |
if ($rs == false) |
| 29 |
$search_author=addslashes(stripslashes($search_text)); |
{ |
| 30 |
|
echo("Count online user error" . mysqli_error($db_conn)); |
| 31 |
$db_conn=include "./db_open.inc.php"; |
exit(); |
| 32 |
|
} |
| 33 |
$rs=mysql_query("select count(user_list.UID) as rec_count from user_list". |
|
| 34 |
" inner join user_pubinfo on user_list.UID=user_pubinfo.UID where". |
$guest_online = 0; |
| 35 |
" user_list.enable and ".($type==1?"user_pubinfo.nickname":"user_list.username"). |
$user_online = 0; |
| 36 |
" like '%$search_author%'") |
|
| 37 |
or die("Query user error!"); |
while ($row = mysqli_fetch_array($rs)) |
|
|
|
|
$row=mysql_fetch_array($rs); |
|
|
$toa=$u_count=$row["rec_count"]; |
|
|
|
|
|
mysql_free_result($rs); |
|
|
|
|
|
if ($toa==0) |
|
|
$toa=1; |
|
|
|
|
|
$page_total=intval($toa/$page_max_record); |
|
|
if (($toa % $page_max_record)>0) |
|
|
$page_total++; |
|
|
if ($page>$page_total) |
|
|
$page=$page_total; |
|
|
?> |
|
|
<html> |
|
|
<head> |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> |
|
|
<title>用户查找结果</title> |
|
|
<link rel="stylesheet" href="css/default.css" type="text/css"> |
|
|
<script language="JavaScript" src="/js/nw_open.js"></script> |
|
|
</head> |
|
|
<body> |
|
|
<center> |
|
|
<table border="0" cellpadding="1" cellspacing="0" width="770"> |
|
|
<tr bgcolor="#d0d3F0" height="20"> |
|
|
<td align="center" class="title"> |
|
|
<? if ($u_count==0) |
|
|
{ |
|
|
?> |
|
|
未找到指定用户<? } |
|
|
else |
|
|
{ |
|
|
?>用户查找结果(共<? echo $u_count; ?>位)<? } ?> |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
<table bgcolor="#f0F3Fa" border="0" cellpadding="5" cellspacing="0" width="770"> |
|
|
<tr> |
|
|
<td width="5%"> |
|
|
</td> |
|
|
<td width="15%"> |
|
|
</td> |
|
|
<td width="15%"> |
|
|
</td> |
|
|
<td width="15%"> |
|
|
</td> |
|
|
<td width="15%"> |
|
|
</td> |
|
|
<td width="15%"> |
|
|
</td> |
|
|
<td width="15%"> |
|
|
</td> |
|
|
<td width="5%"> |
|
|
</td> |
|
|
</tr> |
|
|
<? |
|
|
$color[0]="#f0F3Fa"; |
|
|
$color[1]="#FAFBFC"; |
|
|
$color_index=-1; |
|
|
$color_count=2; |
|
|
|
|
|
$rs=mysql_query("select user_list.UID,username,nickname,". |
|
|
"IF(user_pubinfo.gender_pub,IF(user_pubinfo.gender='M',". |
|
|
"'<font color=blue>♂</font>','<font color=red>♀</font>'),'') as gender". |
|
|
" from user_list". |
|
|
" 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%' order by ".($type==1?"nickname":"username"). |
|
|
" limit ".($page-1)*$page_max_record.",$page_max_record") |
|
|
or die("Query user error!"); |
|
|
|
|
|
do |
|
|
{ |
|
|
$color_index=($color_index+1)%$color_count; |
|
|
?> |
|
|
<tr bgcolor="<? echo $color[$color_index]; ?>"> |
|
|
<td align="center"> |
|
|
</td> |
|
|
<? |
|
|
for ($i=1; $i<=6; $i=$i+1) |
|
| 38 |
{ |
{ |
| 39 |
if ($row=mysql_fetch_array($rs)) |
if ($row["is_guest"]) |
| 40 |
{ |
{ |
| 41 |
?> |
$guest_online = $row["u_count"]; |
|
<td align="center" onmouseover="this.bgColor='#f0FaFf';" onmouseout="this.bgColor='<? echo $color[$color_index]; ?>';"> |
|
|
<? echo $row["gender"]; ?><a class="s2" href="javascript:show_profile(<? echo $row["UID"]; ?>)"><? echo ($type==1?$row["nickname"]:$row["username"]); ?></a> |
|
|
</td> |
|
|
<? |
|
| 42 |
} |
} |
| 43 |
else |
else |
| 44 |
{ |
{ |
| 45 |
?> |
$user_online = $row["u_count"]; |
| 46 |
<td align="center"> |
} |
| 47 |
</td> |
} |
| 48 |
<? |
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 |
<td align="center"> |
($friend ? " INNER JOIN friend_list ON user_list.UID = friend_list.fUID" : "") . |
| 53 |
</td> |
($type == 1 ? " INNER JOIN user_pubinfo ON user_list.UID = user_pubinfo.UID" : "") . |
| 54 |
</tr> |
" WHERE user_list.enable AND ". |
| 55 |
<? |
($type == 1 ? "nickname" : "username") . |
| 56 |
}while($row); |
" LIKE '%" . mysqli_real_escape_string($db_conn, $search_text) . "%'" . |
| 57 |
?> |
($online ? " AND last_tm >= SUBDATE(NOW(), INTERVAL $BBS_user_off_line SECOND)" : ""). |
| 58 |
</table> |
($friend ? " AND friend_list.UID = " . $_SESSION["BBS_uid"] : ""); |
| 59 |
<? |
|
| 60 |
mysql_free_result($rs); |
$rs = mysqli_query($db_conn, $sql); |
| 61 |
mysql_close($db_conn); |
if ($rs == false) |
|
?> |
|
|
<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> |
|
|
<td width="25%" align="center" style="color:#909090"> |
|
|
<form action="search_user.php" method="get" id="change_page" name="change_page"> |
|
|
<input type="hidden" id="search_text" name="search_text" value="<? echo $search_text;?>"> |
|
|
分页: <? echo $page; ?>/<? echo $page_total; ?>页 |
|
|
<? if ($page>1) |
|
|
{ |
|
|
?><a class="s8" title="首页" href="search_user.php?page=1&type=<? echo $type; ?><? if ($search_text!="") echo "&search_text=".$search_text;?>"><font face=webdings>9</font></a><a class="s8" title="上一页" href="search_user.php?page=<? echo $page-1; ?>&type=<? echo $type; ?><? if ($search_text!="") echo "&search_text=".$search_text;?>"><font face=webdings>7</font></a><? } |
|
|
else |
|
|
{ |
|
|
?><font face=webdings>97</font><? } ?> |
|
|
<input id="page_id" name="page" value="<? echo ($page) ; ?>" size="2"> |
|
|
<? if ($page<$page_total) |
|
|
{ |
|
|
?><a class="s8" title="下一页" href="search_user.php?page=<? echo $page+1; ?>&type=<? echo $type; ?><? if ($search_text!="") echo "&search_text=".$search_text;?>"><font face=webdings>8</font></a><a class="s8" title="尾页" href="search_user.php?page=<? echo $page_total; ?>&type=<? echo $type; ?><? if ($search_text!="") echo "&search_text=".$search_text;?>"><font face=webdings>:</font></a><? } |
|
|
else |
|
|
{ |
|
|
?><font face=webdings>8:</font><? } ?> |
|
|
</form> |
|
|
</td> |
|
|
<td width="50" align="center"> |
|
|
<form action="search_user.php" method="get" id="search"> |
|
|
<font color=#909090>查找用户</font> |
|
|
<select name="type"> |
|
|
<option value="1" <? if ($type==1) echo "selected"; ?> >按昵称</option> |
|
|
<? |
|
|
if ($_SESSION["BBS_priv"]->checklevel(P_ADMIN_M) || |
|
|
$_SESSION["BBS_priv"]->checklevel(P_ADMIN_S) || |
|
|
$_SESSION["BBS_priv"]->checklevel(P_MAN_C)) |
|
| 62 |
{ |
{ |
| 63 |
?> |
echo("Query user error" . mysqli_error($db_conn)); |
| 64 |
<option value="2" <? if ($type==2) echo "selected"; ?> >按用户名</option> |
exit(); |
|
<? |
|
| 65 |
} |
} |
|
?> |
|
|
</select> |
|
|
<input type="text" id="search_text" name="search_text" size="15"> <input type=image src="images/search.gif" alt="按昵称查找注册用户" border="0" name="image"></a> |
|
|
</form> |
|
|
</td> |
|
|
<td width="25"> |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
</center> |
|
|
<? |
|
|
include "./foot.inc.php"; |
|
|
?> |
|
|
</body> |
|
|
</html> |
|
| 66 |
|
|
| 67 |
|
if ($row = mysqli_fetch_array($rs)) |
| 68 |
|
{ |
| 69 |
|
$toa = $row["rec_count"]; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
mysqli_free_result($rs); |
| 73 |
|
|
| 74 |
|
if (!in_array($rpp, $BBS_list_rpp_options)) |
| 75 |
|
{ |
| 76 |
|
$rpp = $BBS_list_rpp_options[0]; |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
$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 |
|
?> |