<!--#include file="conn.asp"-->
<!--#include file="inc/Function.asp"-->
<%
Dim AskD,inHtml,sCount,IndexClass
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	opendb
	set AskD.myConn =conn
	AskD.myPredb =predb
	AskD.Mysday =sday
	AskD.Getsetting()
	AskD.Expired1
	AskD.GetTemplate("T-index.html")
	AskD.GetCount()
	siteinfo=AskD.siteinfo
	setting=AskD.setting
	regForm=AskD.regForm
	sCount=AskD.scount
	Call GetIndexClass()
	inHtml=RexHtml(AskD.tempbody)
	inHtml=RexHtml_IF(inHtml)
	set AskD.myConn =Nothing
	closedb
Set AskD = Nothing
	  
Response.Write(inHtml)

Function strongClass()
Dim str,rs,rs1,n  
set rs=conn.execute("select top 1 classid,classname,bask,bstr,UpFile from "&predb&"class where isb=1 order by btime desc")
IF not(rs.bof and rs.eof) then

  str=str&"<div class=""strClass"">"&vbcrlf
  str=str&"<div>"&vbcrlf
  str=str&"<div class=""strClass1""><img src=""UploadFile/"&rs("UpFile")&""" width=""80"" height=""60"" alt=""""/></div>"&vbcrlf
	  str=str&"<div class=""strClass2"">"&vbcrlf
	  str=str&"<div><a href="""
		
		IF setting(34)=0 Then
		str=str&"List.asp?classid="&rs("CLassID")
		Else
		str=str&siteInfo(1)&"List-"&rs("CLassID")&".html"
		End IF
		str=str&""">"&AskD.leftstr(rs("classname"),16)&"</a></div>"&vbcrlf    
	  str=str&"<div>"&AskD.leftstr(rs("bstr"),30)&"</div>"&vbcrlf         
	  str=str&"</div>"&vbcrlf           
	  str=str&"</div>"&vbcrlf              
	  str=str&"<div class=""strClass3"">"&vbcrlf      
	  str=str&"<ul>"&vbcrlf    
	
			  dim bask
			  bask=split(rs("bask"),",")
			  For n=0 to Ubound(bask)
			  set rs1=conn.execute("select title from "&predb&"ask where askid="&bask(n))
		
	  str=str&"<li><img src=""Template/"&siteInfo(11)&"/images/dot.gif"" alt=""""/><a href="""
	  IF setting(34)=0 Then
	  str=str&"ask.asp?id="&bask(n)&""
	  Else
	  str=str&siteInfo(1)&"ask-"&bask(n)&".html"
	  End IF
	  str=str&""">"&AskD.leftstr(rs1("title"),30)&"</a></li>"&vbcrlf 
	
			  set rs1=nothing
			  Next
			  
	  str=str&"</ul>"&vbcrlf 
  

  str=str&"</div>"&vbcrlf 
  str=str&"</div>"&vbcrlf   
  
end if
set rs=nothing
  strongClass=str
End Function

Function YesAsk()
Dim rs,str,sql
    str=str&"<div class=""x-next"">"&vbcrlf
    str=str&"<ul>"&vbcrlf
	set rs= Server.CreateObject("adodb.recordset")
	sql="select top 4 askid,title,asktime,classid,classname from "&predb&"Ask a inner join "&predb&"Class b on a.sclass=b.classid where a.ispass=1 and(state=1 or state=5  or state=6  or state=7) Order by askid desc"
	rs.open sql,conn,1,1
	do while not rs.eof
	
	str=str&"<li class=""l1"">[<a href="""
    IF setting(34)=0 Then
	str=str&"List.asp?classid="&rs("CLassID")
	Else
	str=str&siteInfo(1)&"List-"&rs("CLassID")&".html"
	End IF
	str=str&""">"&AskD.leftstr(rs("classname"),8)&"</a>]</li>"&vbcrlf
	str=str&"<li class=""l2""><a href="""
  IF setting(34)=0 Then
  str=str&"ask.asp?id="&rs("askid")&""
  Else
  str=str&siteInfo(1)&"ask-"&rs("askid")&".html"
  End IF
  str=str&""">"&AskD.leftstr(rs("title"),42)&"</a></li>"&vbcrlf
	str=str&"<li class=""l3"">"&AskD.Ftime(rs("asktime"))&"</li>"&vbcrlf
	rs.movenext
	loop
	rs.close
	set rs=nothing
    str=str&"</ul>"&vbcrlf
    str=str&"</div>"&vbcrlf
    YesAsk=str
End Function

Function NewAsk()
Dim rs,sql,str
    str=str&"<div class=""x-next"">"&vbcrlf
    str=str&"<ul>"&vbcrlf
	set rs= Server.CreateObject("adodb.recordset")
	sql="select top 18 askid,title,asktime,classid,classname,xshang from "&predb&"Ask a inner join "&predb&"Class b on a.sclass=b.classid where a.ispass=1 Order by AskID desc"
	rs.open sql,conn,1,1
	do while not rs.eof
	str=str&"<li class=""l1"">[<a href="""
    IF setting(34)=0 Then
	str=str&"List.asp?classid="&rs("CLassID")
	Else
	str=str&siteInfo(1)&"List-"&rs("CLassID")&".html"
	End IF
	str=str&""" title="""&rs("classname")&""">"&AskD.leftstr(rs("classname"),8)&"</a>]</li>"&vbcrlf
	str=str&"<li class=""l2""><a href="""
  IF setting(34)=0 Then
  str=str&"ask.asp?id="&rs("askid")&""
  Else
  str=str&siteInfo(1)&"ask-"&rs("askid")&".html"
  End IF
  str=str&""">"&AskD.leftstr(rs("title"),38)&"</a>"
  if rs("xshang")>0 then
  str=str&" <img src=""images/money.gif"" align=""absmiddle""/><font color=""#FF9900"">"&rs("xShang")&"</font>"&vbcrlf
  end if
  str=str&"</li>"&vbcrlf
    str=str&"<li class=""l3"">"&AskD.Ftime(rs("asktime"))&"</li>"&vbcrlf
	rs.movenext
	loop
	rs.close
	set rs=nothing
    str=str&"</ul>"&vbcrlf
    str=str&"</div>"&vbcrlf
    NewAsk=str
End Function

Function ZeroAsk()
Dim rs,sql,str
    str=str&"<div class=""x-next"">"&vbcrlf
    str=str&"<ul>"&vbcrlf
	set rs= Server.CreateObject("adodb.recordset")
	sql="select top 6 askid,title,asktime,classid,classname from "&predb&"Ask a inner join "&predb&"Class b on a.sclass=b.classid where a.ispass=1 and ansNum=0 Order by AskID desc"
	rs.open sql,conn,1,1
	do while not rs.eof
	str=str&"<li class=""l1"">[<a href="""
    IF setting(34)=0 Then
	str=str&"List.asp?classid="&rs("CLassID")
	Else
	str=str&siteInfo(1)&"List-"&rs("CLassID")&".html"
	End IF
	str=str&""" title="""&rs("classname")&""">"&AskD.leftstr(rs("classname"),8)&"</a>]</li>"&vbcrlf
	str=str&"<li class=""l2""><a href="""
  IF setting(34)=0 Then
  str=str&"ask.asp?id="&rs("askid")&""
  Else
  str=str&siteInfo(1)&"ask-"&rs("askid")&".html"
  End IF
  str=str&""">"&AskD.leftstr(rs("title"),42)&"</a></li>"&vbcrlf
    str=str&"<li class=""l3"">"&AskD.Ftime(rs("asktime"))&"</li>"&vbcrlf
	rs.movenext
	loop
	rs.close
	set rs=nothing
    str=str&"</ul>"&vbcrlf
    str=str&"</div>"&vbcrlf
    ZeroAsk=str
End Function

Function TpAsk()
Dim rs,sql,str
    str=str&"<div class=""x-next"">"&vbcrlf
    str=str&"<ul>"&vbcrlf
	set rs= Server.CreateObject("adodb.recordset")
	sql="select top 6 askid,title,asktime,classid,classname from "&predb&"Ask a inner join "&predb&"Class b on a.sclass=b.classid where a.ispass=1 and state=4 Order by AskID desc"
	rs.open sql,conn,1,1
	do while not rs.eof
	str=str&"<li class=""l1"">[<a href="""
    IF setting(34)=0 Then
	str=str&"List.asp?classid="&rs("CLassID")
	Else
	str=str&siteInfo(1)&"List-"&rs("CLassID")&".html"
	End IF
	str=str&""" title="""&rs("classname")&""">"&AskD.leftstr(rs("classname"),8)&"</a>]</li>"&vbcrlf
	str=str&"<li class=""l2""><a href="""
  IF setting(34)=0 Then
  str=str&"ask.asp?id="&rs("askid")&""
  Else
  str=str&siteInfo(1)&"ask-"&rs("askid")&".html"
  End IF
  str=str&""">"&AskD.leftstr(rs("title"),42)&"</a></li>"&vbcrlf
    str=str&"<li class=""l3"">"&AskD.Ftime(rs("asktime"))&"</li>"&vbcrlf
	rs.movenext
	loop
	rs.close
	set rs=nothing
    str=str&"</ul>"&vbcrlf
    str=str&"</div>"&vbcrlf
    TpAsk=str
End Function

Function TodayStrong()
Dim i,str,rs,strongID,strongT,strongP,strongC,xgstrong,n,rs1,display
i=0
set rs=conn.execute("select top 5 askid,title,content,Upfile,xgstrong from "&predb&"ask where isstrong=1 and ispass=1 order by strongtime desc")
do while not rs.eof	   
	   strongID=rs("askid")
	   strongT=AskD.leftstr(rs("title"),16)
	   strongP="UploadFile/"&rs("upfile")
	   strongC=rs("content")
	   if isnull(strongc) then strongC=""
	   strongC=AskD.leftstr(AskD.RemoveHTML2(strongC),48)
	   xgstrong=" "&rs("xgstrong")&","
	   xgstrong=split(xgstrong,",")
	   if i=0 Then display="block" else display="none"
	   str=str&"<div id=""d"&i&""" class=""r-next"" style=""display:"&display&""">"&vbcrlf
	   str=str&"<div class=""t1""><img src="""&strongP&""" alt="""" width=""210"" height=""70""/></div>"&vbcrlf
	   str=str&"<div class=""t2"">"&vbcrlf
	   str=str&"<div class=""sth2""><h2><a href="""
  IF setting(34)=0 Then
  str=str&"ask.asp?id="&strongID&""
  Else
  str=str&siteInfo(1)&"ask-"&strongID&".html"
  End IF
  str=str&""">"&strongT&"</a></h2></div>"&vbcrlf
	   str=str&"<div class=""t-nr"">&nbsp;&nbsp;&nbsp; "&strongC&"</div>"&vbcrlf
	   str=str&"</div>"&vbcrlf
	   str=str&"<div class=""t3"">"&vbcrlf
	   str=str&"<ul>"&vbcrlf

	  For n=0 To Ubound(xgstrong)
	  IF Trim(xgstrong(n))<>"" Then
	  Set rs1=conn.execute("select title from "&predb&"ask where askid="&Trim(xgstrong(n)))
	  
	  str=str&"<li><img src=""Template/"&siteInfo(11)&"/images/dot.gif"" alt=""""/><a target=""_blank"" href="""
  IF setting(34)=0 Then
  str=str&"ask.asp?id="&Trim(xgstrong(n))&""
  Else
  str=str&siteInfo(1)&"ask-"&Trim(xgstrong(n))&".html"
  End IF
  str=str&""">"&AskD.leftstr(rs1("title"),30)&"</a></li>"&vbcrlf

	  Set rs1=nothing
	  End IF
	  Next
	  str=str&"</ul>"&vbcrlf
      str=str&"</div>"&vbcrlf
	  str=str&"</div>"&vbcrlf
i=i+1
rs.movenext
loop
set rs=nothing
TodayStrong=str
End Function

Function Announce()
Dim rs,str,xtype,i
    str=str&"<div class=""r-next"">"&vbcrlf
	  set rs=conn.execute("select top 10 * from "&predb&"Announce order by isnew desc,id desc")
	  IF not (rs.bof and rs.eof) Then
	  xtype=rs("xtype")
	  IF xtype=1 Then
	  
	str=str&"<div style=""height:88px"">"&vbcrlf
    str=str&"<div class=""Announce1"">"&rs("title")&" <font color=""#FF0000"">New</font></div>"&vbcrlf
    str=str&"<div class=""Announce2""><a href=""AnnounceS.asp?id="&rs("id")&""">"&AskD.leftstr(rs("content"),110)&"></a></div>"&vbcrlf
    str=str&"<div class=""Announce3"">"&rs("admin")&">("& FormatDateTime(rs("addtime"),vbshortdate)&")</div>"&vbcrlf
	str=str&"</div>"&vbcrlf

	  ElseIF xtype=2 Then
	  
    str=str&"<div id=""box"" style=""overflow: hidden; height:88px; width:100%;"">"&vbcrlf
    str=str&"<div id=""box1"">"&vbcrlf
    str=str&"<ul class=""Announce"">"&vbcrlf

                i=0
                do while not rs.eof
                i=i+1
	str=str&"<li><img src=""Template/"&siteInfo(11)&"/images/dot.gif"" alt=""""/><a href=""AnnounceS.asp?id="&rs("id")&""">"&AskD.leftstr(rs("title"),24)&"</a>"
	If i=1 Then
	str=str&"<font color=""#FF0000"">New</font>"&vbcrlf
	End If
	str=str&"</li>"&vbcrlf

                rs.movenext
                loop
				
    str=str&"</ul>"&vbcrlf
    str=str&"</div>"&vbcrlf
    str=str&"<div id=""box2""></div>"&vbcrlf
    str=str&"</div>"&vbcrlf
    str=str&"<script language=""javascript"" type=""text/javascript"">"&vbcrlf
    str=str&"var m = new Marquee(22,10,88,'box','box1','box2',"&i&");"&vbcrlf
	str=str&"m.start();"&vbcrlf
    str=str&"</script>"&vbcrlf
	  Else
	  
    str=str&"<div>"&vbcrlf
    str=str&"<ul class=""Announce"">"&vbcrlf
		i=0
		do while not rs.eof
		i=i+1
		IF i>4 Then Exit Do
		
    str=str&"<li><img src=""Template/"&siteInfo(11)&"/images/dot.gif"" alt=""""/><a href=""AnnounceS.asp?id="&rs("id")&""">"&AskD.leftstr(rs("title"),24)&"</a>"
		If i=1 Then
	str=str&"<font color=""#FF0000"">New</font>"
		End If
    str=str&"</li>"&vbcrlf

		rs.movenext
		loop

    str=str&"</ul>"&vbcrlf
    str=str&"</div>"&vbcrlf
	  End IF
	  End IF
	  Set rs=nothing

    str=str&"<div class=""Announce3""><a href=""Announce.asp"" target=""_blank"">更多&raquo;</a></div>"&vbcrlf
    str=str&"</div>"&vbcrlf
    Announce=str
