<!--#include file="conn.asp"-->
<!--#include file="chklogin.asp"-->
<!--#include file="inc/function.asp"-->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<%
dim hdnr,rs,sql,show_name
hdnr=HTMLcode(RemoveHTML(request("hdnr")))
show_name=request.QueryString("hdwt")

dim rs1,sql1
set rs1=server.CreateObject("adodb.recordset")
sql1 ="Select * from kw_wt where wt_filename='"&show_name&"'"
rs1.open sql1,conn,1,1
email=rs1("email")
qm=rs1("qm")
'if rs1("userid")=session("userid") then
'response.Write("不能回答自己的提问")
'response.End()
'end if

if username="" then
username="admin"
end if

if hdnr<>"" then
set rs=server.CreateObject("adodb.recordset")
sql ="Select * from kw_user where username='"&session("userid")&"'"
rs.open sql,conn,1,3
rs("jifen")=rs("jifen")+10
rs.update
rs.close
set rs=nothing

set rs=server.CreateObject("adodb.recordset")
sql ="Select * from kw_hd where hdques='"&show_name&"'"
rs.open sql,conn,1,3
rs.addnew
rs("wtans")=hdnr
rs("userid")=session("userid")
rs("usertx")=session("usertx")
rs("hdtime")=now()
rs("zt")=1
rs("hdques")=show_name
rs.update

	dim show
	show=ReadTemplate("template/show_temp.html")
	show=replace(show,"{$siteinfo}",rs1("bt"))
	show=replace(show,"{$daohang}",daohang())
	show=replace(show,"{$show_wt}",show_wt())
	show=replace(show,"{$hd_count}",hd_count())
	show=replace(show,"{$wt_filename}",show_name)
	show=replace(show,"{$show_hd}",show_hd(rs1("id")))
	show=replace(show,"{$show_best}",show_best())
	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 BuildFile(Server.MapPath("show/"&show_name),show)

rs.close
set rs=nothing
rs1.close
set rs1=nothing
closedb

response.write "<script language=javascript>alert('恭喜！回答成功了');history.go(-1);</script>"
else
response.write "<script language=javascript>alert('抱歉！回答没有成功');history.go(-1);</script>"
end if

Function hd_count()
dim rs,sql
set rs=server.CreateObject("adodb.recordset")
sql ="Select * from kw_hd where hdques='"&show_name&"'"
rs.open sql,conn,1,1
hd_count=rs.recordcount
rs.close
set rs=nothing
End Function

Function show_best()
dim rs,sql
set rs=server.CreateObject("adodb.recordset")
sql ="Select * from kw_hd where hdques='"&show_name&"' and zt='2'"
rs.open sql,conn,1,1
if rs.recordcount<>0 then
show_best="<table width=""670""  border=""0"" cellspacing=""0"" cellpadding=""0"" class=""table_best"">"&vbcrlf
show_best=show_best&"<tr>"&vbcrlf
show_best=show_best&"<td class=""back"" style=""padding-top: 1px; padding-bottom: 1px"">&nbsp;<img src=""../../images/cn_point.gif"">&nbsp;最佳答案</td>"&vbcrlf
show_best=show_best&"</tr>"&vbcrlf
show_best=show_best&"<tr>"&vbcrlf
show_best=show_best&"<td>"&vbcrlf
show_best=show_best&"<table width=""94%""  border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
show_best=show_best&"<tr>"&vbcrlf
show_best=show_best&"<td width=""2%"" rowspan=""4"">&nbsp;</td>"&vbcrlf
show_best=show_best&"<td width=""98%"" height=""60""><font style=""font-size:14"">"&rs("wtans")&"</font></td>"&vbcrlf
show_best=show_best&"</tr>"&vbcrlf
show_best=show_best&"<tr>"&vbcrlf
show_best=show_best&"<td align=""right""><font color=""#666666"">回答者：</font>"
   dim rs1,sql1
   set rs1=server.CreateObject("adodb.recordset")
   sql1 ="Select * from kw_user where username='"&rs("userid")&"'"
   rs1.open sql1,conn,1,1
   if rs1("zhuan")=1 then
show_best=show_best&"<img src=""/ask/images/zhuan.gif"">"
   end if
show_best=show_best&""&rs("userid")&"</td>"&vbcrlf
show_best=show_best&"</tr>"&vbcrlf
   if rs1("zhuan")=1 then
   end if
   rs1.close
   set rs1=nothing
show_best=show_best&"<tr>"&vbcrlf
show_best=show_best&"<td><hr color=""#666666"" align=""center"" width=""96%"" size=""1""></td>"&vbcrlf
show_best=show_best&"</tr>"&vbcrlf
show_best=show_best&"</table>"&vbcrlf
show_best=show_best&"</td></tr>"&vbcrlf
show_best=show_best&"</table>"&vbcrlf
show_best=show_best&"<table width=""100%""  border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
show_best=show_best&"<tr>"&vbcrlf
show_best=show_best&"<td height=""8""></td>"&vbcrlf
show_best=show_best&"</tr>"&vbcrlf
show_best=show_best&"</table>"&vbcrlf
end if
rs.close
set rs=nothing
End Function

