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>
VBSには少し操作がないため、ページでJSとVBSを使用するのは良くありません。 VBSを使用しても大丈夫ですが、少し冗長です。そして、一つのことは少し目立っています。 VBSで分割( "202.102.29.6"、 ")を分割した場合、3つの数字202、102、および29を取得し、最後の6を取得しないため、IPを分割して変更する必要があります(" 202.102.29.6 "&"。 "、"。 ")
私はVBSでそれをしました、そして、少し操作がないので、それはもっと面倒です
<%
functionip2int(ipstr)
Dimiptemp、マックス
iptemp = split(ipstr& "。"、 "。")
max = ubund(iptemp)
ifmax <> 4then
exitFunction
endif
ディマ、b、i
a = "&h"
fori = 0to3
b = hex(iptemp(i))
iflen(b)= 1then
b = "0"&b
endif
a = a&b
次
ip2int = clng(a)
エンド機能
functionint2ip(ip)
dimiptemp、a、ipstr、i、長さ
iptemp = hex(ip)
長さ= 8-len(iptemp)
fori = 1tolength
iptemp = "0"&iptemp
次
a =左(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 = right(iptemp、2)
a = "&h"&a
i = cint(a)
a = cstr(i)
IPSTR = IPSTR&A
int2ip = ipstr
エンド機能
dimtestip、testint
testip = "202.102.29.6"
testint = ip2int(testip)
Response.writeTestip& "WillBeencoded to <fontcolor = red>"& "</font> <br>"
respons.writeTestip& "Willbedencoded to <fontcolor = red>"&int2ip(testint)& "</font> <br>"