<%@ ENABLESESSIONSTATE=False%> <% ' This script is used for access to online databases. It performs three functions: ' * Translates a (local) database name into a working URL, making it possible to set up stable ' local URLs that can be bookmarked and will continue to work even if the actual URL used ' to access the resource changes. ' * Checks whether the user is accessing from a TCU IP address and, whether the resource ' requires proxy access, and directs them to the EZproxy server if needed. ' * Records information in a log file used to generate usage statistics for online resources. ' ' These functions were formerly performed by http://lib.tcu.edu/htbin/validate.pp, and both scripts ' will be in use as the library makes the transition from VMS to Windows NT. ' ' PARAMETERS: ' 1 - Database name, use as GET key, rather than key-value pair: DBASE.ASP?DbaseName ' ' -Kerry Bouchard, 11/23/1999 ' ' Modifications: ' 02/16/2000: Added code so that library public OPAC terminals will prompt for ID. 'Define constants 'URL to invoke EZproxy for HTTP-based authentication (IP recognition or HTTP-username password) strEZproxy = "http://libnt2.lib.tcu.edu:2048/login?url=" 'URL to invoke EZproxy for WebScript type login strEZlogin = "http://libnt2.lib.tcu.edu:2048/login/" 'URL of script to do ID check on OPAC terminals urlOPACid = "http://libnt1.is.tcu.edu/PURL/OPAC_ID.asp?url=" 'Three constants required by FileSystemObject used for generating usage log file TristateFalse = 0 'Ascii ForAppending = 8 'Open file for append access strLogFile = "C:\winnt\system32\LogFiles\WebCounter\WWW_Counts.log" 'log file location 'Get database name from URL that invoked this script (GET rather than POST method is assumed) strName = Request.QueryString.Key(1) 'Establish connection to database set conn = server.createobject("ADODB.Connection") 'establish ODBC connection conn.open "RefDatabases" 'Now look up strName in database and get info. Shouldn't be more than one record matching query strQuery = "SELECT [Details (child table)].URLprefix & [Details (child table)]![URLunique] AS URL, [Details (child table)].Proxy, [AccessGroups (lookup table)].AccessGroup FROM [Format (lookup table)] INNER JOIN (Databases INNER JOIN ([AccessGroups (lookup table)] INNER JOIN [Details (child table)] ON [AccessGroups (lookup table)].ID = [Details (child table)].AccessGroup) ON Databases.ID = [Details (child table)].Database_ID) ON [Format (lookup table)].type_id = [Details (child table)].Format_ID WHERE (Databases.PURL = '" & strName & "') AND ([Format (lookup table)].Type='Web only' OR [Format (lookup table)].Type='Z39.50');" set RS = conn.execute(strQuery) 'Check whether user needs to connect to this database through EZproxy. "Proxy" codes are: ' 0 = None [no proxy needed ever] ' 1 = Off-campus [proxy needed if user coming from an off-campus IP address ' 2 = All - HTTP-based (only needed for databases like Hoovers that use HTTP-based username/password pair ' 3 = All - Form-based username password login dim strURL, REMOTE_ADDR strURL = RS("URL") REMOTE_ADDR = Request.ServerVariables("REMOTE_ADDR") If ( (RS("Proxy") = 1) AND (Left(REMOTE_ADDR, 7) <> "138.237") ) OR (RS("Proxy") = 2) then strURL = strEZproxy + strURL ElseIf RS("Proxy") = 3 then strURL = strEZlogin + strURL End if 'Now check if user is at an OPAC terminal, and if so send to OPAC_ID.SCR to require ID check 'OPAC_ID.SCR will handle logging usage strQuery = "SELECT IPlistOPAC.IPaddr FROM IPlistOPAC WHERE (IPlistOPAC.IPaddr = '" & REMOTE_ADDR & "');" set RSip = conn.execute(strQuery) if not RSip.EOF then 'if record found, user is at an OPAC strURL = urlOPACid + Server.URLencode(strURL) + "&Group=" & Server.URLEncode(RS("AccessGroup")) & "&name=" & strName Response.Redirect strURL End If 'Log usage Dim fsFileSystem 'FileSystemObject Dim tsLog 'TextStream Object Dim strEntry 'String to write to log file 'Proxy everybody If Left(REMOTE_ADDR, 7) = "138.237" then strEntry = strName + ",ONCAMPUS" Else strEntry = strName + ",OFFCAMPUS" End if Set fsFileSystem = Server.CreateObject("Scripting.FileSystemObject") Set tsLog = fsFileSystem.OpenTextFile(strLogFile, ForAppending, TristateFalse) tsLog.WriteLine strEntry tsLog.Close 'Response.Write "strURL = " & strURL & "
REMOTE_ADDR = " & REMOTE_ADDR 'Close connection Object conn.close 'Send user to requested resource Response.Redirect strURL %>