End Function

Function Honours()
Dim rs,rs1,str,n,face
str=str&"<div class=""r-next"">"&vbcrlf
	   set rs=conn.execute("select top 1 * from "&predb&"user where isstrong=1 order by strongtime desc,id desc")
	   
IF not(rs.bof and rs.eof) Then
if rs("face")&""="" then face="face/info.gif" else face=rs("face")
str=str&"<div>"&vbcrlf
str=str&"<div class=""u-pic""><img src=""UploadFile/"&face&""" alt="""" width=""50"" height=""50""/></div>"&vbcrlf
str=str&"<div class=""u-info"">"&vbcrlf
str=str&"<ul>"&vbcrlf
str=str&"<li><a href=""user/userinfo.asp?id="&rs("id")&""">"&rs("userid")&"</a></li>"&vbcrlf

		  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
		  
str=str&"<li>头衔："&rs1("gradename")&"</li>"&vbcrlf

		  set rs1=nothing
		  
str=str&"<li>积分："&rs("score")&"</li>"&vbcrlf
str=str&"</ul>"&vbcrlf
str=str&"</div>"&vbcrlf    
str=str&"</div>"&vbcrlf   
str=str&"<div class=""t4"">"&vbcrlf  
str=str&"<ul>"&vbcrlf
        
	  Dim strongask
	  strongask=split(rs("strongask"),",")
	  For n=0 To Ubound(strongask)
	  IF Trim(strongask(n))<>"" Then
	  Set rs1=conn.execute("select title from "&predb&"ask where askid="&Trim(strongask(n)))
	  
str=str&"<li><img src=""Template/"&siteInfo(11)&"/images/dot.gif"" alt=""""/><a target=""_blank"" href="""
  IF setting(34)=0 Then
  str=str&"ask.asp?id="&Trim(strongask(n))&""
  Else
  str=str&siteInfo(1)&"ask-"&Trim(strongask(n))&".html"
  End IF
  str=str&""">"& AskD.leftstr(rs1("title"),30)&"</a></li>"&vbcrlf

	  Set rs1=nothing
	  End IF
	  Next
str=str&"</ul>"&vbcrlf
str=str&"</div>"&vbcrlf

		End IF
		set rs=nothing
str=str&"</div>"&vbcrlf
Honours =str  
End Function

Function showscore()
Dim rs,i,str
str=str&"<div class=""r-next"">"&vbcrlf
str=str&"<div class=""u-list"" id=""u1"">"&vbcrlf

		i=0
		set rs=conn.execute("select top 5 id,userid,MonthScore from "&predb&"user order by MonthScore desc,id desc")
		do while not rs.eof
		i=i+1

str=str&"<ul>"&vbcrlf
str=str&"<li class=""u-b1"">"&i&"</li>"&vbcrlf
str=str&"<li class=""u-b2""><a href=""user/userinfo.asp?id="&rs("id")&""">"&rs("userid")&"</a></li>"&vbcrlf
str=str&"<li class=""u-b3""><img src=""Template/"&siteInfo(11)&"/images/up.gif"" alt="""" align=""middle""/> "&rs("MonthScore")&"</li>"&vbcrlf
str=str&"</ul>"&vbcrlf

	    rs.movenext
		loop
		set rs=nothing
		
str=str&"</div>"&vbcrlf
str=str&"<div class=""u-list"" id=""u2"" style=""display:none"">"&vbcrlf

		i=0
		set rs=conn.execute("select top 5 id,userid,WeekScore from "&predb&"user order by WeekScore desc,id desc")
		do while not rs.eof
		i=i+1
		
str=str&"<ul>"&vbcrlf
str=str&"<li class=""u-b1"">"&i&"</li>"&vbcrlf
str=str&"<li class=""u-b2""><a href=""user/userinfo.asp?id="&rs("id")&""">"&rs("userid")&"</a></li>"&vbcrlf
str=str&"<li class=""u-b3""><img src=""Template/"&siteInfo(11)&"/images/up.gif"" alt="""" align=""middle""/> "&rs("WeekScore")&"</li>"&vbcrlf
str=str&"</ul>"&vbcrlf

	    rs.movenext
		loop
		set rs=nothing
str=str&"</div>"&vbcrlf
str=str&"<div class=""u-list"" id=""u3"" style=""display:none"">"&vbcrlf
        
		i=0
		set rs=conn.execute("select top 5 id,userid,DayScore from "&predb&"user order by DayScore desc,id desc")
		do while not rs.eof
		i=i+1
		
str=str&"<ul>"&vbcrlf
str=str&"<li class=""u-b1"">"&i&"</li>"&vbcrlf
str=str&"<li class=""u-b2""><a href=""user/userinfo.asp?id="&rs("id")&""">"&rs("userid")&"</a></li>"&vbcrlf
str=str&"<li class=""u-b3""><img src=""Template/"&siteInfo(11)&"/images/up.gif"" alt="""" align=""middle""/> "&rs("DayScore")&"</li>"&vbcrlf
str=str&"</ul>"&vbcrlf

	    rs.movenext
		loop
		set rs=nothing
str=str&"</div>"&vbcrlf
str=str&"</div>"&vbcrlf   
showscore=str
End Function

Function LoginInfo()
IF Request.Cookies("Muser")<>"" Then
Dim rs,str,grade,gradetype,Uscore,isActivated,gradename
str=str&"<div class=""ubs1"">"&vbcrlf
str=str&"<div class=""uminfo1"">用户信息</div>"&vbcrlf 
str=str&"<div class=""uminfo2""><a href=""user/loginout.asp""><img src=""Template/"&siteInfo(11)&"/images/back.gif"" alt="""" border=""0""/> 退出</a></div>"&vbcrlf 
str=str&"</div>"&vbcrlf 
str=str&"<div class=""ubs3"">"&vbcrlf 
str=str&"<div class=""ubs6"">您好，"&Request.Cookies("Musername")&"</div>"&vbcrlf 

		  set rs=conn.execute("select grade,gradetype,score,isActivated from "&predb&"user where id="&Request.Cookies("Muser"))
              grade=rs("grade")
			  gradetype=rs("gradetype")
			  Uscore=rs("score")
			  isActivated=rs("isActivated")
		  set rs=nothing
		  
		  if gradetype=0 then
		     set rs=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="&grade)
		  else
		      set rs=conn.execute("select gradename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.id="&gradetype&" and a.grade="&grade)
		  end if
		  IF not(rs.bof and rs.eof) then
		     gradename=rs("gradename")
		  end if
		  set rs=nothing
		  
