<% Option Explicit %>
<%
'<<<<< DECLARE ALL VARIABLES >>>>>'
Dim sRIPa
Dim sDate
Dim intRandom
Dim objFSO
Dim objTextFile
Dim sLine
Dim sMacAddr
'<<<<< OBTAIN CLIENT's IP ADDRESS >>>>>'
sRIPa = Request.ServerVariables("REMOTE_ADDR")
'<<<<< OBTAIN DATE AND FORMAT FOR APPROPRIATE DHCP LOG EXTENSION >>>>>'
sDate = LEFT(FormatDateTime(Date, 1), 3)
'<<<<< REDIRECT BAD IP RANGES TO APPROPRIATE PAGE >>>>>'
If LEFT(sRIPa, 7) <> "255.255" Then
Response.Redirect ("error_page.asp")
End If
'<<<<< CREATE TEMP FILE NAME - RANDOMLY GENERATED >>>>>'
Randomize
intRandom = Int((99999 - 11111 + 1) * Rnd + 1)
'<<<<< COPY THE DHCP LOG TO WORKING DIRECTORY>>>>>'
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\winnt\system32\dhcp\DhcpSrvLog." & _
sDate, "C:\working\"
& intRandom & ".txt"
Set objFSO = Nothing
'<<<<< OBTAIN THE MAC ADDRESS FROM THE COPIED DHCP LOG >>>>>'
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\working\" & _
intRandom & ".txt")
Do While Not objTextFile.AtEndOfStream
sLine = objTextFile.ReadLine
If InStr(sLine, sRIPa) Then
sMacAddr = LCASE(RIGHT(sLine,12))
End If
Loop
'<<<<< CLEAN UP AND DELETE THE TEMPORARY FILE >>>>>'
objTextFile.Close
Set objTextFile = Nothing
objFSO.DeleteFile ("C:\working\" & intRandom & ".txt")
Set objFSO = Nothing
'<<<<< FORMAT THE MAC ADDRESS >>>>>'
sMacAddr = LEFT(sMacAddr, 4) & "." & MID(sMacAddr, 5, 4) & "." &
RIGHT(sMacAddr, 4)
'<<<<< GENERATE THE HTML OUTPUT >>>>>'
Response.Write ("<HTML><FORM><TABLE BORDER=0 ALIGN=LEFT><TR><TD>")
Response.Write ("<B>IP Address:</B></TD><TD><INPUT TYPE='TEXT'")
Response.Write (" SIZE=15 VALUE='" & sRIPa & "'>")
Response.Write ("</TD></TR>")
Response.Write ("<TR><TD><B>MAC Address:</B> </TD><TD>")
Response.Write ("<INPUT TYPE=TEXT SIZE=15 VALUE='" & sMacAddr)
Response.Write ("'></TD>")
Response.write ("</TR></TABLE></FORM></HTML>")
%>