<!--#include file="conn.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="config.asp"-->
<%
const index_name="index.html"
Dim oFSO
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
If Application("Kw_do")=false and oFSO.FileExists(Server.mappath(index_name)) and DateDiff("s",Application("Kw_dotime"),Now())<300 Then
	Set oFSO = Nothing
	Response.Redirect(index_name)
Else
	Set oFSO = Nothing
	dim show
	show=ReadTemplate("template/index_temp.html")
	show=replace(show,"{$siteinfo}",sitename&" - 问答首页")
	show=replace(show,"{$show_fl}",show_fl())
	show=replace(show,"{$strong_wt}",strong_wt())
	show=replace(show,"{$wt_count}",wt_count())
	webtop=ReadTemplate("template/webtop.html")
	webbottom=ReadTemplate("template/webbottom.html")
	webright=ReadTemplate("template/webright.html")
	show=replace(show,"{$WebTop}",webtop)
	show=replace(show,"{$WebBottom}",webbottom)
	show=replace(show,"{$WebRight}",webright)
	
	Call ChangeHtml("{$show_user(")
	Call ChangeHtml("{$show_zhuan(")
	Call ChangeHtml("{$strong_list(")
    Call ChangeHtml("{$new_list(")
	Call ChangeHtml("{$hot_list(")
	Call ChangeHtml("{$gf_list(")
	Call ChangeHtml("{$ok_list(")
	
	Call BuildFile(Replace(Server.MapPath("index.asp"),"index.asp",index_name),show)	
	Application.Lock
	Application("Kw_update")=false
	Application("Kw_dotime")=now()
	Application.unLock
		Response.Redirect(index_name)
End If

Function ChangeHtml(code)
on Error Resume Next
    Dim tmp1,tmp2,tmp3
	tmp2=1
 While InStr(tmp2, show,code) > 0
	tmp1=instr(tmp2,show,code)
	tmp2=InStr(tmp1,show,")}")
	tmp3=Mid(show,tmp1,tmp2-tmp1)
	tmp3=Trim(replace(tmp3,code,""))
	select case code
	case "{$new_list("
	show=replace(show,code&tmp3&")}",new_list(int(tmp3)))
	            If Err Then
                Response.Write "<br/>"&code&")}标签有错误，请检查参数"
                Response.End()
                End If
	case "{$show_user("
	show=replace(show,code&tmp3&")}",show_user(int(tmp3)))
	            If Err Then
                Response.Write "<br/>"&code&")}标签有错误，请检查参数"
                Response.End()
                End If
	case "{$strong_list("
	show=replace(show,code&tmp3&")}",strong_list(int(tmp3)))
	            If Err Then
                Response.Write "<br/>"&code&")}标签有错误，请检查参数"
                Response.End()
                End If				
	case "{$hot_list("
	show=replace(show,code&tmp3&")}",hot_list(int(tmp3)))
	            If Err Then
                Response.Write "<br/>"&code&")}标签有错误，请检查参数"
                Response.End()
                End If
	case "{$show_zhuan("
	show=replace(show,code&tmp3&")}",show_zhuan(int(tmp3)))
	            If Err Then
                Response.Write "<br/>"&code&")}标签有错误，请检查参数"
                Response.End()
                End If
	case "{$gf_list("
	show=replace(show,code&tmp3&")}",gf_list(int(tmp3)))
	            If Err Then
                Response.Write "<br/>"&code&")}标签有错误，请检查参数"
                Response.End()
                End If
	case "{$ok_list("
	show=replace(show,code&tmp3&")}",ok_list(int(tmp3)))
	            If Err Then
                Response.Write "<br/>"&code&")}标签有错误，请检查参数"
                Response.End()
                End If
	End Select
  wend
End Function

Function wt_count()
dim rs,sql,str
set rs=server.CreateObject("adodb.recordset")
sql ="SELECT * from kw_wt as A  where (select count(*) from Kw_Hd as B where A.wt_filename=B.hdques)>0"
rs.open sql,conn,1,1
str="&nbsp;已解决问题数："&rs.recordcount
rs.close
set rs=nothing
set rs=server.CreateObject("adodb.recordset")
sql ="SELECT * from kw_wt as A  where (select count(*) from Kw_Hd as B where A.wt_filename=B.hdques)=0"
rs.open sql,conn,1,1
str=str&"<br>&nbsp;待解决问题数："&rs.recordcount-nums
rs.close
set rs=nothing
wt_count=str
End Function