str=str&"<div class=""ubs7"">等级头衔："& gradename&"</div>"&vbcrlf 
str=str&"<div class=""ubs7"">积分："&Uscore&"&nbsp; <a href=""user/userinfo.asp?id="& Request.Cookies("Muser") &"&s=2"">积分明细</a></div>"&vbcrlf 
str=str&"<div class=""ubs8"">"&vbcrlf 
str=str&""&vbcrlf 

If setting(43)="0" or regform(3)="0" Then

	If isActivated=1 Then
str=str&"您已激活邮箱，可及时获取最新问答"&vbcrlf 
    Else
str=str&"<a href=""user/Activated.asp?act=chk"">激活邮箱，及时获取最新问答</a>"&vbcrlf 
    End If
Else
str=str&"系统未开通邮件机制！"&vbcrlf 
End If
str=str&"</div>"&vbcrlf 
str=str&"<div class=""ubs7""><a href=""myAsk.asp"">我要提问</a>&nbsp; <a href=""list.asp"">我要回答</a>&nbsp; <a href=""user/userinfo.asp?id="& Request.Cookies("Muser") &""">个人中心</a></div>"&vbcrlf    
str=str&"</div>"&vbcrlf  
str=str&"<div class=""ubs2"">·恭喜，您已经成功登录</div>"&vbcrlf 
   LoginInfo=str 
End IF  
End Function
%>