|

分享源码
界面截图: |
- |
是否带模块: |
- |
备注说明: |
- |
自行上https://github.com/lionsoul2014/ip2region | 下载xdb文件
窗口程序集名 | 保 留 | 保 留 | 备 注 | ip2region | | | | 变量名 | 类 型 | 数组 | 备 注 | qqwry数据 | 字节集 | | sPtr | 整数型 | | ePtr | 整数型 | | VectorIndexCols | 整数型 | | VectorIndexSize | 整数型 | | SegmentIndexSize | 整数型 | |
qqwry数据 = { }qqwry数据 = IP文件数据 VectorIndexSize = 8 VectorIndexCols = 256 SegmentIndexSize = 14 变量名 | 类 型 | 静态 | 数组 | 备 注 | ipInt | 长整数型 | | | l | 整数型 | | | u | 整数型 | | | m | 整数型 | | | p | 整数型 | | | buff | 字节集 | | | sip | 长整数型 | | | eip | 长整数型 | | | dataLen | 短整数型 | | | dataPtr | 长整数型 | | | bin | 字节集 | | |
ipInt = ip2long (IP地址 ) 如果真 (ipInt = 0 ) 返回 (“未知IP”) l = 0 u = (ePtr - sPtr ) ÷ SegmentIndexSize 判断循环首 (l ≤ u ) m = 到整数 ( (l + u ) ÷ 2 )  p = sPtr + m × SegmentIndexSize  buff = 取字节集中间 (qqwry数据, p + 1, 14 ) sip = 取字节集数据 (取字节集中间 (buff, 0, 4 ), #长整数型, ) 判断 (ipInt < sip )   u = m - 1   eip = 取字节集数据 (取字节集中间 (buff, 5, 4 ), #长整数型, )   判断 (ipInt > eip )   l = m + 1    dataLen = 取字节集数据 (取字节集中间 (buff, 9, 1 ), #短整数型, )    dataPtr = 取字节集数据 (取字节集中间 (buff, 11, 4 ), #长整数型, )      bin = 取字节集中间 (qqwry数据, dataPtr + 1, dataLen )   返回 (到文本 (文本编码转换 (bin, , )) )     判断循环尾 ()返回 (“cha询失败”)变量名 | 类 型 | 静态 | 数组 | 备 注 | IP | 文本型 | | 0 | idx | 长整数型 | | | 指针 | 整数型 | | |
IP = 分割文本 (IP地址, “.”, ) 如果真 (取数组成员数 (IP ) ≠ 4 ) 返回 (0 )idx = 到数值 (IP [1]) × VectorIndexCols × VectorIndexSize + 到数值 (IP [2]) × VectorIndexSizesPtr = 取字节集数据 (取字节集中间 (qqwry数据, idx + 256 + 1, 8 ), #长整数型, )ePtr = 取字节集数据 (取字节集中间 (qqwry数据, idx + 256 + 5, 8 ), #长整数型, )返回 (到数值 (IP [4 ]) + 到数值 (IP [3 ]) × 256 + 到数值 (IP [2 ]) × 求次方 (256, 2 ) + 到数值 (IP [1 ]) × 求次方 (256, 3 ))
使用方法
变量名 | 类 型 | 静态 | 数组 | 备 注 | ip | ip2region | | | 时间 | 整数型 | | |
ip. 初始化 (读入文件 (“ip2region.xdb”)) 输出调试 (取程序名称 (1 ), ip. IP (“127.0.0.1”)) 时间 = 取启动时间 ()输出调试 (取程序名称 (1 ), ip. IP (“120.4.167.70”)) 调试输出 (取启动时间 () - 时间 )
|
评分
-
查看全部评分
本帖被以下淘专辑推荐:
- · 个人收藏|主题: 2546, 订阅: 83
- · 收藏|主题: 250, 订阅: 6
|