<%
'option explicit
response.buffer= True
Server.ScriptTimeOut=99999999
%>
<!--#include file="../conn.asp"-->
<!--#include file="../inc/function.asp"-->
<!--#include file="chklogin.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>生成问题</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FF9999"><br>
<br><br>
<br>
<table width="460" border="0" align="center" cellpadding="0" cellspacing="1" class="tablebg">
  <tr bgcolor="#ff6666">
    <td width="91" align="center" bgcolor="#ff6666" id="crhtml"></td>
    <td width="366">
<img src="images/bar.gif" width=0 height=16 id=bar name=bar align=absmiddle>
</td>
  </tr>
  <tr align="center" bgcolor="#ff6666">
    <td colspan="2"><span id="percent">0</span>%</td>
  </tr>
</table>
</body>
</html>
<%

dim rs,sql,id,dl,xl
    id=request.QueryString("id")
	dl=request.Form("dl")
	xl=request.Form("xl")
	
    set rs=server.CreateObject("adodb.recordset")
	if id<>"" then
	sql ="Select * from kw_wt where id="&id
	elseif dl="" then
	sql ="Select * from kw_wt"
	elseif dl<>"" and xl="" then
	sql ="Select * from kw_wt where dalei='"&dl&"'"
	elseif xl<>"" then
	sql ="Select * from kw_wt where xiaolei='"&xl&"'"
	end if
    rs.open sql,conn,1,1
	
	   dim RecordIndex,RecordNum
	   RecordIndex=0
	   RecordNum=rs.recordcount
	   
do while not rs.eof
    dim show_name,show
	show_name=rs("wt_filename")
	show=ReadTemplate("../template/show_temp.html")
	show=replace(show,"{$siteinfo}",rs("bt") & "-康美")
	show=replace(show,"{$daohang}",daohang())
	show=replace(show,"{$show_wt}",show_wt())
	webtop=ReadTemplate("/ask/template/webtop.html")
	webbottom=ReadTemplate("/ask/template/webbottom.html")
	webright=ReadTemplate("/ask/template/webright.html")
	show=replace(show,"{$WebTop}",webtop)
	show=replace(show,"{$WebBottom}",webbottom)
	show=replace(show,"{$WebRight}",webright)

	            dim rs2,sql2
			    set rs2=server.CreateObject("adodb.recordset")
                sql2 ="Select * from kw_hd where hdques='"&rs("wt_filename")&"'"
                rs2.open sql2,conn,1,1
	        show=replace(show,"{$hd_count}",rs2.recordcount)
			    rs2.close
				set rs2=nothing
	
	show=replace(show,"{$wt_filename}",show_name)
	show=replace(show,"{$show_hd}",show_hd())
	show=replace(show,"{$show_best}",show_best())
	Call BuildFile(Server.MapPath("../show/"&show_name),show)
	rs.movenext

	    RecordIndex = RecordIndex + 1
            Call Refresh()
			Call Pause()
loop
rs.close
set rs=nothing  
closedb	

const pausetime=1  '生成文章的暂停时间(1~100)
Sub Pause()
	Dim i,lStep,iCount
	iCount=pausetime
	lStep=200000	
	If  Not IsNumeric(iCount) OR iCount=0 Then Exit Sub
	iCount=CLNG(iCount)
	If iCount>100 Then iCount=100
	For i=1 To iCount * lStep
	Next
End Sub

Sub Refresh()
    Response.Write "<script>" & vbCrLf
    Response.Write "crhtml.innerHTML=""正在生成"";" & vbCrLf
    If RecordNum > 0 Then
        Response.Write "bar.width="
        If Fix((RecordIndex / RecordNum) * 350) = 0 Then
            Response.Write "1;" & vbCrLf
        Else
            Response.Write Fix((RecordIndex / RecordNum) * 350) & ";" & vbCrLf
        End If
            Response.Write "percent.innerHTML=""" & FormatNumber(RecordIndex / RecordNum * 100, 2, -1) & """;" & vbCrLf
    End If
    Response.Write "</script>" & vbCrLf
    Response.Flush
End Sub

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=""100%""  border=""0"" cellspacing=""0"" cellpadding=""0"" class=""zuijia"">"&vbcrlf
show_best=show_best&"<tr>"&vbcrlf
show_best=show_best&"<td class=""back"">&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=""../../images/zhuan.gif"">"
   end if
show_best=show_best&""&rs("userid")&"</td>"&vbcrlf
show_best=show_best&"</tr>"&vbcrlf
   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()
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=""/ask/index.html"">在线答疑</a> >> <a href=""/ask/list.asp?dl="&rs("dalei")&"&xl="&rs("xiaolei")&""">"&rs("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>"&rs("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"">悬赏分："&rs("xsf")&"</font>&nbsp;&nbsp;"

if rs("gq")=2 then
Show_wt=Show_wt&"<font color=#000000>已经过期</font>&nbsp;&nbsp;&nbsp;<font color=#666666>过期时间"&FormatDateTime(now(),vbLongDate)&"</font>"&vbcrlf
elseif rs("zt")=1 then
Show_wt=Show_wt&"<script src=""../../wttime.asp?wtid="&rs("id")&"""></script>"&vbcrlf
elseif rs("zt")=2 then
Show_wt=Show_wt&"<font color=red>已经结束</font>&nbsp;&nbsp;&nbsp;<font color=#666666>结束时间"&FormatDateTime(now(),vbLongDate)&"</font>"&vbcrlf
elseif rs("zt")=3 then
Show_wt=Show_wt&"<font color=red>无满意答案</font>&nbsp;&nbsp;&nbsp;<font color=#666666>操作时间"&FormatDateTime(now(),vbLongDate)&"</font>"&vbcrlf
end if

Show_wt=Show_wt&"</td></tr>"&vbcrlf
Show_wt=Show_wt&"<tr>"&vbcrlf
Show_wt=Show_wt&"<td><font style=""font-size:14"">"&rs("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><a href='/ask/list3.asp?key="&qm&"'>"&qm&"</a></td>"&vbcrlf
Show_wt=Show_wt&"</tr>"&vbcrlf
if rs("zt")=1 then
Show_wt=Show_wt&"<tr>"&vbcrlf
Show_wt=Show_wt&"<td align=""right"" height=""30""><script src=""../../change_wt.asp?id="&rs("id")&"""></script>&nbsp;&nbsp;&nbsp;&nbsp;</td>"&vbcrlf
Show_wt=Show_wt&"</tr>"&vbcrlf
end if
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
%>