Cálculo de segmentação de endereço IP
<scriptLanguage = "jscript" runat = "server">
functionIPDecode (EIP) {
Varip1, IP2, IP3, IP4;
Ip1 = movebyter (eip & 0xff000000,3);
IP2 = MoveByter (EIP & 0x00FF0000,2);
IP3 = MoveByter (EIP & 0x0000FF00,1);
IP4 = EIP & 0x000000FF;
returnip1+"."+ip2+"."+ip3+"."+ip4;
}
functionMoveByTel (num, bytenum) {
returnnum << = (bytenum*8)
}
functionMoveByter (num, bytenum) {
returnnum >>> = (bytenum*8)
}
</script>
Não há operação de bits no VBS, portanto, não é bom usar JS e VBS em uma página. Também está ok se você usar o VBS, mas é um pouco detalhado. E uma coisa é um pouco perceptível. Se você dividir ("202.102.29.6", ".") No VBS, você receberá três números 202, 102 e 29, e você não receberá os últimos 6, então precisará alterar o IP para dividir ("202.102.29.6" & ".". "")
Eu fiz isso com VBS e, como não há operação de bit, é mais problemático
<%
functionip2int (ipstr)
DIMIPTEMP, MAX
iPtemp = Split (ipstr & ".", "")
max = ubund (iPtemp)
ifmax <> 4then
saída de saída
endif
Dima, b, i
a = "& h"
fori = 0to3
B = hexadecimal (iPtemp (i))
iflen (b) = 1hen
b = "0" & b
endif
a = a & b
próximo
ip2int = clng (a)
Função final
functionInt2ip (IP)
DIMIPTEMP, A, IPSTR, I, comprimento
IPTEMP = Hex (IP)
comprimento = 8-len (IPTEMP)
fori = 1Tol comprimento
ipTemp = "0" & iPtemp
próximo
a = esquerda (iPtemp, 2)
a = "& h" & a
i = cint (a)
a = cstr (i)
ipstr = a & "."
A = MID (IPTEMP, 3,2)
a = "& h" & a
i = cint (a)
a = cstr (i)
ipstr = ipstr & a & "."
A = MID (IPTEMP, 5,2)
a = "& h" & a
i = cint (a)
a = cstr (i)
ipstr = ipstr & a & "."
a = à direita (iPtemp, 2)
a = "& h" & a
i = cint (a)
a = cstr (i)
ipstr = ipstr & a
int2ip = ipstr
Função final
Dimtestip, Testint
testip = "202.102.29.6"
testint = ip2int (testip)
Response.WriteTEstip & "WillbencodedTo <FontColor = Red>" & testint & "</font> <br>"
Response.WriteTEstip & "WillBedEncodedTo <FontColor = Red>" & Int2ip (testInt) & "</font> <br>"