<!--#include file="../../act_inc/ACT.User.asp"-->
<%
Server.ScriptTimeOut=999
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.CacheControl = "no-cache"
response.Charset = "gb2312"
ConnectionDatabase
Dim ClsMain,ACT_S_Qie_Qie
	Set ACT_S_Qie_Qie =  New ACT_Search
	Dim MaxPerPage,CurrentPage,ModeID,KeyWord,SearchType,ClassID,RS,SearchForm,TotalPut,i
		MaxPerPage=20
		If request("page") <> "" Then
          CurrentPage = CInt(Request("page"))
        Else
          CurrentPage = 1
        End If

		Dim RefreshTime:RefreshTime = 5  '设置防刷新时间
		If DateDiff("s", Session("SearchTime"), Now()) < RefreshTime Then
			'Response.Write "<META http-equiv=Content-Type content=text/html; chaRset=gb2312><meta HTTP-EQUIV=REFRESH CONTENT="&RefreshTime&"><br>本页面起用了防刷新机制，请不要在"&RefreshTime&"秒内连续刷新本页面<BR>正在打开页面，请稍后……"
		'	Response.End
		End If
		Session("SearchTime")=Now()
        ModeID=ACTCMS.ChkNumeric(request("ModeID"))
		If ModeID=0 Then ModeID=1
		KeyWord=ACTCMS.s("KeyWord")
		If KeyWord="" Then KeyWord=ACTCMS.s("Tags")
		SearchType=ACTCMS.ChkNumeric(request("SearchType"))
        ClassID=request("ClassID"):If ClassID="" Then ClassID="0"
		If KeyWord="" Then Call ACTCMS.Alert("你没有输入搜索关键字!",""):response.End
		Response.Write "<html>"
		Response.Write "<head>"
		Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
		Response.Write "<title>搜索"&KeyWord&"结果-By ActCMS.com</title>"
		Response.Write "<link href=""../images/Main.css"" rel=""stylesheet"" type=""text/css"">"
		Call TagsHits()
   Response.Write "<table width=""100%"" cellspacing=""3"" cellpadding=""3"" align=""center"" class=""searchtitle"">"
   Response.Write "<tr>"
   Response.Write "<td height=""25"" bgcolor=""#F5F5F5"">"
   IF KeyWord="" Then
   Response.Write "<p><strong>搜索结果...</p>" & vbcrlf
   Else
   Response.Write "<p height=""25""><strong>您要查询〖  <font color=red>" & KeyWord & "</font>  〗的信息，以下是搜索结果...</font></p>" & vbcrlf
   End if
   Response.Write "</td></tr>"& vbcrlf
   Call ArticleSearchResult()
   SearchForm=ACT_S_Qie_Qie.ArticleSearch(ModeID)
   Response.Write "<tr><td height=""25"">" & SearchForm & "</td></tr>"
   Response.Write "</table>"

  Sub TagsHits()
    If SearchType=5 Then
	 Conn.Execute("Update Tags_ACT set hits=hits+1,ClicksTime=" & NowString & " where TagsChar='" & keyword & "'")
	End IF
  End Sub
  Sub  ArticleSearchResult()      
  Dim SqlStr,Param
  Param=" Where isAccept=0 And delif=0"
  Select Case SearchType
   Case 100
     If IsDate(KeyWord) Then
	   Param=Param & " And UpdateTime>=#" & KeyWord & " 00:00:00# and UpdateTime<=#" &KeyWord & " 23:59:59#"
	 Else
	   Exit Sub
	 End If
   Case 1:Param=Param & " And (Title  Like '%" & KeyWord & "%')"
   Case 2:Param=Param & " And Content Like '%" & KeyWord & "%'"
   Case 3:Param=Param & " And Author Like '%" & KeyWord & "%'"
   Case 4:Param=Param & " And ArticleInput Like '%" & KeyWord & "%'"
   Case 5:Param=Param & " And KeyWords Like '%" & KeyWord & "%'"
   Case else: Param=Param & " And (Title Like '%" & KeyWord & "%')"
  End Select
  If ClassID<>"0" Then Param=Param & " And ClassID ='"& ClassID &"'"
     SqlStr="Select ID,Classid,Title,UpdateTime,ChangesLink,FileName,GroupID_ACT,Score_ACT,Hits From "&ACTCMS.ACT_C(ModeID,2)&"" & Param &  " Order By ID Desc"
  Response.Write "<dl>" & vbcrlf
  Set RS=Server.CreateObject("ADODB.RECORDSET")
  RS.Open SqlStr,Conn,2,1
  IF RS.Eof And RS.Bof Then
      Response.Write "<tr><td style=""height:25px;padding-left:5px""><strong>此次搜索没有找到您查询的任何文章信息，建议重新选择查询条件再搜一次</td></tr>"
  Else
					TotalPut = Conn.Execute("Select Count(1) From (Select ID From "&ACTCMS.ACT_C(ModeID,2)&"" & Param & ")a")(0)
                    If CurrentPage < 1 Then
                        CurrentPage = 1
                    End If

                    If (CurrentPage - 1) * MaxPerPage > totalPut Then
                        If (TotalPut Mod MaxPerPage) = 0 Then
                            CurrentPage = totalPut \ MaxPerPage
                        Else
                            CurrentPage = totalPut \ MaxPerPage + 1
                        End If
                    End If

                    If CurrentPage = 1 Then
                            Call TypeArticleContent()
                    Else
                        If (CurrentPage - 1) * MaxPerPage < totalPut Then
                            RS.Move (CurrentPage - 1) * MaxPerPage
                            Call TypeArticleContent()
                        Else
                            CurrentPage = 1
                            Call TypeArticleContent()
                        End If
                    End If
    End IF
	RS.Close
	Set RS=Nothing
  End Sub


  Sub TypeArticleContent()  
       Dim N,GainClassName,TempTitle
	   N=(CurrentPage-1)*MaxPerPage
      Do While Not RS.Eof
	   N=N+1
       GainClassName = "[" & ACTCMS.GainClassName(RS("ClassID"), "target=""_blank""", "") & "]"
	   TempTitle = "<a href=""" & ACTCMS.GetInfoUrl(ModeID,Rs("ClassID"),Rs("ID"),Rs("ChangesLink"),Rs("FileName"),Rs("GroupID_ACT"),Rs("Score_ACT")) & """ target=""_blank"">" & Replace(RS("Title"),KeyWord,"<font color=red>" & KeyWord &"</font>") & "</a>"

	   Response.Write "<tr><td style=""height:25px;padding-left:5px""><strong>" & N & "</strong>." & GainClassName & "<strong>" & TempTitle & "</strong>&nbsp;[点击数：" &RS("Hits")& "&nbsp;发布时间："&RS("UpdateTime") & "]</td></tr>" & vbcrlf
	   Response.Write "<tr><td height=""1"" bgcolor=""#eeeeee""></td></tr>"
	    I = I + 1
        If I >= MaxPerPage Then Exit Do
        RS.MoveNext
	Loop
        Response.Write "<tr><td style=""height:25px;padding-left:5px""><strong>"
        Call ShowPagePara(totalPut, MaxPerPage, "", true, "篇", CurrentPage, "SearchType=" & SearchType & "&ClassID=" & ClassID & "&KeyWord=" & KeyWord & "&ModeID=" & ModeID )
		Response.Write "</td></tr>" & vbcrlf
  End Sub





  Sub ShowProductContent()   '显示Product搜索结果
       Dim N,GainClassName,TempTitle
	   N=(CurrentPage-1)*MaxPerPage
      Do While Not RS.Eof
	   N=N+1
       GainClassName = "[" & ClsMain.GainClassName(RS("ClassID"), "target=""_blank""", "") & "]"
	   TempTitle = "<a href=""" & ClsMain.GetInfoUrl(5,Rs("ClassID"),Rs("ID"),Rs("ChangesLink"),Rs("FileName"),Rs("SaveArticlePath"),Rs("InfoPurview"),Rs("ReadPoint")) & """ target=""_blank"">" & Replace(RS("Title"),KeyWord,"<font color=red>" & KeyWord &"</font>") & "</a>"
	   Response.Write "<tr><td style=""height:25px;padding-left:5px""><strong>" & N & "</strong>." & GainClassName & "<strong>" & TempTitle & "</strong>&nbsp;[" & RS("ProducerName") & "][" & RS("Adddate") & "]</td></tr>" & vbcrlf
		Response.Write "<tr><td height=""1"" bgcolor=""#eeeeee""></td></tr>"
	    I = I + 1
        If I >= MaxPerPage Then Exit Do
        RS.MoveNext
	Loop
        Response.Write "<tr><td style=""height:25px;padding-left:5px""><strong>"
        Call ShowPagePara(totalPut, MaxPerPage, "", True, "件", CurrentPage, "SearchType=" & SearchType & "&ClassID=" & ClassID & "&KeyWord=" & KeyWord & "&ModeID=" & ModeID )
		Response.Write "</td></tr>" & vbcrlf
  End Sub

  Sub AllSearchResult()
   Dim SqlStr
   Dim ArticleSqlStr:ArticleSqlStr="Select C.ModeID,A.ID,A.classid,A.Title,A.UpdateTime,A.Author,A.FileName,A.GroupID_ACT,A.Score_ACT,A.ChangesLink,A.Hits From "&ACTCMS.ACT_C(ModeID,2)&" A,Class_ACT C Where A.classid=C.classid and A.isAccept=0  And A.delif=0  And (A.Title Like '%" & KeyWord & "%'  Like '%" & KeyWord & "%' or A.Author Like '%" & KeyWord & "%')"
	SqlStr=ArticleSqlStr & " Order By A.UpdateTime Desc"
  Set RS=Server.CreateObject("ADODB.RECORDSET")
  RS.Open SqlStr,Conn,1,1
  IF RS.Eof And RS.Bof Then
           Response.Write "<tr><td style=""height:25px;padding-left:5px""><strong>此次搜索没有找到您查询的任何信息，建议重新选择查询条件再搜一次</td></tr>"
  Else
                    TotalPut = RS.RecordCount

                    If CurrentPage < 1 Then
                        CurrentPage = 1
                    End If

                    If (CurrentPage - 1) * MaxPerPage > totalPut Then
                        If (TotalPut Mod MaxPerPage) = 0 Then
                            CurrentPage = totalPut \ MaxPerPage
                        Else
                            CurrentPage = totalPut \ MaxPerPage + 1
                        End If
                    End If

                    If CurrentPage = 1 Then
                            Call ShowALLContent()
                    Else
                        If (CurrentPage - 1) * MaxPerPage < totalPut Then
                            RS.Move (CurrentPage - 1) * MaxPerPage
                            Call ShowALLContent()
                        Else
                            CurrentPage = 1
                            Call ShowALLContent()
                        End If
                    End If
    End IF
	RS.Close
	Set RS=Nothing
  End Sub
  Sub ShowAllContent()  
       Dim N,GainClassName,TempTitle
	   N=(CurrentPage-1)*MaxPerPage
      Do While Not RS.Eof
	   N=N+1
       GainClassName = "[" & ClsMain.GainClassName(RS(2), "target=""_blank""", "") & "]"
	   TempTitle = "<a href=""" & ClsMain.GetInfoUrl(RS(0),Rs("ClassID"),Rs("ID"),Rs("ChangesLink"),Rs("FileName"),Rs("SaveArticlePath"),Rs("InfoPurview"),Rs("ReadPoint")) & """ target=""_blank"">" & Replace(RS(3),KeyWord,"<font color=red>" & KeyWord &"</font>") & "</a>"

	   Response.Write "<tr><td style=""height:25px;padding-left:5px""><strong>" & N & "</strong>." & GainClassName & "<strong>" & TempTitle & "</strong>&nbsp;[点击数：" &RS("Hits")& "&nbsp;发布时间："&RS("UpdateTime") & "]</td></tr>" & vbcrlf
	   Response.Write "<tr><td height=""1"" bgcolor=""#eeeeee""></td></tr>"
	    I = I + 1
        If I >= MaxPerPage Then Exit Do
        RS.MoveNext
	Loop
        Response.Write "<tr><td style=""height:25px;padding-left:5px""><strong>"
        Call ShowPagePara(totalPut, MaxPerPage, "", True, "条", CurrentPage, "SearchType=" & SearchType & "&ClassID=" & ClassID & "&KeyWord=" & KeyWord & "&ModeID=" & ModeID )
		Response.Write "</td></tr>" & vbcrlf
  End Sub
	Public Function ShowPagePara(totalnumber, MaxPerPage, FileName, ShowAllPages, strUnit, CurrentPage, ParamterStr)
		  Dim N, I, PageStr
				Const Btn_First = "第一页"'样式定义
				Const Btn_Prev = "上一页" 
				Const Btn_Next = "下一页" 
				Const Btn_Last = "最后一页" 
				  PageStr = ""
					If totalnumber Mod MaxPerPage = 0 Then
						N = totalnumber \ MaxPerPage
					Else
						N = totalnumber \ MaxPerPage + 1
					End If
				If N > 1 Then
					PageStr = PageStr & ("页次：<font color=red>" & CurrentPage & "</font>/" & N & "页 共有:" & totalnumber & strUnit & " 每页:" & MaxPerPage & strUnit & " ")
					If CurrentPage < 2 Then
						PageStr = PageStr & Btn_First & " " & Btn_Prev & " "
					Else
						PageStr = PageStr & ("<a href=" & FileName & "?page=1" & "&" & ParamterStr & ">" & Btn_First & "</a> <a href=" & FileName & "?page=" & CurrentPage - 1 & "&" & ParamterStr & ">" & Btn_Prev & "</a> ")
					End If
					
					If N - CurrentPage < 1 Then
						PageStr = PageStr & " " & Btn_Next & " " & Btn_Last & " "
					Else
						PageStr = PageStr & (" <a href=" & FileName & "?page=" & (CurrentPage + 1) & "&" & ParamterStr & ">" & Btn_Next & "</a> <a href=" & FileName & "?page=" & N & "&" & ParamterStr & ">" & Btn_Last & "</a> ")
					End If
					If ShowAllPages = True Then
						PageStr = PageStr & ("GO:<select  onChange='location.href=this.value;' style='width:55;' name='select'>")
				   For I = 1 To N
					 If Cint(CurrentPage) = I Then
						PageStr = PageStr & ("<option value=" & FileName & "?page=" & I & "&" & ParamterStr & " selected>NO." & I & "</option>")
					 Else
						 PageStr = PageStr & ("<option value=" & FileName & "?page=" & I & "&" & ParamterStr & ">NO." & I & "</option>")
					 End If
				   Next
				  PageStr = PageStr & "</select>"
				  End If
			 End If
			 ShowPagePara = PageStr
			 response.write ShowPagePara
	End Function
	%>