Line 42 is: If Contents.InStr(pIP) > 0 Then
pIP is in the text file along with the IP addresses.
I would rather do this via code than access lists on the router.
But I keep getting this error:
Microsoft VBScript runtime error '800a01a8'
Object required: 'Contents'
/Folder/ValidAddressList.asp, line 42
Here is my code:
FUNCTION ValidIPs(pIP) Const Filename = "/Folder/ipaddress.txt" ' file of ip addresses to read Const ForReading = 1, ForWriting = 2, ForAppending = 3 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 ' create a filesystem object Dim FSO set FSO = server.CreateObject("Scripting.FileSystemObject") ' map the logical path to the physical system path Dim Filepath Filepath = Server.MapPath(Filename) IF FSO.FileExists(Filepath) Then Set TextStream = FSO.OpenTextFile(Filepath, ForReading, False, TristateUseDefault) ' read file in one hit, then close text file Dim Contents ' Dim position ' Position=instr(1, contents, pIP,comparemethod.text) 'if isObject(Contents) then ' set objectName = nothing 'end if ' Set Contents = nothing ' Set Contents.InStr(pIP) = nothing Contents = TextStream.ReadAll If Contents.InStr(pIP) > 0 Then ValidIPs = true Else ValidIPs = false End If TextStream.Close Set TextStream = nothing ELSE ' close file TextStream.Close Set FSO = nothing END IF END FUNCTION %>