result.asp
上传用户:yjkj1008
上传日期:2020-10-17
资源大小:1496k
文件大小:15k
源码类别:

电子政务应用

开发平台:

HTML/CSS

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  2. <!--#include file="Connections/conn_news.asp" -->
  3. <%
  4. function ShowBold(theField)
  5. Set objRegExp= New RegExp
  6. objRegExp.Pattern="(" & Request("shuru") & ")"
  7. objRegExp.IgnoreCase=True
  8. objRegExp.Global=True
  9. ShowBold=objRegExp.Replace(theField,"<font color=red><b>$1</b></font>")
  10. end function
  11. %>
  12. <%
  13. Dim rst
  14. Dim rst_numRows
  15. Set rst = Server.CreateObject("ADODB.Recordset")
  16. rst.ActiveConnection = MM_conn_news_STRING
  17. rst.Source = "SELECT * FROM t_type"
  18. rst.CursorType = 0
  19. rst.CursorLocation = 2
  20. rst.LockType = 1
  21. rst.Open()
  22. rst_numRows = 0
  23. %>
  24. <%
  25. Dim rss__varkkk
  26. rss__varkkk = "%"
  27. If (request("shuru")      <> "") Then 
  28.   rss__varkkk = request("shuru")     
  29. End If
  30. %>
  31. <%
  32. Dim rss__varxxx
  33. rss__varxxx = "n_title"
  34. If (request("fangshi")  <> "") Then 
  35.   rss__varxxx = request("fangshi") 
  36. End If
  37. %>
  38. <%
  39. set rss = Server.CreateObject("ADODB.Recordset")
  40. rss.ActiveConnection = MM_conn_news_STRING
  41. rss.Source = "SELECT n_id, n_title, n_author, n_content,n_date, n_tid, n_check, n_fname  FROM t_news  WHERE " + Replace(rss__varxxx, "'", "''") + " like '%" + Replace(rss__varkkk, "'", "''") + "%' and n_check = true  ORDER BY n_date DESC"
  42. rss.CursorType = 0
  43. rss.CursorLocation = 2
  44. rss.LockType = 3
  45. rss.Open()
  46. rss_numRows = 0
  47. %>
  48. <%
  49. Dim rssetup
  50. Dim rssetup_numRows
  51. Set rssetup = Server.CreateObject("ADODB.Recordset")
  52. rssetup.ActiveConnection = MM_conn_news_STRING
  53. rssetup.Source = "SELECT * FROM t_setup"
  54. rssetup.CursorType = 0
  55. rssetup.CursorLocation = 2
  56. rssetup.LockType = 1
  57. rssetup.Open()
  58. rssetup_numRows = 0
  59. %>
  60. <%
  61. Dim Repeat1__numRows
  62. Dim Repeat1__index
  63. Repeat1__numRows = -1
  64. Repeat1__index = 0
  65. rst_numRows = rst_numRows + Repeat1__numRows
  66. %>
  67. <%
  68. '  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
  69. Dim rss_total
  70. Dim rss_first
  71. Dim rss_last
  72. ' set the record count
  73. rss_total = rss.RecordCount
  74. ' set the number of rows displayed on this page
  75. If (rss_numRows < 0) Then
  76.   rss_numRows = rss_total
  77. Elseif (rss_numRows = 0) Then
  78.   rss_numRows = 1
  79. End If
  80. ' set the first and last displayed record
  81. rss_first = 1
  82. rss_last  = rss_first + rss_numRows - 1
  83. ' if we have the correct record count, check the other stats
  84. If (rss_total <> -1) Then
  85.   If (rss_first > rss_total) Then
  86.     rss_first = rss_total
  87.   End If
  88.   If (rss_last > rss_total) Then
  89.     rss_last = rss_total
  90.   End If
  91.   If (rss_numRows > rss_total) Then
  92.     rss_numRows = rss_total
  93.   End If
  94. End If
  95. %>
  96. <%
  97. ' *** Recordset Stats: if we don't know the record count, manually count them
  98. If (rss_total = -1) Then
  99.   ' count the total records by iterating through the recordset
  100.   rss_total=0
  101.   While (Not rss.EOF)
  102.     rss_total = rss_total + 1
  103.     rss.MoveNext
  104.   Wend
  105.   ' reset the cursor to the beginning
  106.   If (rss.CursorType > 0) Then
  107.     rss.MoveFirst
  108.   Else
  109.     rss.Requery
  110.   End If
  111.   ' set the number of rows displayed on this page
  112.   If (rss_numRows < 0 Or rss_numRows > rss_total) Then
  113.     rss_numRows = rss_total
  114.   End If
  115.   ' set the first and last displayed record
  116.   rss_first = 1
  117.   rss_last = rss_first + rss_numRows - 1
  118.   
  119.   If (rss_first > rss_total) Then
  120.     rss_first = rss_total
  121.   End If
  122.   If (rss_last > rss_total) Then
  123.     rss_last = rss_total
  124.   End If
  125. End If
  126. %>
  127. <%
  128. Dim Repeat2__numRows
  129. Dim Repeat2__index
  130. Repeat2__numRows = (rssetup.Fields.Item("st_cnnu").Value)
  131. Repeat2__index = 0
  132. rss_numRows = rss_numRows + Repeat2__numRows
  133. %>
  134. <%
  135. Dim MM_paramName 
  136. %>
  137. <%
  138. ' *** Move To Record and Go To Record: declare variables
  139. Dim MM_rs
  140. Dim MM_rsCount
  141. Dim MM_size
  142. Dim MM_uniqueCol
  143. Dim MM_offset
  144. Dim MM_atTotal
  145. Dim MM_paramIsDefined
  146. Dim MM_param
  147. Dim MM_index
  148. Set MM_rs    = rss
  149. MM_rsCount   = rss_total
  150. MM_size      = rss_numRows
  151. MM_uniqueCol = ""
  152. MM_paramName = ""
  153. MM_offset = 0
  154. MM_atTotal = false
  155. MM_paramIsDefined = false
  156. If (MM_paramName <> "") Then
  157.   MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
  158. End If
  159. %>
  160. <%
  161. ' *** Move To Record: handle 'index' or 'offset' parameter
  162. if (Not MM_paramIsDefined And MM_rsCount <> 0) then
  163.   ' use index parameter if defined, otherwise use offset parameter
  164.   MM_param = Request.QueryString("index")
  165.   If (MM_param = "") Then
  166.     MM_param = Request.QueryString("offset")
  167.   End If
  168.   If (MM_param <> "") Then
  169.     MM_offset = Int(MM_param)
  170.   End If
  171.   ' if we have a record count, check if we are past the end of the recordset
  172.   If (MM_rsCount <> -1) Then
  173.     If (MM_offset >= MM_rsCount Or MM_offset = -1) Then  ' past end or move last
  174.       If ((MM_rsCount Mod MM_size) > 0) Then         ' last page not a full repeat region
  175.         MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
  176.       Else
  177.         MM_offset = MM_rsCount - MM_size
  178.       End If
  179.     End If
  180.   End If
  181.   ' move the cursor to the selected record
  182.   MM_index = 0
  183.   While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
  184.     MM_rs.MoveNext
  185.     MM_index = MM_index + 1
  186.   Wend
  187.   If (MM_rs.EOF) Then 
  188.     MM_offset = MM_index  ' set MM_offset to the last possible record
  189.   End If
  190. End If
  191. %>
  192. <%
  193. ' *** Move To Record: if we dont know the record count, check the display range
  194. If (MM_rsCount = -1) Then
  195.   ' walk to the end of the display range for this page
  196.   MM_index = MM_offset
  197.   While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
  198.     MM_rs.MoveNext
  199.     MM_index = MM_index + 1
  200.   Wend
  201.   ' if we walked off the end of the recordset, set MM_rsCount and MM_size
  202.   If (MM_rs.EOF) Then
  203.     MM_rsCount = MM_index
  204.     If (MM_size < 0 Or MM_size > MM_rsCount) Then
  205.       MM_size = MM_rsCount
  206.     End If
  207.   End If
  208.   ' if we walked off the end, set the offset based on page size
  209.   If (MM_rs.EOF And Not MM_paramIsDefined) Then
  210.     If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
  211.       If ((MM_rsCount Mod MM_size) > 0) Then
  212.         MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
  213.       Else
  214.         MM_offset = MM_rsCount - MM_size
  215.       End If
  216.     End If
  217.   End If
  218.   ' reset the cursor to the beginning
  219.   If (MM_rs.CursorType > 0) Then
  220.     MM_rs.MoveFirst
  221.   Else
  222.     MM_rs.Requery
  223.   End If
  224.   ' move the cursor to the selected record
  225.   MM_index = 0
  226.   While (Not MM_rs.EOF And MM_index < MM_offset)
  227.     MM_rs.MoveNext
  228.     MM_index = MM_index + 1
  229.   Wend
  230. End If
  231. %>
  232. <%
  233. ' *** Move To Record: update recordset stats
  234. ' set the first and last displayed record
  235. rss_first = MM_offset + 1
  236. rss_last  = MM_offset + MM_size
  237. If (MM_rsCount <> -1) Then
  238.   If (rss_first > MM_rsCount) Then
  239.     rss_first = MM_rsCount
  240.   End If
  241.   If (rss_last > MM_rsCount) Then
  242.     rss_last = MM_rsCount
  243.   End If
  244. End If
  245. ' set the boolean used by hide region to check if we are on the last record
  246. MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
  247. %>
  248. <%
  249. ' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
  250. Dim MM_keepNone
  251. Dim MM_keepURL
  252. Dim MM_keepForm
  253. Dim MM_keepBoth
  254. Dim MM_removeList
  255. Dim MM_item
  256. Dim MM_nextItem
  257. ' create the list of parameters which should not be maintained
  258. MM_removeList = "&index="
  259. If (MM_paramName <> "") Then
  260.   MM_removeList = MM_removeList & "&" & MM_paramName & "="
  261. End If
  262. MM_keepURL=""
  263. MM_keepForm=""
  264. MM_keepBoth=""
  265. MM_keepNone=""
  266. ' add the URL parameters to the MM_keepURL string
  267. For Each MM_item In Request.QueryString
  268.   MM_nextItem = "&" & MM_item & "="
  269.   If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
  270.     MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
  271.   End If
  272. Next
  273. ' add the Form variables to the MM_keepForm string
  274. For Each MM_item In Request.Form
  275.   MM_nextItem = "&" & MM_item & "="
  276.   If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
  277.     MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
  278.   End If
  279. Next
  280. ' create the Form + URL string and remove the intial '&' from each of the strings
  281. MM_keepBoth = MM_keepURL & MM_keepForm
  282. If (MM_keepBoth <> "") Then 
  283.   MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
  284. End If
  285. If (MM_keepURL <> "")  Then
  286.   MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
  287. End If
  288. If (MM_keepForm <> "") Then
  289.   MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
  290. End If
  291. ' a utility function used for adding additional parameters to these strings
  292. Function MM_joinChar(firstItem)
  293.   If (firstItem <> "") Then
  294.     MM_joinChar = "&"
  295.   Else
  296.     MM_joinChar = ""
  297.   End If
  298. End Function
  299. %>
  300. <%
  301. ' *** Move To Record: set the strings for the first, last, next, and previous links
  302. Dim MM_keepMove
  303. Dim MM_moveParam
  304. Dim MM_moveFirst
  305. Dim MM_moveLast
  306. Dim MM_moveNext
  307. Dim MM_movePrev
  308. Dim MM_urlStr
  309. Dim MM_paramList
  310. Dim MM_paramIndex
  311. Dim MM_nextParam
  312. MM_keepMove = MM_keepBoth
  313. MM_moveParam = "index"
  314. ' if the page has a repeated region, remove 'offset' from the maintained parameters
  315. If (MM_size > 1) Then
  316.   MM_moveParam = "offset"
  317.   If (MM_keepMove <> "") Then
  318.     MM_paramList = Split(MM_keepMove, "&")
  319.     MM_keepMove = ""
  320.     For MM_paramIndex = 0 To UBound(MM_paramList)
  321.       MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
  322.       If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
  323.         MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
  324.       End If
  325.     Next
  326.     If (MM_keepMove <> "") Then
  327.       MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
  328.     End If
  329.   End If
  330. End If
  331. ' set the strings for the move to links
  332. If (MM_keepMove <> "") Then 
  333.   MM_keepMove = MM_keepMove & "&"
  334. End If
  335. MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="
  336. MM_moveFirst = MM_urlStr & "0"
  337. MM_moveLast  = MM_urlStr & "-1"
  338. MM_moveNext  = MM_urlStr & CStr(MM_offset + MM_size)
  339. If (MM_offset - MM_size < 0) Then
  340.   MM_movePrev = MM_urlStr & "0"
  341. Else
  342.   MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
  343. End If
  344. %>
  345. <SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
  346. function DoTrimProperly(str, nNamedFormat, properly, pointed, points)
  347.   dim strRet
  348.   strRet = Server.HTMLEncode(str)
  349.   strRet = replace(strRet, vbcrlf,"")
  350.   strRet = replace(strRet, vbtab,"")
  351.   If (LEN(strRet) > nNamedFormat) Then
  352.     strRet = LEFT(strRet, nNamedFormat)
  353.     If (properly = 1) Then
  354.       Dim TempArray
  355.       TempArray = split(strRet, " ")
  356.       Dim n
  357.       strRet = ""
  358.       for n = 0 to Ubound(TempArray) - 1
  359.         strRet = strRet & " " & TempArray(n)
  360.       next
  361.     End If
  362.     If (pointed = 1) Then
  363.       strRet = strRet & points
  364.     End If
  365.   End If
  366.   DoTrimProperly = strRet
  367. End Function
  368. </SCRIPT>
  369. <SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
  370. function DoDateTime(str, nNamedFormat, nLCID)
  371. dim strRet
  372. dim nOldLCID
  373. strRet = str
  374. If (nLCID > -1) Then
  375. oldLCID = Session.LCID
  376. End If
  377. On Error Resume Next
  378. If (nLCID > -1) Then
  379. Session.LCID = nLCID
  380. End If
  381. If ((nLCID < 0) Or (Session.LCID = nLCID)) Then
  382. strRet = FormatDateTime(str, nNamedFormat)
  383. End If
  384. If (nLCID > -1) Then
  385. Session.LCID = oldLCID
  386. End If
  387. DoDateTime = strRet
  388. End Function
  389. </SCRIPT>
  390. <html>
  391. <head>
  392. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  393. <!--#include file="top.asp" --><link href="config/beauty.css" rel="stylesheet" type="text/css">
  394. </head>
  395. <body background="pic_site/bgw.gif" leftmargin="0" topmargin="5" marginwidth="0" marginheight="0">
  396. <table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F5F5F5" height="34">
  397.   <tr> 
  398. <form action="result.asp" method="get" name="form1">
  399.             <td align="center" bgcolor="#FFDDDD" width="100%" height="34" > 
  400.               <input name="shuru" type="text" id="shuru23" size="20" style="border: 1px solid #000000; background-color: #E8E8E8"> 
  401.               <select name="fangshi" id="fangshi">
  402.                 <option value="n_title" selected>标题</option>
  403.                 <option value="n_author">作者</option>
  404.                 <option value="n_content">内容</option>
  405.               </select> 
  406.               <input type="submit" value="本站搜索" style="border: 1px solid #666666; background-color: #E8E8E8">
  407.               </font>
  408.               输入关键词!</td>
  409.           </form>
  410. </td>
  411.   </tr>
  412. </table>
  413. <table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  414.   <tr> 
  415.     <td>&nbsp;&nbsp;&nbsp;&nbsp; 通过对<font color="#FF0000"> 
  416.       <% name=(request("fangshi"))
  417.   select case name
  418.   case "n_title"
  419.   response.write"标题"
  420.   case "n_author"
  421.   response.write"作者"
  422.   case else
  423.   response.write"内容"
  424.   end select
  425.   %>
  426.       </font>的检索共找到关键字是 <font color="#FF0000"><%=request("shuru")%> </font>的新闻 <font color="#FF0000"><%=(rss_total)%>&nbsp;</font>则,分<font color="#FF0000"> 
  427.       <%
  428.      Dim page1
  429.      Dim page2
  430.      page1=(rss_total)/20
  431.      if page1 > int(page1) then
  432.        page2 = int(page1)+1
  433.        response.write(page2)
  434.      else
  435.        response.write(page1)
  436.     end if
  437.     %>
  438.       </font>页显示,该页显示<font color="#FF0000"> <%=(rss_first)%>-<%=(rss_last)%>/<%=(rss_total)%> </font>。</td>
  439.   </tr>
  440. </table>
  441. <table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  442.   <tr>
  443.     <td><br> <table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
  444.         <% 
  445. While ((Repeat2__numRows <> 0) AND (NOT rss.EOF)) 
  446. %>
  447.         <tr> 
  448.           <td width="5%" height="20" align="center"><img src="pic_site/arrow.gif" width="15" height="11"></td>
  449.           <td height="20"><strong><span class="title"><a href="<%=(rss.Fields.Item("n_tid").Value)%>/<%=(rss.Fields.Item("n_fname").Value)%>" target="_blank"><%=ShowBold(rss.Fields.Item("n_title").Value)%></a></span></strong>&nbsp; 
  450.             作者:<%=(rss.Fields.Item("n_author").Value)%>&nbsp;日期<font color="#666666">:<%= DoDateTime((rss.Fields.Item("n_date").Value), 2, -1) %></font></td>
  451.         </tr>
  452.         <tr> 
  453.           <td height="20" colspan="2"></td>
  454.         </tr>
  455.         <% 
  456.   Repeat2__index=Repeat2__index+1
  457.   Repeat2__numRows=Repeat2__numRows-1
  458.   rss.MoveNext()
  459. Wend
  460. %>
  461.       </table>
  462.       <table border="0" width="50%" align="center">
  463.         <tr> 
  464.           <td width="23%" align="center"> 
  465.             <% If MM_offset <> 0 Then %>
  466.             <a href="<%=MM_moveFirst%>">第一页</a> 
  467.             <% End If ' end MM_offset <> 0 %>
  468.           </td>
  469.           <td width="31%" align="center"> 
  470.             <% If MM_offset <> 0 Then %>
  471.             <a href="<%=MM_movePrev%>">前一页</a> 
  472.             <% End If ' end MM_offset <> 0 %>
  473.           </td>
  474.           <td width="23%" align="center"> 
  475.             <% If Not MM_atTotal Then %>
  476.             <a href="<%=MM_moveNext%>">下一页</a> 
  477.             <% End If ' end Not MM_atTotal %>
  478.           </td>
  479.           <td width="23%" align="center"> 
  480.             <% If Not MM_atTotal Then %>
  481.             <a href="<%=MM_moveLast%>">最后一页</a> 
  482.             <% End If ' end Not MM_atTotal %>
  483.           </td>
  484.         </tr>
  485.       </table></td>
  486.   </tr>
  487. </table>
  488. </body>
  489. </html>
  490. <%
  491. rst.Close()
  492. Set rst = Nothing
  493. %>
  494. <%
  495. rss.Close()
  496. %>
  497. <%
  498. rssetup.Close()
  499. Set rssetup = Nothing
  500. %>