<!--#include file="conn.asp"-->
<!--#include file="inc/function.asp"-->
<%
Dim Uid,p,a
p=clng(Request.QueryString("p"))
a=Trim(Request.QueryString("a"))

Dim AskD,inHtml
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	opendb
	set AskD.myConn =conn
	AskD.myPredb =predb
	AskD.Getsetting()
	AskD.GetTemplate("T-user.html")
	siteinfo=AskD.siteinfo
	setting=AskD.setting
    inHtml=RexHtml(AskD.tempbody)
    inHtml=RexHtml_IF(inHtml)
	set AskD.myConn =Nothing
     closedb
Set AskD = Nothing
Response.Write(inHtml)



Function topuser()
	dim rs,rs1,gradename,ansnum,Face,uid,str
	  set rs=conn.execute("select top 1 userid,grade,gradetype,face,score,asknum,ansnum,bcn from "&predb&"user where isstrong=1 order by strongtime desc")
	  IF not(rs.bof and rs.eof) Then  
		  if rs("gradetype")=0 then
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.isDefault=1 and a.grade="&rs("grade"))
		  else
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.id="&rs("gradetype")&" and a.grade="&rs("grade"))
		  end if
		     gradename=rs1("gradename")
			 set rs1=nothing
			 
		ansnum=rs("ansnum")
		IF rs("face")&""<>"" Then face=rs("face") else face="Face/info.gif"
		
		str=str&"<div class=""upai1""><img src=""UploadFile/"&face&""" width=""100"" height=""80""/></div>"&vbcrlf
		str=str&"<div class=""upai2"">"&vbcrlf
		str=str&"昵&nbsp; 称："&rs("userid")&"<br>"&vbcrlf
		str=str&"等&nbsp; 级："&gradename&"<br>"&vbcrlf
		str=str&"总积分："&rs("score")&"<br>"&vbcrlf
		str=str&"提问总数："&rs("asknum")&""&vbcrlf
		str=str&"</div>"&vbcrlf
		str=str&"<div class=""upai2"">"&vbcrlf
		str=str&"回答总数："&ansnum&"<br>"&vbcrlf
		str=str&"被采纳数："&rs("bcn")&"<br>"&vbcrlf
		str=str&"被采纳率："&vbcrlf
		IF ansnum=0 Then ansnum=1
		str=str&Formatpercent(rs("bcn")/ansnum,1,true)&vbcrlf
		str=str&"</div>"&vbcrlf
	 End IF
	set rs=nothing
	topuser=str
End Function

Function monthuser()
Dim rs,rs1,face,gradename,str
	  set rs=conn.execute("select top 1 id,userid,grade,gradetype,face,monthscore,asknum,ansnum from "&predb&"user where DateDiff("&Sday&",LastTime,'"&now()&"')<30 order by monthscore desc")
	  IF not(rs.eof and rs.bof) Then
		  if rs("gradetype")=0 then
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.isDefault=1 and a.grade="&rs("grade"))
		  else
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.id="&rs("gradetype")&" and a.grade="&rs("grade"))
		  end if
		     gradename=rs1("gradename")
			 set rs1=nothing
		
		uid=rs("id") 
		IF rs("face")&""<>"" Then face=rs("face") else face="Face/info.gif"
		
		str=str&"<div class=""upai1""><img src=""UploadFile/"&face&""" width=""100"" height=""80""/></div>"&vbcrlf
		str=str&"<div class=""upai2"">"&vbcrlf
		str=str&"昵&nbsp; 称："&rs("userid")&"<br>"&vbcrlf
		str=str&"等&nbsp; 级："&gradename&"<br>"&vbcrlf
		str=str&"月积分："&rs("monthscore")&"<br>"&vbcrlf
		str=str&"问答数："&rs("asknum")&"/"&rs("ansnum")&vbcrlf
		str=str&"</div>"&vbcrlf
	Else
	Uid=0
	End IF
	set rs=nothing
    monthuser=str
End Function

