剛寫的應用於某軟體的全文檢索索引程式

來源:互聯網
上載者:User
程式|全文檢索索引|全文檢索索引 <p> <!--#include file=function/conn.asp-->

<br>

<%

keyWord=trim(request("oKey"))

sType=trim(request("oType"))

if keyWord="" or keyWord="關鍵字…" then

Response.Write "請輸入關鍵字!"

Response.End()

end if

if sType="" then

Response.Write "請選取查詢資訊類別"

Response.End()

end if

dim ftsTable '要查詢資訊的儲存表名

dim ftsFolder '要查詢資訊的儲存檔案夾 

if sType="1" then

ftsTable="tb_bzxx"

ftsFolder=fjroot

elseif sType="2" then

ftsTable="tb_other"

ftsFolder=fjroot_other

elseif sType="3" then

ftsTable="tb_info"

ftsFolder=fjroot_info

else

Response.Write "出錯了!"

Response.End

end if

sql=""

if sType="1" then

sql="select bz_xuhao as xuhao,bz_name as bname,bz_code as bcode,bz_htm as htm from " & ftsTable

elseif sType="2" then

sql="select p_xuhao as xuhao,p_name as bname,p_code as bcode,p_htm as htm from " & ftsTable

elseif sType="3" then

sql="select info_id as xuhao,info_htm,info_type as htm from " & ftsTable

else

Response.Write "出錯了!"

Response.End

end if

Call OPenConn() ' 開啟資料庫連接

set fso=server.CreateObject("scripting.filesystemobject")

set rs=server.createobject("adodb.recordset")

dim oPattern

oPattern="<p>|<p(.*)>|</p>"

'如果是查詢第三種資訊(其他資訊),則先將所有的資訊類別取出來,放到數組中。

dim infoType()

if sType="3" then

rs.Open "select type_id,type_name from tb_info_type order by type_id desc",adocon,3,1

if rs.RecordCount<=0 then

CloseRs rs

Call CloseConn

Response.Write "出錯了!"

Response.End()

end if

redim infoType(clng(rs(0)))

do while not rs.EOF

infoType(clng(rs(0)))=rs(1)

rs.MoveNext

loop

rs.Close()

end if

%>

<h4 ALIGN= "CENTER" STYLE= "COLOR:#000080" > 標準資訊系統全文檢索索引結果

 關鍵字: <span style= "color:#ff0000" > <%=KEYWORD%>

</span><br>

</h4>

<hr>

<table width= "600" >

<tr>

<td style= "font-size:12;color:000000;line-height:1.8" > <%

'進行檢索

rs.Open sql,adocon,3,1

if rs.RecordCount>0 then

sCount=0

do while not rs.EOF

findPos=0

htm=rs("htm")

if htm<>"" then

vpath=ftsFolder & "/" & rs("xuhao") & "/" & htm

filePath=Server.MapPath(vpath)

if fso.FileExists(filepath) then

set oFile=fso.GetFile(filepath)

set oFilestream=oFile.openastextstream(1)

oFileInfo=""

if not oFilestream.atendofstream then

oFileInfo=FilterHTML(FilterBr(trim(oFilestream.readall)))

if oFileInfo<>"" then

findPos=instr(1,oFileInfo,keyWord,1)

'查到了資料,需要顯示

if findPos>0 then

Response.Write "<a href='" & vpath & "' target='_blank'>"

if sType="1" or sType="2" then

Response.Write "<span style='font-weight:bold;font-size:13;color:0000ff'>" & rs("bname") & " ( " & rs("bcode") & " )  </span></a><br>"

else

Response.Write "<span style='font-weight:bold;font-size:13;color:0000ff''>" & infotype(clng(rs("info_Type"))) & "  </span></a><br>"

end if

if findPos>50 then

Response.Write "…" & replace(mid(oFileInfo,findPos-50,200),keyWord,"<span style='color:ff0000'>" & keyWord & "</span>",1,-1,1) &



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.