<!--#include file="conn.asp" -->
<!--#include file="inc/const.asp"-->
<%
Dim j
Dim i
Dim keyword
Dim findword
Dim Action
Dim CurrentPage
Dim maxperpage
Dim totalnumber
Dim Pcount
Dim Rs
Dim SQL
Dim HtmlString
Dim SoftName
Dim Soft_Name
Dim SoftSize
Dim SoftTime
Dim Content
Dim Title
Dim Stitle
Dim InfoTime
Dim DownloadClass_Ads
Dim temphtml
Dim NowStats
Dim HtmlTitle
Dim TempTopStr
Dim TempFootStr
Dim bookmark
On Error Resume Next
Set Rs = Server.CreateObject("adodb.recordset")
Action = Trim(Request("Action"))
keyword = Trim(Request("keyword"))
If Not IsEmpty(Request("page")) Then
	CurrentPage = CInt(Request("page"))
Else
	CurrentPage = 1
End If
If Not IsNumeric(Request("page")) And Request("page") <> "" Then
	Response.Write "错误的系统参数!请输入整数"
	Err.Raise -19691969
End If
DownsysClass.LoadTemplates ("search")
Set DownloadClass_Ads = New Adcolumn_Cls
NowStats = "搜索引擎"
HtmlTitle = "搜索引擎"
maxperpage = CInt(DownsysClass.TempSet(1)) '###每页显示数
temphtml = DownsysClass.mainhtml(0) & DownsysClass.mainhtml(1) & DownsysClass.mainhtml(2) & DownsysClass.mainhtml(3) & DownsysClass.temphtml(0)
temphtml = Replace(temphtml, "{$NavMenu}", DownsysClass.SortingMenu)
If CInt(DownsysClass.Setting(5)) = 0 Then
	temphtml = Replace(temphtml, "{$TopMeun}", DownsysClass.mainset(9))
Else
	temphtml = Replace(temphtml, "{$TopMeun}", DownsysClass.mainset(10))
End If
temphtml = Replace(temphtml, "{$Style_CSS}", DownsysClass.Style_CSS)
temphtml = Replace(temphtml, "{$NowStats}", NowStats)
temphtml = Replace(temphtml, "{$Title}", HtmlTitle)
temphtml = Replace(temphtml, "{$KeyWord}", keyword)
If keyword = "" Then
	Response.Write ("<script>alert('" & DownsysClass.TempSet(3) & "');history.go(-1)</script>")
	Err.Raise -19691969
Else
	keyword = Replace(Replace(Replace(keyword, "'", "‘"), "<", "&lt;"), ">", "&gt;")
	Select Case Action
	Case "soft" 
		findword = "SoftName like '%" & keyword & "%'"
		SQL = "select Top " & CInt(DownsysClass.TempSet(0)) & " * from NC_SoftInfo where " & findword & " And islock = 0 "
		SQL = SQL & " order by softTime desc,softid desc"
	Case "info" 
		findword = "title like '%" & keyword & "%'"
		SQL = "select Top " & CInt(DownsysClass.TempSet(0)) & " * from NC_Article where " & findword & " And islock = 0 "
		SQL = SQL & " order by InfoTime desc,id desc"
	Case else
		Response.Redirect ("http://www1.baidu.com/baidu?word=" & keyword & "")
	End Select
End If
Rs.Open SQL, conn, 1, 1
If Rs.EOF And Rs.bof Then
	temphtml = temphtml & Replace(DownsysClass.TempSet(4), "{$KeyWord}", keyword)