Function strong_wt()
dim rs,sql,i,str
set rs=server.CreateObject("adodb.recordset")
sql ="Select bt,nr,wt_filename from kw_wt where strong=1"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
strong_wt="新数据库,还没有推荐!"
else
str="<table width=""90%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">"&vbcrlf
str=str&"<tr>"&vbcrlf
str=str&"<td height=""8""></td>"&vbcrlf
str=str&"</tr>"&vbcrlf
str=str&"<tr>"&vbcrlf
str=str&"<td align=""center""><img src=""images/strong.gif"" width=""162"" height=""82""></td>"&vbcrlf
str=str&"</tr>"&vbcrlf
str=str&"<tr>"&vbcrlf
str=str&"<td><b>本期推荐：</b>"&leftstr(rs(0),16)&"</td>"&vbcrlf
str=str&"</tr><tr>"&vbcrlf
str=str&"<td>&nbsp;&nbsp;"&leftstr(rs(1),80)&"</td>"&vbcrlf
str=str&"</tr><tr>"&vbcrlf
str=str&"<td>&nbsp;<a href=""show/"&rs(2)&""" target=""_blank""><font color=""#000000"" face=""Arial, Helvetica, sans-serif"">详细内容>></font></a></td>"&vbcrlf
str=str&"</tr>"&vbcrlf
strong_wt=str&"</table>"&vbcrlf
end if
rs.close
set rs=nothing
End Function

Function show_user(n)
dim rs,sql,i,str
set rs=server.CreateObject("adodb.recordset")
sql ="Select username,jifen from kw_user order by jifen desc"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
show_user="新数据库,还没有用户!"
else
str="<table width=""90%"" border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
for i=1 to n
str=str&"<tr height=""26"">"&vbcrlf
str=str&"<td><font face=""Arial, Helvetica, sans-serif"">"&i&"&nbsp;<a href=showuser.asp?userid="&rs(0)&" target=_blank><font color=#000000>"&rs("username")&"</font></a></font></td>"&vbcrlf
str=str&"<td width=""30%"" align=""center"">"&rs(1)&"</td>"&vbcrlf
str=str&"</tr>"&vbcrlf
str=str&"<tr bgcolor=""#D9D9D9"">"&vbcrlf
str=str&"<td height=""1"" colspan=""2""></td>"&vbcrlf
str=str&"</tr>"&vbcrlf
  rs.movenext
    if rs.eof then
	  exit for
	end if
  next
str=str&"<tr>"&vbcrlf
str=str&"<td height=""30"" colspan=""2"">&nbsp;&nbsp;<a href=userlist.asp target=_blank><font color=#000000 face=""Arial, Helvetica, sans-serif""><b>更多>></b></font></a></td>"&vbcrlf
str=str&"</tr>"&vbcrlf
show_user=str&"</table>"&vbcrlf
end if
rs.close
set rs=nothing
End Function

Function show_zhuan(n)
dim rs,sql,i,str
set rs=server.CreateObject("adodb.recordset")
sql ="Select username,zhuan_dl,zhuan_xl from kw_user where zhuan=1 order by jifen desc"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
show_zhuan="新数据库,还没有专家!"
else
str="<table width=""90%"" border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
for i=1 to n
str=str&"<tr height=""26"">"&vbcrlf
str=str&"<td><font face=""Arial, Helvetica, sans-serif"">"&i&"&nbsp;<img src=""images/zhuan.gif"">&nbsp;<a href=showuser.asp?userid="&rs(0)&" target=_blank><font color=#000000>"&rs("username")&"</font></a></font></td>"&vbcrlf
str=str&"<td width=""40%"">"
if rs(2)="" then
str=str&rs(1)
else
str=str&rs(2)
end if
str=str&"</td>"&vbcrlf
str=str&"</tr>"&vbcrlf
str=str&"<tr bgcolor=""#D9D9D9"">"&vbcrlf
str=str&"<td height=""1"" colspan=""2""></td>"&vbcrlf
str=str&"</tr>"&vbcrlf
  rs.movenext
    if rs.eof then
	  exit for
	end if
  next
str=str&"<tr>"&vbcrlf
str=str&"<td height=""30"" colspan=""2"">&nbsp;&nbsp;<a href=userlist.asp?u=1 target=_blank><font color=#000000 face=""Arial, Helvetica, sans-serif""><b>更多>></b></font></a></td>"&vbcrlf
str=str&"</tr>"&vbcrlf
show_zhuan=str&"</table>"&vbcrlf
end if
rs.close
set rs=nothing
End Function


Function show_fl()
dim rs,sql,i,rs1,sql1,i1,str
set rs=server.CreateObject("adodb.recordset")
sql ="Select * from kw_dl order by dldm"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
show_fl="新数据库,还没有分类"
else
for i=1 to rs.recordcount
str="<table width=""98%"" border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
str=str&"<tr>"&vbcrlf
str=str&"<td height=""24px"" colspan=""2"">&nbsp;&nbsp;<a href=""list.asp?dl="&server.URLEncode(rs("dalei"))&""" class=""dl""><b>"&rs("dalei")&"</b></a></td>"&vbcrlf
str=str&"</tr>"&vbcrlf
str=str&"<tr>"&vbcrlf

	set rs1=server.CreateObject("adodb.recordset")
    sql1 ="Select * from kw_xl where dalei='"&rs("dalei")&"' order by xldm"
    rs1.open sql1,conn,1,1
	for i1=1 to rs1.recordcount
	str=str&"<td width=""50%"" height=""24"">&nbsp;&nbsp;<a href=""list.asp?dl="&server.URLEncode(rs("dalei"))&"&xl="&server.URLEncode(rs1("xiaolei"))&""" class=""xl"">"&rs1("xiaolei")&"</a></td>"&vbcrlf
	    if i1 mod 2=0 then
          str=str&"</tr>"
        end if
    rs1.movenext
    next
	rs1.close
	set rs1=nothing
    str=str&"<tr>"&vbcrlf
	str=str&"<td class=""left_bg_a"" colspan=""2""></td>"&vbcrlf
	str=str&"</tr></table>"&vbcrlf
show_fl=show_fl&str
   rs.movenext
   next
end if
   rs.close
   set rs=nothing
End Function

Function new_list(n)
dim str,rs,sql,i
		set rs=server.CreateObject("adodb.recordset")
		sql ="SELECT * from kw_wt as A  where (select count(*) from Kw_Hd as B where A.wt_filename=B.hdques)=0"
		rs.open sql,conn,1,1
if rs.bof and rs.eof then
new_list="<br>没有该类问题"
else
   str="<table width=""100%""  border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
		for i=1 to rs.recordcount
   str=str&"<tr>"&vbcrlf
   str=str&"<td height=""22"">"&vbcrlf
   str=str&"<a href=""list.asp?dl="&server.URLEncode(rs("dalei"))&"&xl="&server.URLEncode(rs("xiaolei"))&"""><font class=""font_fl"">["&rs("xiaolei")&"]</font></a> <a href=""show/"&rs("wt_filename")&""" target=""_blank"">"&leftstr(rs("bt"),50)&"</a>&nbsp;&nbsp;&nbsp;&nbsp;"&vbcrlf
	if rs("zt")=1 then
	     str=str&"<img src=""images/no_point.gif"">"&vbcrlf
	elseif rs("zt")=2 then
	    str=str&"<img src=""images/yes_point.gif"">"&vbcrlf
	elseif rs("zt")=3 then
	    str=str&"<img src=""images/wu_point.gif"">"&vbcrlf
	end if
   str=str&"</td></tr>"&vbcrlf
		rs.movenext
		  if i=n then
		  exit for
		  end if
		next
	new_list=str&"</table>"&vbcrlf
