<%@ Language=VBScript %> <% Option Explicit %> MCFLS Database Redirect <% Function CheckForErrors(objConn) Dim objError If objConn.Errors.Count > 0 Then For Each objError in objConn.Errors 'Errors numbered with 0 are informational If objError.Number <> 0 Then Response.Write "" & _ "" & _ "
Error PropertyContents
Number" & objError.Number & _ "
Native Error" & objError.NativeError & _ "
SQL State" & objError. SQLState & _ "
Sources" & objError.Source & _ "
Description" & objError.Description & _ "

" CheckForErrors = True End If Next Else CheckForErrors = False End If End Function Dim conn, connString, rsRedirect Dim sql, iAmpPos Dim bOffCampus, sIP, sHost, sPort, sDomain, sTarget, sURL, sURL2, sRemainder sIP = Request.ServerVariables("REMOTE_ADDR") sPort = server.htmlencode(Request.QueryString("Port")) sDomain = server.htmlencode(Request.QueryString("Domain")) sRemainder = server.htmlencode(Request.QueryString("Target")) iAmpPos = 1 Do iAmpPos = InStr(1, sRemainder, "(AMP)") If iAmpPos > 0 Then sTarget = sTarget & Left(sRemainder, iAmpPos -1) & "&" Else Exit Do End If sRemainder = Mid(sRemainder, iAmpPos + 5) Loop sTarget = sTarget & sRemainder sURL = "http://" sURL2 = sURL & sDomain Function MediumDate (str) Dim aDay Dim aMonth Dim aYear aDay = Day(str) if aDay < 10 then aDay = "0" & aDay end if aMonth = Month(str) if aMonth < 10 then aMonth = "0" & aMonth end if aYear = Year(str) MediumDate = aYear & "-" & aMonth & "-" & aDay End Function If Left(sIP, 6) = "172.21" or Left(sIP, 10) = "74.219.81." or Left(sIP, 11) = "216.56.106." or Left(sIP, 14) = "98.100.198.100" or Left(sIP, 13) = "98.100.153.90" Then bOffCampus = False sURL = sURL & sDomain & sTarget Else bOffCampus = True sURL = sURL & sPort & "-" & sDomain & ".countycat.mcfls.org" & sTarget End If If Left(sIP, 9) = "172.21.15" then sHost = "Brown Deer" elseif Left(sIP, 9) = "172.21.12" then sHost = "Cudahy" elseif Left(sIP, 9) = "172.21.7." then sHost = "Franklin" elseif Left(sIP, 9) = "172.21.5." then sHost = "Greendale" elseif Left(sIP, 9) = "172.21.6." then sHost = "Greenfield" elseif Left(sIP, 11) = "216.56.106." then sHost = "Greenfield" elseif Left(sIP, 9) = "172.21.8." then sHost = "Hales Corners" elseif Left(sIP, 9) = "172.21.14" then sHost = "North Shore" elseif Left(sIP, 9) = "172.21.13" then sHost = "Oak Creek" elseif Left(sIP, 9) = "172.21.11" then sHost = "St. Francis" elseif Left(sIP, 9) = "172.21.10" then sHost = "Shorewood" elseif Left(sIP, 9) = "172.21.16" then sHost = "South Milwaukee" elseif Left(sIP, 9) = "172.21.4." then sHost = "Wauwatosa" elseif Left(sIP, 9) = "172.21.17" then sHost = "West Allis" elseif Left(sIP, 9) = "172.21.9." then sHost = "Whitefish Bay" elseif Left(sIP, 10) = "74.219.81." then sHost = "Whitefish Bay" elseif Left(sIP, 9) = "172.21.40" then sHost = "MCFLS" elseif Left(sIP, 14) = "98.100.198.100" then sHost = "MPL" elseif Left(sIP, 13) = "98.100.153.90" then sHost = "MPL" else sHost = "Remote Host" End if 'response.Write "Url: " & sURL set conn=Server.CreateObject("ADODB.Connection") conn.Open "DSN=redtable" Set rsRedirect = Server.CreateObject("ADODB.Recordset") sql = "Select * From redirect" With rsRedirect .Open sql, conn, adOpenDynamic, adLockPessimistic If Not CheckForErrors(conn) Then conn.BeginTrans .AddNew .Fields("URL") = sDomain & sTarget .Fields("OffNetwork") = bOffCampus .Fields("Accessed") = MediumDate( Date() ) .Fields("Time") = Time .Fields("IP") = sIP .Fields("Host") = sHost .Update End If If Not CheckForErrors (conn) Then conn.CommitTrans Else conn.RollbackTrans End If .Close End With conn.Close 'Was forced to convert from a server-side to a client-side redirect because one link wouldn't work properly. 'Response.Clear 'Response.Redirect sURL Response.Write "" Response.Write "

Redirecting to " &sURL2 & ", please wait....

" Response.Write "


" %>
MCFLS LOGO