Function monthpai()
   dim rs,rs1,gradename,str
	  set rs=conn.execute("select top 6 id,userid,sex,grade,gradetype,monthscore,pmp,(select count(id)+1 from "&predb&"user b where b.monthscore>a.monthscore) as pai from "&predb&"user a where a.id<>"&uid&" and DateDiff("&Sday&",LastTime,'"&now()&"')<30 order by monthscore desc,id desc")
	  IF not(rs.bof and rs.eof) Then
	  do while not rs.eof
		  if rs("gradetype")=0 then
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.isDefault=1 and a.grade="&rs("grade"))
		  else
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.id="&rs("gradetype")&" and a.grade="&rs("grade"))
		  end if
		     gradename=rs1("gradename")
			 set rs1=nothing
	
	str=str&"<div class=""sjl"">"&vbcrlf
	str=str&"<div class=""sj0"">"
	If rs("pai")>rs("pmp") Then
	str=str&"<font color=""#FF0000"">&uarr;</font>"
	ElseIf rs("pai")<rs("pmp") Then
	str=str&"<font color=""#000000"">&darr;</font>"
	Else
	str=str&"<font color=""#00FF00"">&rarr;</font>"
	End If
	str=str&"</div>"&vbcrlf
	str=str&"<div class=""sj1""><a href=""user/userinfo.asp?id="&rs("id")&""" target=""_blank"">"&rs("userid")&"</a></div>"&vbcrlf
	str=str&"<div class=""sj2"">"&rs("sex")&"</div>"&vbcrlf
	str=str&"<div class=""sj3"">"&gradename&"</div>"&vbcrlf
	str=str&"<div class=""sj4"">"&rs("monthscore")&"</div>"&vbcrlf
	str=str&"</div>"&vbcrlf

	  rs.movenext
	  loop
   End IF
   set rs=nothing
   monthpai=str
End Function

Function weekuser()
  Dim rs,rs1,gradename,uid,face,str
	  set rs=conn.execute("select top 1 id,userid,grade,gradetype,face,weekscore,asknum,ansnum from "&predb&"user where DateDiff("&Sday&",LastTime,'"&now()&"')<30 order by weekscore desc")
	  IF not(rs.bof and rs.eof) then
		  if rs("gradetype")=0 then
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.isDefault=1 and a.grade="&rs("grade"))
		  else
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.id="&rs("gradetype")&" and a.grade="&rs("grade"))
		  end if
		     gradename=rs1("gradename")
			 set rs1=nothing
		
		uid=rs("id") 
		IF rs("face")&""<>"" Then face=rs("face") else face="Face/info.gif"
		str=str&"<div class=""upai1""><img src=""UploadFile/"&face&""" width=""100"" height=""80""/></div> "&vbcrlf
		str=str&"<div class=""upai2"">"&vbcrlf
		str=str&"昵&nbsp; 称："&rs("userid")&"<br>"&vbcrlf
		str=str&"等&nbsp; 级："&gradename&"<br>"&vbcrlf
		str=str&"周积分："&rs("weekscore")&"<br>"&vbcrlf
		str=str&"问答数："&rs("asknum")&"/"&rs("ansnum")&vbcrlf
		str=str&"</div>"&vbcrlf
	End IF
    set rs=nothing
	weekuser=str
End Function

Function weekpai()
  Dim rs,rs1,gradename,str
	  set rs=conn.execute("select top 6 id,userid,sex,grade,gradetype,weekscore,pwp,(select count(id)+1 from "&predb&"user b where b.weekscore>a.weekscore) as pai from "&predb&"user a where a.id<>"&uid&" and DateDiff("&Sday&",LastTime,'"&now()&"')<30 order by weekscore desc,id desc")
	  IF not(rs.bof and rs.eof) Then
	  do while not rs.eof
		  if rs("gradetype")=0 then
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.isDefault=1 and a.grade="&rs("grade"))
		  else
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.id="&rs("gradetype")&" and a.grade="&rs("grade"))
		  end if
		     gradename=rs1("gradename")
			 set rs1=nothing
	str=str&"<div class=""sjl"">"&vbcrlf
	str=str&"<div class=""sj0"">"
	If rs("pai")>rs("pwp") Then
	str=str&"<font color=""#FF0000"">&uarr;</font>"
	ElseIf rs("pai")<rs("pwp") Then
	str=str&"<font color=""#000000"">&darr;</font>"
	Else
	str=str&"<font color=""#00FF00"">&rarr;</font>"
	End If
	str=str&"</div>"&vbcrlf
	str=str&"<div class=""sj1""><a href=""user/userinfo.asp?id="&rs("id")&""" target=""_blank"">"&rs("userid")&"</a></div>"&vbcrlf
	str=str&"<div class=""sj2"">"&rs("sex")&"</div>"&vbcrlf
	str=str&"<div class=""sj3"">"&gradename&"</div>"&vbcrlf
	str=str&"<div class=""sj4"">"&rs("weekscore")&"</div>"&vbcrlf
	str=str&"</div>"&vbcrlf
	  rs.movenext
	  loop
	  End IF
	  set rs=nothing
	weekpai=str
End Function

Function chufa()
 Dim rs,rs1,gradename,str
		set rs=conn.execute("select top 6 b.id,userid,sex,grade,gradetype,fenz,mTitle from "&predb&"Details a inner join "&predb&"user b on a.uid=b.id where fenz<0 order by a.id desc")
		IF not(rs.eof and rs.bof) Then
		do while not rs.eof
		  if rs("gradetype")=0 then
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.isDefault=1 and a.grade="&rs("grade"))
		  else
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.id="&rs("gradetype")&" and a.grade="&rs("grade"))
		  end if
		     gradename=rs1("gradename")
			 set rs1=nothing
		
		str=str&"<div>"&vbcrlf
		str=str&"<div class=""cf1""><a href=""user/userinfo.asp?id="&rs("id")&""" target=""_blank"">"&rs("userid")&"</a></div>"&vbcrlf
		str=str&"<div class=""cf2"">"&rs("sex")&"&nbsp;</div>"&vbcrlf
		str=str&"<div class=""cf3"">"&gradename&"</div>"&vbcrlf
		str=str&"<div class=""cf4"">"&rs("mtitle")&"</div>"&vbcrlf
		str=str&"<div class=""cf5"">"&rs("fenz")&"</div>"&vbcrlf
		str=str&"<div class=""cf6""><a href=""#"">详细 &raquo;</a></div>"&vbcrlf
		str=str&"</div>"&vbcrlf
		rs.movenext
		loop
		End IF
		set rs=nothing
	chufa=str
