<% Function Valid_IP(IPAddr) 'Due to the constraints of VBScript I had to use the CByte function instead of declaring the variable as a byte Dim part(3), Period, IP On Error Resume Next IP = IPAddr For i = 0 To 2 'Find the period in the string Period = InStr(1, IP, ".") part(i) = CByte(Mid(IP, 1, Period - 1)) IP = Mid(IP, Period + 1, Len(IP) - Period) err.clear Next part(3) = CByte(IP) If Err.Number > 0 Then Valid_IP = False Err.Clear Else Valid_IP = True End If End Function Function checkmask(Mask) Dim aryMask, Number, x aryMask = Split(Mask,".") If UBound(aryMask) <> 3 then checkmask = false Else For x = 0 To UBound(aryMask) 'this returns true if the Mask is a valid mask If CInt(aryMask(x)) <> 255 And CInt(aryMask(x)) <> 0 And CInt(aryMask(x)) <> 128 And _ CInt(aryMask(x)) <> 224 And CInt(aryMask(x)) <> 240 And CInt(aryMask(x)) <> 248 And _ CInt(aryMask(x)) <> 252 And CInt(aryMask(x)) <> 254 Then checkmask = False Exit For Else checkmask = True End If Next End If End Function If Request.ServerVariables("REQUEST_METHOD") = "POST" Then Dim aryIpAddress, aryMask strIPAddress = Request.Form("IP") strMask = Request.Form("Mask") aryIPAddress = Split(strIPAddress, ".") aryMask = Split(strMask,".") If Not Valid_IP(strIPAddress) Then Response.Write "" & vbCrLf Else If Not checkmask(strMask) Then Response.Write "" & vbCrLf Else Response.Redirect "ipdisplay.asp?IP=" & strIPAddress & "&Mask=" & strMask End If End If End If %> New Page 3
IP Address Calculator
   
 IP Information
 IP Address
 Subnet Mask
     

Hosted by uCoz