<!--#include file="../inc/conn.asp"-->
<%
'============================================================
'插件名称：搜索
'Website：http://www.sdcms.cn
'Author：sdcms.cn
'Date：2008-10-4
'Edit By IT平民 2009-1-11
'============================================================

set sdcms_p=new sdcms_Power
set sdcms_f=new sdcms_function
key=sdcms_f.HTMLEncode(trim(request("key")))
show=sdcms_f.LoadFile(""&Load_temp_dir&"sdcms_search.htm")
sdcms_p.sdcms_power(id)
response.Write show
set sdcms_f=nothing
set sdcms_p=nothing	

Sub showsearch(t0)
show_search=""
if key="" then 
show_search=show_search&"<li>关键字不能为空</li>"
else
    page=request.querystring("page")
	if page="" or not isnumeric(page) then
	page=1
	end if
	pages =t0
	set rs=server.CreateObject("adodb.recordset")
	sql="select id,title,classid,adddate,jj,htmlname from sd_info"
	sql=sql&" where (title like '%"&key&"%' or jj like '%"&key&"%') and ispass=1 order by id desc"
	rs.open sql,conn,1,1	
	if rs.eof then
	show_search=show_search&"<li>没有找到您要搜索的资料，请换个关键字试试！</li>"
	else
	rs.pagesize = pages
	maxpagecount=rs.pagecount
	rs.absolutepage = page 
	rcount1=0
	pagestart=page-5
	pageend=page+5
	if pagestart<1 then
	pagestart=1
	end if
	if pageend>maxpagecount then
	pageend=maxpagecount
	end if
	rcount=rs.RecordCount
	do while not rs.eof and rcount1 <rs.pagesize
	show_search=show_search&"<li><span>"&rs(3)&"</span><a href="&sdcms_root&sdcms_htmdir&sdcms_f.LoadRecord("classdir","sd_class",rs(2))&rs(5)&sdcms_filetxt&" target=""_blank"">"&sdcms_f.Highlight(rs(1),key)&"</a></li>"
	show_search=show_search&"<li><div>"&sdcms_f.Highlight(sdcms_f.gottopic(rs(4),200),key)&"</div><hr></li>"
	rs.movenext
	rcount1=rcount1+1
	loop
	end if
	
	if rcount>0 then
    if clng(page)=1 then
	show_list_page=show_list_page&"<a>首页</a>"
	else
	show_list_page=show_list_page&"<a href=?key="&key&">首页</a>"
	end if
	if  clng(page)=1 and maxpagecount>=1 then  
		show_list_page=show_list_page&"<a>上一页</a>"
	elseif page-2=0 then
		show_list_page=show_list_page&"<a href=?key="&key&">上一页</a>"
	else
		show_list_page=show_list_page&"<a href=?page="&page-1&"&key="&key&">上一页</a>"
	end if
	for i=pagestart to pageend
		if i=0 then i=1 end if
			if i=clng(page) then 
				str="<span>"&i&"</span>" 
			else 
			    if i=1 then
					str="<a href=?key="&key&">"&i&"</a>"
				else
					str="<a href=?page="&i&"&key="&key&">"&i&"</a>"
				end if
			end if
		strurl=""&str&""
		show_list_page=show_list_page&strurl
	next
	if page=maxpagecount then
		show_list_page=show_list_page&"<a>下一页</a>"
	elseif page<>""&maxpagecount&"" then
		show_list_page=show_list_page&"<a href=?page="&page+1&"&key="&key&">下一页</a>"
	else
		show_list_page=show_list_page&"<a>下一页</a>"
	end if
	if clng(page)<clng(pageend) then
	show_list_page=show_list_page&"<a href=?page="&maxpagecount&"&key="&key&">未页</a>"
	else
	show_list_page=show_list_page&"<a>未页</a>"
	end if
	show_list_page=show_list_page&"<a>页次:"&page&"/"&maxpagecount&"</a><a>总计:"&rcount&" </a>"
	end if
end if
end sub	
%>