** * ip转换为对应地区地址类 * @version 1.0 2012-12-20 */ class ip2Area{ protected $errors = array(); protected $service = 'api.ipinfodb.com'; protected $version = '***'; protected $apiKey = '*******'; public function __construct(){} public function __destruct(){} public function setKey($key){ if(!empty($key)){ $this->apiKey = $key; } } public function getError(){ return implode("\n", $this->errors); } public function getCountry($host){ return $this->getResult($host, 'ip-country'); } public function getCity($host){ return $this->getResult($host, 'ip-city'); } private function getResult($host, $name){ $ip = @gethostbyname($host); if(preg_match('/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/', $ip)){ $xml = @file_get_contents('http://' . $this->service . '/' . $this->version . '/' . $name . '/?key=' . $this->apiKey . '&ip=' . $ip . '&format=xml'); try{ $response = @new SimpleXMLElement($xml); foreach($response as $field=>$value){ $result[(string)$field] = (string)$value; } return $result; } catch(Exception $e){ $this->errors[] = $e->getMessage(); return; } } $this->errors[] = '"' . $host . '" is not a valid IP address or hostname.'; return; } }
相关推荐
提供把ip地址转换为长整型,把长整型转换为ip地址 。提供一个一般的地址(如192.168.1.250),以及掩码的长度(如24),得到网络地址(如192.168.1.0)。获取掩码位数。根据起始地址,终止地址,掩码长度,获取可使用的...
365IP自动转换IP地址工具, 可以在一定的时间转换一次IP地址。
IpUtil工具类--通过request获取IP,通过IP获取地址(需要联网,调用淘宝的IP库)。使用场景:在网站开发记录用户增删改查日志的时候,往往需要记录操作人的IP地址,来准确的生成操作日志记录等
标准时间与绝对时间进行转换、标准IP与十进制和十六进制IP进行转换
纯真IP库转换工具转换为其他IP库或者TXT文本
时间互转整型、IP地址互转整型、的工具,方便程序开发,数据查询。
时间转换成数字、ip地址转换成数字。数字转换成时间、数字转换成ip地址。
该工具是实现IP地址转换整形的工具,也可以把整形转化为ip地址
2、该工具类可以将数据库表列字段转化为对应的Java实体类字段。生成的实体类字段格式清晰易读,且符合Java命名规范。通过使用该工具类,可以大大提高开发效率,节约时间成本。 3、该工具类使用非常简单。只需要...
IP转换工具,可以将当前的ip转换为ip段,有需要可以下载使用。
利用淘宝IP地址库实现的利用IP获取用户所在地工具类
此工具类包含根据ip和掩码(cidr)计算网段 判断ip是否在网段内 判断是否是ip ip转long long类型的ip转string
扫描局域网对应ip的mac地址工具,通过arp学习到对应ip的mac地址
IP转换工具4.5
使用纯真工具下载最新ip地址转换 然后将txt文件上传到linux系统 导入spark中,使用spark连接mysql 将表保存到mysql中 然后将表导出sql脚本文件
BIP39 Tool 将BIP39助记符转换为地址和私钥的工具。
可以进行进制间的转化,ASCII码与进制间的转换,IP与进制间的转换
ipsetter 免费正式专业版 测试WIN7下可以用 无病毒 无需破解 IP 转换工具 IP监测 IP地址修改
字符转换工具,用于转换编码之类的字符转换工具,用于转换编码之类的字符转换工具,用于转换编码之类的字符转换工具,用于转换编码之类的字符转换工具,用于转换编码之类的字符转换工具,用于转换编码之类的字符转换...