End Function

Function user100()
Dim rs,rs1,gradename,ansnum,str
select case a
   case "m"
       set rs=conn.execute("select top 100 id,userid,sex,grade,gradetype,monthscore,ansnum,bcn,pmp,(select count(id)+1 from "&predb&"user b where b.monthscore>a.monthscore) as pai from "&predb&"user a where DateDiff("&Sday&",LastTime,'"&now()&"')<30 order by monthscore desc")
   case "w"
       set rs=conn.execute("select top 100 id,userid,sex,grade,gradetype,weekscore,ansnum,bcn,pwp,(select count(id)+1 from "&predb&"user b where b.weekscore>a.weekscore) as pai from "&predb&"user a where DateDiff("&Sday&",LastTime,'"&now()&"')<30 order by weekscore desc")
   case "d"
       set rs=conn.execute("select top 100 id,userid,sex,grade,gradetype,dayscore,ansnum,bcn,pdp,(select count(id)+1 from "&predb&"user b where b.dayscore>a.dayscore) as pai from "&predb&"user a where DateDiff("&Sday&",LastTime,'"&now()&"')<30 order by dayscore desc")
   case else
       set rs=conn.execute("select top 100 id,userid,sex,grade,gradetype,score,ansnum,bcn,pdp,(select count(id)+1 from "&predb&"user b where b.score>a.score) as pai from "&predb&"user a where DateDiff("&Sday&",LastTime,'"&now()&"')<30 order by score desc")
end select

IF not(rs.bof and rs.eof) Then
do while not rs.eof

		  if rs("gradetype")=0 then
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.isDefault=1 and a.grade="&rs("grade"))
		  else
		      set rs1=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.id="&rs("gradetype")&" and a.grade="&rs("grade"))
		  end if
		     gradename=rs1("gradename")
			 set rs1=nothing
		 ansnum=rs("ansnum")
		 if ansnum=0 then ansnum=1
		 
	str=str&"<div class=""lb-l"">"&vbcrlf
	str=str&"<ul>"&vbcrlf
	str=str&"<li class=""ul1"">"
	If rs("pai")>rs(8) Then
	str=str&"<font color=""#FF0000"">&uarr;</font>"
	ElseIf rs("pai")<rs(8) Then
	str=str&"<font color=""#000000"">&darr;</font>"
	Else
	str=str&"<font color=""#00FF00"">&rarr;</font>"
	End If
	str=str&rs("pai")&"</li>"&vbcrlf
    str=str&"<li class=""ul2""><a href=""user/userinfo.asp?id="&rs("id")&""" target=""_blank"">"&rs("userid")&"</a></li>"&vbcrlf
    str=str&"<li class=""ul3"">"&rs("sex")&"</li>"&vbcrlf
	str=str&"<li class=""ul4"">"&gradename&"</li>"&vbcrlf
	str=str&"<li class=""ul5"">"&Formatpercent(rs("bcn")/ansnum,1,true)&"</li>"&vbcrlf
	str=str&"<li class=""ul6"">"&rs(5)&"</li>"&vbcrlf
	str=str&"</ul>"&vbcrlf
	str=str&"</div>"&vbcrlf

rs.movenext
loop
End IF
set rs=nothing
user100=str
End Function
%>