Else
	totalnumber = Rs.recordcount
	If (totalnumber Mod maxperpage) = 0 Then
		Pcount = totalnumber \ maxperpage
	Else
		Pcount = totalnumber \ maxperpage + 1
	End If
	Rs.MoveFiRst
	If CurrentPage > Pcount Then CurrentPage = Pcount
	If CurrentPage < 1 Then CurrentPage = 1
	Rs.Move (CurrentPage - 1) * maxperpage
	bookmark = Rs.bookmark
	i = 0
	j = (CurrentPage - 1) * maxperpage + 1
	If Action = "soft" Then
		temphtml = temphtml & DownsysClass.temphtml(1)
	End If
	If Action = "info" Then
		temphtml = temphtml & DownsysClass.temphtml(3)
	End If
	Do While Not Rs.EOF And i < CLng(maxperpage)
		Select Case Action
		 Case  "soft"
			temphtml = temphtml & DownsysClass.temphtml(2)
			Soft_Name = Replace(Rs("SoftName"), "" & keyword & "", "<font color=red>" & keyword & "</font>") & " " & Rs("SoftVer")
			If CInt(DownsysClass.Setting(5)) = 0 Then
				SoftName = "<a href='Software/catalog" & Rs("sortid") & "/" & Rs("SoftID") & ".html'>" & Soft_Name & "</a>"
			Else
				SoftName = "<a href='Software.Asp?id=" & Rs("SoftID") & "'>" & Soft_Name & "</a>"
			End If
			If Rs("SoftSize") > 1024 Then
				SoftSize = (Round(Rs("SoftSize") / 1024, 2) & " MB")
			Else
				SoftSize = (Rs("SoftSize") & " KB")
			End If
			Content = DownsysClass.CutString(Rs("Content"), CInt(DownsysClass.TempSet(2)))
			Content = Replace(Content, "" & keyword & "", "<font color=red>" & keyword & "</font>")
			SoftTime = FormatDateTime(Rs("SoftTime"), 2)
			temphtml = Replace(temphtml, "{$Sequence}", j)
			temphtml = Replace(temphtml, "{$SoftName}", SoftName)
			temphtml = Replace(temphtml, "{$SoftTime}", SoftTime)
			temphtml = Replace(temphtml, "{$SoftSize}", SoftSize)
			temphtml = Replace(temphtml, "{$Content}", Content)
			temphtml = Replace(temphtml, "{$DateTime}", Rs("SoftTime"))
			temphtml = Replace(temphtml, "{$Hits}", Rs("Hits"))
		Case  "info"
			temphtml = temphtml & DownsysClass.temphtml(4)
			Stitle = Replace(Rs("title"), "" & keyword & "", "<font color=red>" & keyword & "</font>")
			If CInt(DownsysClass.Setting(5)) = 0 Then
				Title = "<a href='Article/catalog" & Rs("Classid") & "/" & Rs("ID") & ".html'>" & Stitle & "</a>"
			Else
				Title = "<a href='Article.Asp?id=" & Rs("ID") & "'>" & Stitle & "</a>"
			End If
			Content = DownsysClass.CutString(Rs("content"), CInt(DownsysClass.TempSet(2)))
			Content = Replace(Content, "" & keyword & "", "<font color=red>" & keyword & "</font>")
			InfoTime = FormatDateTime(Rs("InfoTime"), 2)
			temphtml = Replace(temphtml, "{$Sequence}", j)
			temphtml = Replace(temphtml, "{$Title}", Title)
			temphtml = Replace(temphtml, "{$InfoTime}", InfoTime)
			temphtml = Replace(temphtml, "{$Content}", Content)
			temphtml = Replace(temphtml, "{$DateTime}", Rs("InfoTime"))
			temphtml = Replace(temphtml, "{$Hits}", Rs("Hits"))
		Case else
			temphtml = temphtml & Replace(DownsysClass.TempSet(4), "{$KeyWord}", keyword)
		End Select
		Rs.movenext
		j = j + 1
		i = i + 1
		If i >= maxperpage Then Exit Do
	Loop