end if
	    rs.close
		set rs=nothing
End Function

Function strong_list(n)
dim str,rs,sql,i
		set rs=server.CreateObject("adodb.recordset")
		sql ="Select * from kw_wt where strong=1 order by id desc"
		rs.open sql,conn,1,1
if rs.bof and rs.eof then
strong_list="<br>没有该类问题"
else
   str="<table width=""100%""  border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
		for i=1 to rs.recordcount
   str=str&"<tr>"&vbcrlf
   str=str&"<td height=""22"">"&vbcrlf
   str=str&"<a href=""list.asp?dl="&server.URLEncode(rs("dalei"))&"&xl="&server.URLEncode(rs("xiaolei"))&"""><font class=""font_fl"">["&rs("xiaolei")&"]</font></a> <a href=""show/"&rs("wt_filename")&""" target=""_blank"">"&leftstr(rs("bt"),50)&"</a>&nbsp;&nbsp;&nbsp;&nbsp;"&vbcrlf
   str=str&"&nbsp;&nbsp;<span style=""color:#FF0000"">荐！</span>"&vbcrlf
   str=str&"</td></tr>"&vbcrlf
		rs.movenext
		  if i=n then
		  exit for
		  end if
		next
	strong_list=str&"</table>"&vbcrlf
end if
	    rs.close
		set rs=nothing
End Function

Function hot_list(n)
        dim str,rs,sql,i		
        set rs=server.CreateObject("adodb.recordset")
		sql ="Select * from kw_wt order by djs desc"
		rs.open sql,conn,1,1
if rs.bof and rs.eof then
hot_list="<br>没有该类问题"
else
str="<table width=""100%""  border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
		for i=1 to rs.recordcount
