حساب تجزئة عنوان 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 ، لكنها مطوّلة قليلاً. وشيء واحد هو ملحوظ قليلا. إذا قمت بتقسيم ("202.102.29.6" ، ".") في VBS ، فستحصل على ثلاثة أرقام 202 و 102 و 29 ، ولن تحصل على الستة الأخيرة ، لذلك تحتاج إلى تغيير IP إلى الانقسام ("202.102.29.6" & ".". ".")
لقد فعلت ذلك مع VBS ، ولأنه لا يوجد عملية بت ، فهي أكثر إثارة للقلق
<٪
functionip2int (IPSTR)
DimIptemp ، ماكس
iptemp = split (ipstr & "." ، ".")
ماكس = أوبوند (iptemp)
Ifmax <> 4then
exitfunction
Endif
ديما ، ب ، أنا
a = "& h"
fori = 0to3
B = Hex (iptemp (i))
iflen (b) = 1th
ب = "0" & ب
Endif
A = A & B.
التالي
ip2int = clng (a)
الوظيفية
functionInt2ip (IP)
DimIptemp ، A ، IPSTR ، I ، الطول
iptemp = hex (IP)
الطول = 8 لين (iptemp)
fori = 1tolength
iptemp = "0" & iptemp
التالي
أ = اليسار (iptemp ، 2)
a = "& h" & a
أنا = cint (أ)
A = CSTR (i)
IPSTR = A & "."
أ = منتصف (iptemp ، 3،2)
a = "& h" & a
أنا = cint (أ)
A = CSTR (i)
IPSTR = IPSTR & A & "."
أ = منتصف (iptemp ، 5،2)
a = "& h" & a
أنا = cint (أ)
A = CSTR (i)
IPSTR = IPSTR & A & "."
a = الحق (iptemp ، 2)
a = "& h" & a
أنا = cint (أ)
A = CSTR (i)
IPSTR = IPSTR & A.
int2ip = ipstr
الوظيفية
Dimtestip ، testint
testip = "202.102.29.6"
testInt = ip2int (testip)
Response.Writetestip & "willbeencodedto <fontcolor = red>" & testint & "</font> <br>"
Response.WritEtestip & "willbedencodedto <fontcolor = red>" & int2ip (testint) و "</font> <br>"