End If
Rs.Close
Set Rs = Nothing
temphtml = temphtml & DownsysClass.temphtml(5)
temphtml = temphtml & DownsysClass.mainhtml(4)
temphtml = Replace(temphtml, "{$ShowPage}", ShowPage(maxperpage, totalnumber, CurrentPage))
temphtml = Replace(temphtml, "{$Width}", DownsysClass.mainset(0))
If CInt(DownsysClass.Setting(5)) = 1 Then
temphtml = Replace(temphtml, "{$FootMeun}", DownsysClass.mainset(11))
Else 
temphtml = Replace(temphtml, "{$FootMeun}", DownsysClass.mainset(44))
End If
temphtml = Replace(temphtml, "{$Adcolumn(0)}", DownloadClass_Ads.RunScriptAds(7))
temphtml = Replace(temphtml, "{$Adcolumn(1)}", DownloadClass_Ads.BannerAds(7))
temphtml = Replace(temphtml, "{$Adcolumn(2)}", DownloadClass_Ads.AdsColumn(7, 2))
temphtml = Replace(temphtml, "{$Adcolumn(4)}", DownloadClass_Ads.ScriptFloatAds(7))
temphtml = Replace(temphtml, "{$Adcolumn(5)}", DownloadClass_Ads.ScriptFixedAds(7))
Response.Write temphtml
Set DownloadClass_Ads = Nothing
CloseConn
Private Function ShowPage(maxperpage, totalnumber, CurrentPage)
	Dim ii
	Dim n
	Dim HtmlShowPage
	If totalnumber Mod maxperpage = 0 Then
		n = totalnumber \ maxperpage
	Else
		n = totalnumber \ maxperpage + 1
	End If
	HtmlShowPage = "<table cellspacing=1 width='100%' border=0><form method=Post action=?action=" & Request("action") & "&keyword=" & keyword & "><tr><td align=center> " & vbCrLf
	If CurrentPage < 2 Then
		HtmlShowPage = HtmlShowPage & " 查询到 <font COLOR=#FF0000>" & totalnumber & "</font> 条记录&nbsp;&nbsp;首 页&nbsp;&nbsp;上一页&nbsp;&nbsp;&nbsp;"
	Else
		HtmlShowPage = HtmlShowPage & "查询到 <font COLOR=#FF0000>" & totalnumber & "</font> 条记录&nbsp;&nbsp;<a href=?page=1&action=" & Request("action") & "&keyword=" & keyword & ">首 页</a>&nbsp;&nbsp;"
		HtmlShowPage = HtmlShowPage & "<a href=?page=" & CurrentPage - 1 & "&action=" & Request("action") & "&keyword=" & keyword & ">上一页</a>&nbsp;&nbsp;&nbsp;"
	End If
	If n - CurrentPage < 1 Then
		HtmlShowPage = HtmlShowPage & "下一页&nbsp;&nbsp;尾 页 " & vbCrLf
	Else
		HtmlShowPage = HtmlShowPage & "<a href=?page=" & (CurrentPage + 1) & "&action=" & Request("action") & "&keyword=" & keyword & ">下一页</a>"
		HtmlShowPage = HtmlShowPage & "&nbsp;&nbsp;<a href=?page=" & n & "&action=" & Request("action") & "&keyword=" & keyword & ">尾 页</a>" & vbCrLf
	End If
	HtmlShowPage = HtmlShowPage & "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
	HtmlShowPage = HtmlShowPage & "&nbsp;<b>" & maxperpage & "</b>个/页 " & vbCrLf
	HtmlShowPage = HtmlShowPage & "&nbsp;转到： "
	HtmlShowPage = HtmlShowPage & "&nbsp;<select name='page' size='1' style=""font-size: 9pt"" onChange='javascript:submit()'>" & vbCrLf
	For ii = 1 To n
		HtmlShowPage = HtmlShowPage & "&nbsp;<option value='" & ii & "' "
		If CurrentPage = CInt(ii) Then
			HtmlShowPage = HtmlShowPage & "selected "
		End If
		HtmlShowPage = HtmlShowPage & ">第" & ii & "页</option>"
	Next
	HtmlShowPage = HtmlShowPage & "&nbsp;</select> " & vbCrLf
	HtmlShowPage = HtmlShowPage & "</td></tr></FORM></table>" & vbCrLf
	ShowPage = HtmlShowPage
End Function
%>