Function show_hd(wtid)
dim rs,sql,i,str
set rs=server.CreateObject("adodb.recordset")
sql ="Select * from kw_hd where hdques='"&show_name&"' and zt='1' order by id desc"
rs.open sql,conn,1,1
if rs.bof and rs.bof then
show_hd="暂无回答,欢迎您的参与!"
else
for i=1 to rs.recordcount
str="<table width=""94%""  border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
str=str&"<tr>"&vbcrlf
str=str&"<td width=""2%"" rowspan=""4"">&nbsp;</td>"&vbcrlf
str=str&"<td width=""98%"" height=""60""><font style=""font-size:14"">"&rs("wtans")&"</font></td>"&vbcrlf
str=str&"</tr>"&vbcrlf
str=str&"<tr>"&vbcrlf
str=str&"<td align=""right"">"
   dim rs1,sql1,rs2,sql2
    set rs2=server.CreateObject("adodb.recordset")
    sql2 ="Select * from kw_wt where wt_filename='"&rs("hdques")&"'"
    rs2.open sql2,conn,1,1
if rs2("zt")=1 then
str=str&"<script src=""../../cnhd.asp?hdid="&rs("id")&"&wtid="&rs2("id")&"""></script>"
end if
    rs2.close
	set rs2=nothing
str=str&"&nbsp;&nbsp;&nbsp;&nbsp;<font color=""#666666"">回答者：</font>"
   set rs1=server.CreateObject("adodb.recordset")
   sql1 ="Select * from kw_user where username='"&rs("userid")&"'"
   rs1.open sql1,conn,1,1
   if not rs1.eof then
   if rs1("zhuan")=1 then
str=str&"<img src=""../../images/zhuan.gif"">"
   end if
str=str&""&rs("userid")&"</td>"&vbcrlf
str=str&"</tr>"&vbcrlf
   end if
   rs1.close
   set rs1=nothing
str=str&"<tr>"&vbcrlf
str=str&"<td><hr color=""#666666"" align=""center"" width=""96%"" size=""1""></td>"&vbcrlf
str=str&"</tr>"&vbcrlf
str=str&"</table>"&vbcrlf
show_hd=show_hd&str
rs.movenext
next
end if
rs.close
set rs=nothing
End Function

Function Daohang()
Daohang="<a href=""/"">首页</a> → <a href=""../../index.html"">在线答疑</a> → <a href=""../../list.asp?dl="&rs1("dalei")&""">"&rs1("dalei")&"</a> → <a href=""../../list.asp?dl="&rs1("dalei")&"&xl="&rs1("xiaolei")&""">"&rs1("xiaolei")&"</a>"
End Function

Function Show_wt()
Show_wt="<table width=""98%""  border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
Show_wt=Show_wt&"<tr>"&vbcrlf
Show_wt=Show_wt&"<td><font style=""font-size:14""><b>"&rs1("bt")&"</b></font></td>"&vbcrlf
Show_wt=Show_wt&"</tr>"&vbcrlf
Show_wt=Show_wt&"<tr>"&vbcrlf
Show_wt=Show_wt&" <td height=""26""><img src=""../../images/jf_point.gif"">&nbsp;<font color=""#ff5400"">悬赏分："&rs1("xsf")&"</font>&nbsp;&nbsp;<script src=""../../wttime.asp?wtid="&rs1("id")&"""></script></td>"&vbcrlf
Show_wt=Show_wt&"</tr>"&vbcrlf
Show_wt=Show_wt&"<tr>"&vbcrlf
Show_wt=Show_wt&"<td><font style=""font-size:14"">"&rs1("nr")&"</font></td>"&vbcrlf
Show_wt=Show_wt&"</tr>"&vbcrlf
Show_wt=Show_wt&"<tr>"&vbcrlf
Show_wt=Show_wt&"<td align=""right""><font color=""#666666"">提问者：</font><font color=#000000><a href='/ask/list3.asp?key="&qm&"'>"&qm&"</a></td>"&vbcrlf
Show_wt=Show_wt&"</tr>"&vbcrlf
Show_wt=Show_wt&"<tr>"&vbcrlf
Show_wt=Show_wt&"<td align=""right"" height=""30""><script src=""../../change_wt.asp?id="&rs1("id")&"""></script>&nbsp;&nbsp;&nbsp;&nbsp;</td>"&vbcrlf
Show_wt=Show_wt&"</tr>"&vbcrlf
Show_wt=Show_wt&"<tr>"&vbcrlf
Show_wt=Show_wt&"<td height=""40"">&nbsp;&nbsp;&nbsp;&nbsp;<input type=""button"" name=""whd"" value=""我来回答"" onClick=""document.location.href='#hd'"" class=""regbutton""></td>"&vbcrlf
Show_wt=Show_wt&"  </tr></table>"&vbcrlf
End Function
%>