str=str&"<tr>"&vbcrlf
str=str&"<td height=""22"">"&vbcrlf
str=str&"<a href=""list.asp?dl="&server.URLEncode(rs("dalei"))&"&xl="&server.URLEncode(rs("xiaolei"))&"""><font class=""font_fl"">["&rs("xiaolei")&"]</font></a> <a href=""show/"&rs("wt_filename")&""" target=""_blank"">"&leftstr(rs("bt"),50)&"</a>&nbsp;&nbsp;&nbsp;&nbsp;<img src=""images/hot_point.gif"" width=""22"" height=""10"">"&vbcrlf
str=str&"</td>"&vbcrlf
str=str&"</tr>"&vbcrlf	
    	rs.movenext
		  if i=n then
		  exit for
		  end if
		next
	hot_list=str&"</table>"&vbcrlf
end if
	    rs.close
		set rs=nothing
End Function

Function gf_list(n)
dim str,rs,sql,i
		set rs=server.CreateObject("adodb.recordset")
		sql ="Select * from kw_wt order by xsf desc"
		rs.open sql,conn,1,1
if rs.bof and rs.eof then
gf_list="<br>没有该类问题"
else
str="<table width=""100%""  border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
		for i=1 to rs.recordcount
str=str&"<tr>"&vbcrlf
str=str&"<td height=""22"">"&vbcrlf
str=str&"<a href=""list.asp?dl="&server.URLEncode(rs("dalei"))&"&xl="&server.URLEncode(rs("xiaolei"))&"""><font class=""font_fl"">["&rs("xiaolei")&"]</font></a> <a href=""show/"&rs("wt_filename")&""" target=""_blank"">"&leftstr(rs("bt"),50)&"</a>&nbsp;&nbsp;&nbsp;&nbsp;<img src=""images/jf_point.gif""> <span style=""color:#FF0000;font-size:14px;"">"&rs("xsf")&"</span>"&vbcrlf
str=str&"</td>"&vbcrlf
str=str&"</tr>"&vbcrlf
		rs.movenext
		   if i=n then
		   exit for
		   end if
		next
  gf_list=str&"</table>"&vbcrlf
end if
		rs.close
		set rs=nothing
End Function

Function ok_list(n)
dim str,rs,sql,i
		set rs=server.CreateObject("adodb.recordset")
		sql ="Select* from kw_wt where zt=2 order by id desc"
		rs.open sql,conn,1,1
if rs.bof and rs.eof then
ok_list="<br>没有该类问题"
else
str="<table width=""100%""  border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
		for i=1 to rs.recordcount
str=str&"<tr>"&vbcrlf
str=str&"<td height=""22"">"&vbcrlf
str=str&"<a href=""list.asp?dl="&server.URLEncode(rs("dalei"))&"&xl="&server.URLEncode(rs("xiaolei"))&"""><font class=""font_fl"">["&rs("xiaolei")&"]</font></a> <a href=""show/"&rs("wt_filename")&""" target=""_blank"" >"&leftstr(rs("bt"),50)&"</a>&nbsp;&nbsp;&nbsp;&nbsp;<img src=""images/yes_point.gif"">"&vbcrlf
str=str&"</td>"&vbcrlf
str=str&"</tr>"&vbcrlf
		rs.movenext
		  if i=n then
		  exit for
		  end if
		next
	ok_list=str&"</table>"&vbcrlf	
end if
		rs.close
		set rs=nothing
		closedb
End Function
%>

<!--Function ok_list(n)
dim str,rs,sql,i
		set rs=server.CreateObject("adodb.recordset")
		sql ="SELECT * from kw_wt as A  where (select count(*) from Kw_Hd as B where A.wt_filename=B.hdques)>0"
		rs.open sql,conn,1,1


if rs.bof and rs.eof then
ok_list="<br>没有该类问题"
else
str="<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
		for i=1 to rs.recordcount
str=str&"<tr>"&vbcrlf
str=str&"<td height=""22"">"&vbcrlf
str=str&"<a href=""list.asp?dl="&server.URLEncode(rs("dalei"))&"&xl="&server.URLEncode(rs("xiaolei"))&"""><font class=""font_fl"">["&rs("xiaolei")&"]</font></a> <a href=""show/"&rs("wt_filename")&""" target=""_blank"" class=""bt"">"&leftstr(rs("bt"),32)&"</a>&nbsp;&nbsp;&nbsp;&nbsp;<img src=""images/yes_point.gif"">"&vbcrlf
str=str&"</td>"&vbcrlf
str=str&"</tr>"&vbcrlf
		rs.movenext
		  if i=n then
		  exit for
		  end if
		next
	ok_list=str&"</table>"&vbcrlf	
end if
		rs.close
		set rs=nothing
		closedb
End Function
%>-->