<!--#include file="../conn.asp"-->
<!--#include file="Function.asp"-->
<%
Response.ContentType="application/xml"
Response.Write("<?xml version=""1.0"" encoding=""utf-8""?>")
Response.Write("<mytitle>")

Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	opendb
	set AskD.myConn =conn
	AskD.myPredb =predb
	AskD.Getsetting()
	siteinfo=AskD.siteinfo
	setting=AskD.setting
	
const pk=2 '截取字符数
dim rs,sql,title,key,i,strsql,rs1,ansContent
title=Trim(Request.Form("title"))

sql="select top 6 askid,title from "&predb&"ask where ispass=1 and ("
	strsql="title like '%"&left(title,pk)&"%'"
for i=pk+1 to len(title)
    key=mid(title,i,pk)
	if len(key)<pk then exit for
	strsql=strsql&" or title like '%"&key&"%'"
next
sql=sql&strsql
sql=sql&") order by askid desc"

	set rs= Server.CreateObject("adodb.recordset")
	rs.open sql,conn,1,1
	if rs.bof and rs.eof then
		Response.Write("<siteinfo><title>#</title></siteinfo>")
	else
	do while not rs.eof
		set rs1=conn.execute("select top 1 ansContent from "&predb&"ans where askid="&rs("askid")&" and ispass=1 order by iscn desc")
		IF rs1.bof and rs1.eof then
		   ansContent="…"
		Else
		   ansContent=rs1("ansContent")
		End IF
		set rs1=nothing
		Response.Write("<siteinfo><title><![CDATA[<a href=""")
	
		  IF setting(34)=0 Then
			Response.Write "ask.asp?id="&rs("askid")&""
		  Else
			Response.Write "ask-"&rs("askid")&".html"
		  End IF

		Response.Write(""" target=""_blank"">"&AskD.Leftstr(rs("title"),36)&"</a>]]></title><ansContent><![CDATA["&AskD.Leftstr(AskD.RemoveHTML(ansContent),60)&"]]></ansContent></siteinfo>")
	rs.movenext
	loop
	end if
	rs.close	
	set rs=nothing
	
	set AskD.myConn =Nothing
closedb
Set AskD = Nothing
Response.Write("</mytitle>")
%>