<!--#INCLUDE FILE="setup.asp" -->
<!--#include file="checkuser.asp"-->
<!--#INCLUDE FILE="theme.asp" -->
<!--#include file="include/validate.asp"-->

<%locat="校友查询"
Call top(1,1)
if Request("action")="search" Then
	Call find()
Else	
	Call inputname()
End if

Sub find()

	realname=trim(Request.form("realname"))

	if realname="" Then
		Errmsg=Errmsg+"<br>"+"<li>请输入了校友真实姓名。"
		founderr=True
	ElseIf not isChinese(realname) Then
		Errmsg=Errmsg+"<br>"+"<li>您的输入有误！"
		founderr=True
	End if

	if founderr=True Then
		Call Error("Information",Errmsg)
		Exit Sub
	End if

%>
<br><br>
<!--#INCLUDE FILE="script/popup.inc" -->
    <table width=100% Class=TableBorder  cellspacing=0 border=0  align=center>
    	<tr>
	        <td>
        	
<table cellpadding=6 cellspacing=1 border=0 width=100% Class=TableBorder>
<tr Class=LightTableBody> 
<td colspan=2 valign=top width=40% align=center>&nbsp;<img src=images/find.gif>
<font face=宋体></td><td colspan=4 align=center>校友<font color=brown><b><%=htmlencode(realname)%></b></font>查询结果：共找到&nbsp;<font color=brown><b><%=allfriends(realname)%></b></font>&nbsp;人</font></td>

</tr>
<tr> 
<th align=center>用户名</th>
<th align=center>所在班级</th>
<th align=center>QQ</th>
<th align=center>主页</th>
<th align=center>Email</th>
<th align=center>短信息</th>
</tr>
<%

realname=replace(realname,"'","")
if not sysadmin and BoolVar(9) then
	sql="Select * from student where realname='"&realname&"' and locked<2"
else
	sql="Select * from student where realname='"&realname&"'"
end if

Set rs=conn.execute(sql)
if rs.eof Then
%>
<TR  Class=DarkTableBody>
	<TD colspan=6>对不起，没有您要找的同学:(</TD>
</TR>

<%Else%>
<script language="JavaScript" src="script/jsfun.js"></script>
<%
do until rs.eof
name=htmlencode(rs("userid"))
%>
<tr Class=DarkTableBody>
<td nowrap>&nbsp;&nbsp;<a href="profile.asp?name=<%=name%>"  target=_blank  onmouseout="kill()" onmouseover="popup('查看<%=name%>的个人信息','<%=LightTBColor%>')"><%=name%></a></td>
<td nowrap>&nbsp;&nbsp;<%Call classlist(name)%></td>
<td align=center>
<%if rs("oicq")="" or isnull(rs("oicq")) Then
Response.Write "-"
ElseIf rs("isoicqshow")=False Then
Response.Write "<img src=images/passwd.gif onmouseout=kill() onmouseover=popup('我的QQ保密哦','"&LightTBColor&"')>"
Else
%>
<a href=http://search.tencent.com/cgi-bin/friend/user_show_info?ln=<%=rs("oicq")%> target=_blank onmouseout="kill()" onmouseover="popup('查看<%=name%>的QQ[<%=rs("oicq")%>]资料','<%=LightTBColor%>')"><img src="images/oicq.gif" border=0 width=16 height=16 hspace=1></a>
<%End if%>
</td>
<td align=center>
<%if rs("homepage")="" or rs("homepage")="http://" or isnull(rs("homepage")) Then
Response.Write "-"
ElseIf rs("ishomepageshow")=False Then
Response.Write "<img src=images/passwd.gif onmouseout=kill() onmouseover=popup('我的主页保密哦','"&LightTBColor&"')>"
Else
%>
<a href=<%=htmlencode(rs("homepage"))%> target=_blank  onmouseout="kill()" onmouseover="popup('访问<%=name%>的主页','<%=LightTBColor%>')"><img border=0 src=images/homepage.gif></a>
<%End if%>
</td>
<td align=center><%if rs("isemailshow")=False Then 
Response.Write "<img src=images/passwd.gif onmouseout=kill() onmouseover=popup('我的Email保密哦','"&LightTBColor&"')>"
Else%>
<a href="mailto:<%=htmlencode(rs("email"))%>" onmouseout="kill()"  onmouseover="popup('给<%=name%>发电子邮件','<%=LightTBColor%>')"><img border=0 src=images/email1.gif hspace=1></a>
<%End if%>
</td>
<td align=center><a href="usersms.asp?action=new&touser=<%=htmlencode(rs("userid"))%>" target=_blank onmouseout="kill()" onmouseover="popup('给<%=name%>发短消息','<%=LightTBColor%>')"><img border=0 src=images/message.gif hspace=1></a></td>

</tr>
<%
rs.movenext
loop
	End if
%>
</table></td></tr></table><BR>
<%
End Sub

Sub inputname()
%>
<br><br><form action="search.asp" method="post"> 
<input type=hidden name=action value=search>
<table cellpadding=0 cellspacing=0 border=0 width=750 Class=TableBorder align=center>
    <tr>    
        <td>
        <table cellpadding=6 cellspacing=1 border=0 width=100%>

    <tr>
    <td bgcolor=<%=TableTitleColor%> valign=middle colspan=2 align=center><IMG SRC="IMAGES/find_c.gif" WIDTH="148" HEIGHT="33" BORDER=0 ALT=""></font></td></tr>
    <tr Class=LightTableBody>
    <td valign=middle width=40%>请输入校友真实姓名：</td>
    <td valign=middle><INPUT name=realname type=text> &nbsp; </td></tr>
    <tr>
    <td Class=DarkTableBody valign=middle colspan=2 align=center><input type=submit name="submit" value="查询"></td></tr></table></td></tr></table>
</form>
<%

End Sub


Function allfriends(byval realname) 
    	tmprs=conn.execute("Select count(*) from student where realname='"&realname&"'") 
    	allfriends=tmprs(0) 
	Set tmprs=Nothing 
	if isnull(allfriends) Then allfriends=0 
End Function 


Sub classlist(byval username) 
   	Set tmprs=conn.execute("Select classid,classname from class where classid "&_
	"in (Select classid from joinclass where userid='"&username&"' and isauditing=False)")
	if tmprs.eof Then
		Response.Write "尚未加入任何班级"
	Else
		Response.Write "<Select name=classlist onchange=""if(this.selectedIndex!=0&&this.selectedIndex!=1)"&_
				"{window.open('BrowseClass.asp?classid='+options[this.selectedIndex].value);this.selectedIndex=0;}"">"
		Response.Write "<option value=0>浏览所注册班级</option>"
		Response.Write "<option value=1>--------------</option>"
		do until tmprs.eof
			Response.Write 	"<option value="&tmprs(0)&">"&htmlencode(tmprs(1))&"</option>"
			tmprs.movenext
		loop		
	End if
End Sub 



%>
<%Call footer%>
