/*
$pro 使用(sina,ip138)可选
*/
public function get_ip_address($ip,$pro='ip138')
{
$ip_address = '';
if($ip == '127.0.0.1')
{
$ip_address = '本机 127.0.0.1';
}else if($pro=='ip138')
{
$url = 'http://www.ip138.com/ips138.asp?ip='.$ip;
$content = file_get_contents($url );
preg_match("/<ul class=\"ul1\"><li>[\s|\S]*?<\/li><\/ul>/",$content,$matches);
$ip_address = iconv('gbk','utf-8',$matches[0]);
}else
{
$url = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip='.$ip;
$content = file_get_contents($url );
$content = str_replace('var remote_ip_info =', '', $content);
$content = rtrim($content,';');
$content = trim($content);
$content = json_decode($content,true);
if($content)
{
$ip_address = $content['country'].' '.$content['province'].' '.$content['city'].' '.$content['district'].' '.$content['isp'].' '.$content['type'].' '.$content['desc'];
}
}
return $ip_address;
} 转载注明:雷劈网
ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。