ol=ol&"<select name=""space"">"
if cstr(space)="0"then selected=" selected=""selected""" else selected=""
ol=ol&"<option value=""0"""&selected&">"&king.lang("common/title")&"</option>"
if cstr(space)="1"then selected=" selected=""selected""" else selected=""
ol=ol&"<option value=""1"""&selected&">"&king.lang("common/content")&"</option>"
if cstr(space)="2"then selected=" selected=""selected""" else selected=""
ol=ol&"<option value=""2"""&selected&">"&king.lang("common/author")&"</option>"
ol=ol&"</select> "
ol=ol&"<select name=""classid"">"
set rs=conn.execute("select distinct classid from kingmenu where not classid in (0,1,4,6) order by classid")
if not rs.eof and not rs.bof then
while (not rs.eof)
if cstr(classid)=cstr(rs(0)) then selected=" selected=""selected""" else selected=""
ol=ol&"<option value="""&rs(0)&""""&selected&">"&king.lang("sub/s"&rs(0))&"</option>"
rs.movenext
wend
else
ol=ol&"<option value=""0"">"&king.lang("system/error/notmenu")&"</option>"
end if
set rs=nothing
ol=ol&"</select> "
ol=ol&"<input type=""hidden"" name=""king"" value=""kingcms"" /> "
ol=ol&"<input type=""hidden"" name=""rn"" value="""&king.rn&""" />"
ol=ol&"<input type=""submit"" name=""submits"" value="""&king.lang("common/search")&""" /> <a href=""search.asp"">高级搜索</a>"
ol=ol&"</form>"
ol=ol&"<dl>"
dim outdt,outdd1,outdd2,menuname,menupath,querycount,datamenu,bbstype
'参数处理并显示 sql填写规则:第一个必须为menuid!!!
select case cstr(classid)
case"2"
sql=" menuid,arttitle,artdescription,artauthor,artdate,artpath,artgrade,artid "'7
if cstr(space)="0" then'只查询标题
insql=IIII1("arttitle",killjapan(formatquery),1)
elseif cstr(space)="1" then
insql=IIII1("artcontent",killjapan(formatquery),1)
else
insql=IIII1("artauthor",killjapan(formatquery),1)
end if
if len(insql)>2 then insql=" and "&insql else insql=""
sql="select top 1000 "&sql&" from kingart where artshow=1 and menuid<>0 "&insql&" order by artorder desc,artid desc;"
king.open sql,king.page&"?pid=$&rn="&king.rn&"&query="&server.urlencode(query)&"&classid="&classid&"&space="&space,1
querycount=conn.execute("select count(artid) from kingart where artshow=1 and menuid<>0 "&insql&";")(0)
case"10"
sql=" menuid,bbstitle,bbscontent,username,bbsdate,topicid,lastdate,sysdate "'7
if cstr(space)="0" then'只查询标题
insql=IIII1("bbstitle",killjapan(formatquery),1)
elseif cstr(space)="1" then
insql=IIII1("bbscontent",killjapan(formatquery),1)
else
insql=IIII1("username",killjapan(formatquery),1)
end if
if len(insql)>2 then insql=" and "&insql else insql=""
sql="select top 1000 "&sql&",menuid from kingtopic where topicdel=0 "&insql&" order by lastdate desc,topicid desc;"
king.open sql,king.page&"?pid=$&rn="&king.rn&"&query="&server.urlencode(query)&"&classid="&classid&"&space="&space,1
querycount=conn.execute("select count(topicid) from kingtopic where topicdel=0 "&insql&";")(0)
case else king.error("system/error/search/classid")
end select
'搜索数量
if king.length>=0 then
ol=ol&"<p>约有"&formatnumber(querycount,0,true)&"项符合 <strong>"&query&"</strong> 的查询结果,以下是第"&cstr((king.pid-1)*king.rn+1)&"-"&cstr(king.count-(king.pid-1)*king.rn)&"项。 (搜索用时 "&formatnumber(timer()-king.tDiff,2,true)&" 秒)</p>"
else
ol=ol&"<p>找不到和您的查询 "&query&" 相符的网页。</p>"
end if
set rs=conn.execute("select menuid,menuname,menupath,bbstype from kingmenu;")
if not rs.eof and not rs.bof then
datamenu=rs.getrows()
end if
set rs=nothing
'循环输出
for i=0 to king.length'循环一遍
for j=0 to ubound(datamenu,2)
if cstr(datamenu(0,j))=cstr(king.data(0,i)) then
menuname=datamenu(1,j)
menupath=datamenu(2,j)
bbstype=datamenu(3,j)
exit for
end if
next
select case cstr(classid)
case"2"
if ll11("0",king.data(6,i)) then'静态
if cstr(king.named)="1" then
outdt="<a target=""_blank"" href=""../"&menupath&"/"&III11(king.data(4,i))&"/"&king.data(5,i)&king.ext&""">"&king.keywordlight(htmlencode(king.data(1,i)),formatquery)&"</a>"
else
outdt="<a target=""_blank"" href=""../"&menupath&"/"&king.data(5,i)&king.ext&""">"&king.keywordlight(htmlencode(king.data(1,i)),formatquery)&"</a>"
end if
else
outdt="<a target=""_blank"" href=""article.asp?/"&king.data(7,i)&king.ext&""">"&king.keywordlight(htmlencode(king.data(1,i)),formatquery)&"</a>"
end if
outdd1=king.keywordlight(htmlencode(king.data(2,i)),formatquery)
outdd2="<i>"&king.data(4,i)&"</i> - <span>"&king.keywordlight(htmlencode(king.data(3,i)),formatquery)&"</span> - <a target=""_blank"" href=""../"&menupath&"/index"&king.ext&""">"&htmlencode(menuname)&"</a> - <a target=""_blank"" href=""link.asp?url="&server.urlencode(replace(king_link,"{king}",server.urlencode(king.data(1,i))))&""">类似网页</a>"
case"10"
'" menuid,bbstitle,bbscontent,username,bbsdate,topicid,lastdate,sysdate "'7
if ll11("0,1",bbstype) then
outdt="<a target=""_blank"" href=""../"&menupath&"/"&III11(king.data(7,i))&"/"&king.data(5,i)&king.ext&""">"&king.keywordlight(htmlencode(king.data(1,i)),formatquery)&"</a>"
else
outdt="<a target=""_blank"" href=""topic.asp?/"&king.data(5,i)&king.ext&""">"&king.keywordlight(htmlencode(king.data(1,i)),formatquery)&"</a>"
end if
outdd1=king.keywordlight(htmlencode(king.lefte(king.cls(llIIl(king.data(2,i))),180)),formatquery)
outdd2="<i>"&king.data(4,i)&"</i> - <span><a target=""_blank"" href=""user.asp?username="&server.urlencode(king.data(3,i))&""">"&king.keywordlight(htmlencode(king.data(3,i)),formatquery)&"</a></span> - <a target=""_blank"" href=""../"&menupath&"/index"&king.ext&""">"&htmlencode(menuname)&"</a> - <a target=""_blank"" href=""link.asp?url="&server.urlencode(replace(king_link,"{king}",server.urlencode(king.data(1,i))))&""">类似网页</a>"
end select
'每页显示数
ol=ol&"<dt>"&outdt&"</dt>"
ol=ol&"<dd>"&outdd1&"</dd>"
ol=ol&"<dd>"&outdd2&"</dd>"
next
if cstr(king.length)="-1" then ol=ol&"<dt>"&king.lang("system/error/search")&"</dt>"
ol=ol&"</dl>"
ol=ol&king.plist
ol=ol&"</div>"
end sub
'outhtm *** *** www.KingCMS.com *** ***
sub king_outhtm()
%>{king:search/}
<%end sub%>
rem query :关键字
rem space :搜索范围,标题和索引(内容)
rem rn :每页显示
rem classid :搜索类别,即论坛/或文章
dim king,query'outhtm的简写,全局变量
query=trim(request("query"))
set king=new kingcms
king.head 0,0
select case IIII1("keyword",clskeyword(query),1)'query
case "","()" king_def()
case else king_search()
end select
king_outhtm
set king=nothing
'def *** *** www.KingCMS.com *** ***
sub king_def()'需要加入标题,访问级别
dim classid,rs,i,selected
dim space
space=l1ll("space",2)
classid=l1ll("classid",2)
'搜索范围
ol=ol&"<tr><th>搜索范围</th><td>"
ol=ol&"<select name=""space"">"
if cstr(space)="0" then selected=" selected=""selected""" else selected=""
ol=ol&"<option value=""0"""&selected&">"&king.lang("common/title")&"</option>"
if cstr(space)="1"then selected=" selected=""selected""" else selected=""
ol=ol&"<option value=""1"""&selected&">"&king.lang("common/content")&"</option>"
if cstr(space)="2"then selected=" selected=""selected""" else selected=""
ol=ol&"<option value=""2"""&selected&">"&king.lang("common/author")&"</option>"
ol=ol&"</select>"
ol=ol&"</td></tr>"
'每页显示
ol=ol&"<tr><th>每页显示</th><td>"
ol=ol&"<select name=""rn"">"
if cstr(king.rn)="10" then selected=" selected=""selected""" else selected=""
ol=ol&"<option value=""10"""&selected&">10</option>"
if cstr(king.rn)="20" then selected=" selected=""selected""" else selected=""
ol=ol&"<option value=""20"""&selected&">20</option>"
if cstr(king.rn)="50" then selected=" selected=""selected""" else selected=""
ol=ol&"<option value=""50"""&selected&">50</option>"
if cstr(king.rn)="100" then selected=" selected=""selected""" else selected=""
ol=ol&"<option value=""100"""&selected&">100</option>"
ol=ol&"</select>"
ol=ol&"</td></tr>"
'栏目
ol=ol&"<tr><th>搜索对象</th><td>"
ol=ol&"<select name=""classid"">"
set rs=conn.execute("select distinct classid from kingmenu where not classid in (0,1,4,6) order by classid")
if not rs.eof and not rs.bof then
while (not rs.eof)
if cstr(classid)=cstr(rs(0)) then selected=" selected=""selected""" else selected=""
ol=ol&"<option value="""&rs(0)&""""&selected&">"&king.lang("sub/s"&rs(0))&"</option>"
rs.movenext
wend
else
ol=ol&"<option value=""0"">"&king.lang("system/error/notmenu")&"</option>"
end if
set rs=nothing
ol=ol&"</select>"
ol=ol&"</td></tr>"