濮阳杆衣贸易有限公司

主頁 > 知識庫 > asp下IP地址分段計算函數(shù)

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

熱門標簽:宿州防封外呼系統(tǒng)平臺 無營業(yè)執(zhí)照地圖標注教學 高質量的電銷外呼系統(tǒng) 地圖標注還可以做嗎 硅基電話機器人加盟 外呼系統(tǒng)怎么話費 滴滴地圖標注上車點 友邦互聯(lián)電銷機器人違法嗎 電銷機器人采購
IP地址分段計算
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中沒有位操作,這樣在一個頁面中用到了js和vbs,并不好,如果用vbs也可以,不過羅嗦了一些,而且有一點注意,如果在vbs中split("202.102.29.6","."),會得到202,102,29三個數(shù),得不到最后一個6,所以需要將ip換成split("202.102.29.6"  ".",".")
我用vbs做的,由于沒有位操作,所以做得比較麻煩
%
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>"
%> 

 

標簽:廣元 七臺河 宣城 錫林郭勒盟 江門 儋州 雅安 新余

巨人網(wǎng)絡通訊聲明:本文標題《asp下IP地址分段計算函數(shù)》,本文關鍵詞  asp,下,地址,分段,計算,函數(shù),;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《asp下IP地址分段計算函數(shù)》相關的同類信息!
  • 本頁收集關于asp下IP地址分段計算函數(shù)的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    泉州市| 辽阳县| 林周县| 巴马| 襄汾县| 林口县| 应用必备| 军事| 安福县| 杭锦旗| 泰宁县| 朝阳县| 普格县| 孟连| 句容市| 宁波市| 若羌县| 昆明市| 开平市| 宁国市| 多伦县| 富源县| 山丹县| 横峰县| 铁岭县| 石泉县| 绥宁县| 普兰店市| 昌邑市| 建宁县| 四川省| 德州市| 绥阳县| 卫辉市| 苍溪县| 日照市| 新闻| 通河县| 浦城县| 长阳| 宝坻区|