<% ' First take care that the entry is correct or return the errors!
'------------------------------------------------------------------------------------------------------
'In case someone is using the old NameCache parameter
Session.Codepage=65001
if len(Request("NameCache"))>0 then
paraname="NameCache"
else
paraname="name"
end if
' Allow multiple items to be search
errorcode=0
sql_or=""
for each name in Request(paraname)
name=Replace(name, "*", "%")
name=Replace(name, "+", " ")
name=Replace(name, "'", "''")
'sql_or=sql_or & "(Name.NameCache LIKE '"& name &"') OR "
sql_or=sql_or & "(Name.OrthoProjection LIKE dbo.f_core_OrthoProjector('"& name &"')) OR "
'Error handling
if Instr(name,"%") > 0 and Len(name) < 4 then
errorcode=1
end if
if Instr(name,"%%") > 0 then
errorcode=2
end if
if Mid(name,1,1) = "%" and Mid(name,4,1) = "%" then
errorcode=3
end if
if len(name)<3 then
errorcode=4
end if
Next
if len(sql_or) < 4 then
errorcode = 1
else
'Delete the latest OR in the sql_or
sql_or=left(sql_or,len(sql_or)-3)
end if
'-------- Here start the error handling ---------------
%>
<% if errorcode=1 then %>
Input error 1. Please enter at least three letters with a wildcard
Return
<% elseif errorcode=2 then %>
Input error 2. Please do not enter successive wildcards
Return
<% elseif errorcode=3 then %>
Input error 3. Please enter at least three letters between wildcards
Return
<% elseif errorcode=4 then %>
Input error 4. Please enter at least three letters
Return
<% else %>
<%
'There was no problems in the input --------
'The SQL statement changes depending a Reference is selected or not.
' If Request("RefId")<>"" then
SQL = SQL & "SELECT DISTINCT Name.NameCache AS Name, PTRefFk FROM Name INNER JOIN PTaxon ON Name.NameId = PTaxon.PTNameFk WHERE ("& sql_or &") AND PTRefFk IN (7000000, 7700000)" & " ORDER BY Name.NameCache"
' else
' SQL=SQL&"SELECT DISTINCT Name.NameCache AS Name FROM Name INNER JOIN PTaxon ON Name.NameId = PTaxon.PTNameFk WHERE "& sql_or &" ORDER BY Name.NameCache"
' end if
Set Rspecie = Server.CreateObject("ADODB.Recordset")
Rspecie.ActiveConnection = MM_jun_STRING
Rspecie.Source = SQL
Rspecie.CursorType = 3
Rspecie.CursorLocation = 2
Rspecie.LockType = 1
Rspecie.Open()
' Add this query to 00_WebSpy table in the connected database
Set AnotherConnection = Server.CreateObject("ADODB.Connection")
AnotherConnection.Open MM_jun_STRING
SQLInsert = "INSERT INTO [00_WebSpy] (NameSearched, Created_When, IP) VALUES ('" + Replace(Request("Name"), "'", "''") + "', GetDate(), '" + Request.ServerVariables("REMOTE_ADDR") + "')"
AnotherConnection.Execute SQLInsert
AnotherConnection.Close
Set AnotherConnection = Nothing
%>
<%' if a reference is selected take his name from the database
if Request("RefId")<>"" then
SQL="SELECT Refcache FROM reference WHERE RefId="& Request("RefId")
Set Rname_ref = Server.CreateObject("ADODB.Recordset")
Rname_ref.ActiveConnection = MM_jun_STRING
Rname_ref.Source = SQL
Rname_ref.CursorType = 3
Rname_ref.CursorLocation = 2
Rname_ref.LockType = 1
Rname_ref.Open()
name_ref=Rname_ref("RefCache")
Rname_ref.close
set Rname_ref=Nothing
end if
%>
<%=Rspecie.Recordcount%> names found. Click on name for details.
<%if Request("RefId")<>"" then%>
Search restricted to: <%=name_ref%>
<%end if%>
<%
'end of the error in the input handled
end if %>
|
|