佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > asp下IP地址分段計(jì)算函數(shù)

asp下IP地址分段計(jì)算函數(shù)

熱門(mén)標(biāo)簽:團(tuán)購(gòu)網(wǎng)站 服務(wù)器配置 電子圍欄 Linux服務(wù)器 科大訊飛語(yǔ)音識(shí)別系統(tǒng) 阿里云 銀行業(yè)務(wù) Mysql連接數(shù)設(shè)置
IP地址分段計(jì)算
script language="JScript" Runat="Server">
function IPDeCode(EIP){
var Ip1,Ip2,Ip3,Ip4;
Ip1 = moveByteR(EIP  0xff000000,3);
Ip2 = moveByteR(EIP  0x00ff0000,2);
Ip3 = moveByteR(EIP  0x0000ff00,1);
Ip4 = EIP  0x000000ff;
return Ip1 + "." + Ip2 + "." + Ip3 + "." + Ip4;
}


function moveByteL(num,bytenum){
return num = (bytenum*8)
}

function moveByteR(num,bytenum){
return num >>>= (bytenum*8)
}

/script>


在vbs中沒(méi)有位操作,這樣在一個(gè)頁(yè)面中用到了js和vbs,并不好,如果用vbs也可以,不過(guò)羅嗦了一些,而且有一點(diǎn)注意,如果在vbs中split("202.102.29.6","."),會(huì)得到202,102,29三個(gè)數(shù),得不到最后一個(gè)6,所以需要將ip換成split("202.102.29.6"  ".",".")
我用vbs做的,由于沒(méi)有位操作,所以做得比較麻煩
%
function ip2int(ipstr)
dim iptemp,max
iptemp = split(ipstr".",".")
max = ubound(iptemp)
if max > 4 then
exit function
end if

dim a,b,i
a = "H"
for i = 0 to 3
b = Hex(iptemp(i))
if len(b) = 1 then
b = "0"b
end if
a = ab
next
ip2int = CLng(a)
end function

function int2ip(ip)
dim iptemp,a,ipstr,i,length
iptemp = Hex(ip)
length = 8 - len(iptemp)
for i = 1 to length
iptemp = "0"  iptemp
next
a = left(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
end function

dim testIP,testInt
testIP="202.102.29.6"
testInt = ip2int(testIP)
response.write testIP  " will be encoded to font color=red>"  testInt  "/font>br>"
response.write testIP  " will be dencoded to font color=red>"  int2ip(testInt)  "/font>br>"
%> 

 

標(biāo)簽:江蘇 棗莊 蚌埠 萍鄉(xiāng) 廣元 衢州 衡水 大理

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp下IP地址分段計(jì)算函數(shù)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    磐石市| 天峻县| 分宜县| 保亭| 连南| 梁平县| 华蓥市| 宁明县| 安乡县| 宝清县| SHOW| 垦利县| 永嘉县| 万宁市| 杭州市| 盘山县| 武胜县| 微博| 兴化市| 宜州市| 横山县| 利辛县| 襄樊市| 东明县| 德庆县| 赤壁市| 涟源市| 会昌县| 随州市| 长泰县| 来凤县| 自治县| 淄博市| 陵水| 郴州市| 陵川县| 长武县| 广宁县| 专栏| 临邑县| 通海县|