Modificare il file:
\Buoni-spesa-OLD\buono_searchsuggest.asp
<!--#include file="include/dbcommon.asp"--> <!--#include file="include/buono_variables.asp"--> <% if SESSION("UserID")="" then response.End end if if not CheckSecurity(SESSION("_" & strTableName & "_OwnerID"),"Search") then response.End end if dim objDict, numDictEl, objFields set objDict = Server.CreateObject("Scripting.Dictionary") numDictEl = 0 if Request.QueryString("searchFor") <> "" then dbConnection="" db_connect() Set rs = server.CreateObject("ADODB.Recordset") dim searchFor, searchField, whereCondition,field searchFor = postvalue("searchFor") searchField = GoodFieldName(postvalue("searchField")) if searchField = "" or searchField="N_Buono" then field="N_Buono" if CheckFieldPermissions(field,"") then if suggestAllContent then whereCondition = " like '%" & replace(searchFor,"'","''") & "%'" else whereCondition = " like '" & replace(searchFor,"'","''") & "%'" end if whereCondition = " " & GetFullFieldName(field,"") & whereCondition whereCondition = whereAdd(gsqlWhere,whereCondition) strSQL = "SELECT DISTINCT TOP 10 " & GetFullFieldName(field,"") & " " & gsqlFrom & " WHERE " & whereCondition & gsqlTail & " ORDER BY 1" rs.Open strSQL, dbConnection,1,2 do while not rs.EOF pos=InStr(rs(0),vbLf) if pos <> 0 then objDict(numDictEl)=Left(rs(0),pos) numDictEl = numDictEl + 1 else objDict(numDictEl)=rs(0) numDictEl = numDictEl + 1 end if rs.MoveNext loop rs.Close end if end if if searchField = "" or searchField="titolo" then field="titolo" if CheckFieldPermissions(field,"") then if suggestAllContent then whereCondition = " like '%" & replace(searchFor,"'","''") & "%'" else whereCondition = " like '" & replace(searchFor,"'","''") & "%'" end if whereCondition = " " & GetFullFieldName(field,"") & whereCondition whereCondition = whereAdd(gsqlWhere,whereCondition) strSQL = "SELECT DISTINCT TOP 10 " & GetFullFieldName(field,"") & " " & gsqlFrom & " WHERE " & whereCondition & gsqlTail & " ORDER BY 1" rs.Open strSQL, dbConnection,1,2 do while not rs.EOF pos=InStr(rs(0),vbLf) if pos <> 0 then objDict(numDictEl)=Left(rs(0),pos) numDictEl = numDictEl + 1 else objDict(numDictEl)=rs(0) numDictEl = numDictEl + 1 end if rs.MoveNext loop rs.Close end if end if if searchField = "" or searchField="cognome_nome" then field="cognome_nome" if CheckFieldPermissions(field,"") then if suggestAllContent then whereCondition = " like '%" & replace(searchFor,"'","''") & "%'" else whereCondition = " like '" & replace(searchFor,"'","''") & "%'" end if whereCondition = " " & GetFullFieldName(field,"") & whereCondition whereCondition = whereAdd(gsqlWhere,whereCondition) strSQL = "SELECT DISTINCT TOP 10 " & GetFullFieldName(field,"") & " " & gsqlFrom & " WHERE " & whereCondition & gsqlTail & " ORDER BY 1" rs.Open strSQL, dbConnection,1,2 do while not rs.EOF pos=InStr(rs(0),vbLf) if pos <> 0 then objDict(numDictEl)=Left(rs(0),pos) numDictEl = numDictEl + 1 else objDict(numDictEl)=rs(0) numDictEl = numDictEl + 1 end if rs.MoveNext loop rs.Close end if end if if searchField = "" or searchField="importo" then field="importo" if CheckFieldPermissions(field,"") then if suggestAllContent then whereCondition = " like '%" & replace(searchFor,"'","''") & "%'" else whereCondition = " like '" & replace(searchFor,"'","''") & "%'" end if whereCondition = " " & GetFullFieldName(field,"") & whereCondition whereCondition = whereAdd(gsqlWhere,whereCondition) strSQL = "SELECT DISTINCT TOP 10 " & GetFullFieldName(field,"") & " " & gsqlFrom & " WHERE " & whereCondition & gsqlTail & " ORDER BY 1" rs.Open strSQL, dbConnection,1,2 do while not rs.EOF pos=InStr(rs(0),vbLf) if pos <> 0 then objDict(numDictEl)=Left(rs(0),pos) numDictEl = numDictEl + 1 else objDict(numDictEl)=rs(0) numDictEl = numDictEl + 1 end if rs.MoveNext loop rs.Close end if end if if searchField = "" or searchField="durata_num" then field="durata_num" if CheckFieldPermissions(field,"") then if suggestAllContent then whereCondition = " like '%" & replace(searchFor,"'","''") & "%'" else whereCondition = " like '" & replace(searchFor,"'","''") & "%'" end if whereCondition = " " & GetFullFieldName(field,"") & whereCondition whereCondition = whereAdd(gsqlWhere,whereCondition) strSQL = "SELECT DISTINCT TOP 10 " & GetFullFieldName(field,"") & " " & gsqlFrom & " WHERE " & whereCondition & gsqlTail & " ORDER BY 1" rs.Open strSQL, dbConnection,1,2 do while not rs.EOF pos=InStr(rs(0),vbLf) if pos <> 0 then objDict(numDictEl)=Left(rs(0),pos) numDictEl = numDictEl + 1 else objDict(numDictEl)=rs(0) numDictEl = numDictEl + 1 end if rs.MoveNext loop rs.Close end if end if if searchField = "" or searchField="durata_let" then field="durata_let" if CheckFieldPermissions(field,"") then if suggestAllContent then whereCondition = " like '%" & replace(searchFor,"'","''") & "%'" else whereCondition = " like '" & replace(searchFor,"'","''") & "%'" end if whereCondition = " " & GetFullFieldName(field,"") & whereCondition whereCondition = whereAdd(gsqlWhere,whereCondition) strSQL = "SELECT DISTINCT TOP 10 " & GetFullFieldName(field,"") & " " & gsqlFrom & " WHERE " & whereCondition & gsqlTail & " ORDER BY 1" rs.Open strSQL, dbConnection,1,2 do while not rs.EOF pos=InStr(rs(0),vbLf) if pos <> 0 then objDict(numDictEl)=Left(rs(0),pos) numDictEl = numDictEl + 1 else objDict(numDictEl)=rs(0) numDictEl = numDictEl + 1 end if rs.MoveNext loop rs.Close end if end if if searchField = "" or searchField="titolare" then field="titolare" if CheckFieldPermissions(field,"") then if suggestAllContent then whereCondition = " like '%" & replace(searchFor,"'","''") & "%'" else whereCondition = " like '" & replace(searchFor,"'","''") & "%'" end if whereCondition = " " & GetFullFieldName(field,"") & whereCondition whereCondition = whereAdd(gsqlWhere,whereCondition) strSQL = "SELECT DISTINCT TOP 10 " & GetFullFieldName(field,"") & " " & gsqlFrom & " WHERE " & whereCondition & gsqlTail & " ORDER BY 1" rs.Open strSQL, dbConnection,1,2 do while not rs.EOF pos=InStr(rs(0),vbLf) if pos <> 0 then objDict(numDictEl)=Left(rs(0),pos) numDictEl = numDictEl + 1 else objDict(numDictEl)=rs(0) numDictEl = numDictEl + 1 end if rs.MoveNext loop rs.Close end if end if if searchField = "" or searchField="chiuso" then field="chiuso" if CheckFieldPermissions(field,"") then if suggestAllContent then whereCondition = " like '%" & replace(searchFor,"'","''") & "%'" else whereCondition = " like '" & replace(searchFor,"'","''") & "%'" end if whereCondition = " " & GetFullFieldName(field,"") & whereCondition whereCondition = whereAdd(gsqlWhere,whereCondition) strSQL = "SELECT DISTINCT TOP 10 " & GetFullFieldName(field,"") & " " & gsqlFrom & " WHERE " & whereCondition & gsqlTail & " ORDER BY 1" rs.Open strSQL, dbConnection,1,2 do while not rs.EOF pos=InStr(rs(0),vbLf) if pos <> 0 then objDict(numDictEl)=Left(rs(0),pos) numDictEl = numDictEl + 1 else objDict(numDictEl)=rs(0) numDictEl = numDictEl + 1 end if rs.MoveNext loop rs.Close end if end if dbConnection.Close set dbConnection = nothing end if for i=0 to objDict.Count - 1 for j=i+1 to objDict.Count - 1 if objDict(i)>objDict(j) then tmpVar=objDict(i) objDict(i)=objDict(j) objDict(j)=tmpVar end if next next if objDict.Count < 10 then for i=0 to objDict.Count - 1 if suggestAllContent then response.write Replace(Left(objDict(i),50),searchFor,"<b>" & searchFor & "</b>",1,1,1) & vbLf else response.write Left(objDict(i),50) & vbLf end if next else for i=0 to 9 if suggestAllContent then response.write Replace(Left(objDict(i),50),searchFor,"<b>" & searchFor & "</b>",1,1,1) & vbLf else response.write Left(objDict(i),50) & vbLf end if next end if %>
[
Íàçàä
]