文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>WEB追捕PHP版源代码

WEB追捕PHP版源代码

时间:2008-04-17  来源:剑心通明


ip= '';
for ($i=1; $i 255)
return -1;
else
$this->ip.= sprintf("%03.0f", $ipsection[$i]). (($iseek($recno);
$buf= fread($this->fp, $this->recordlength);
if (strlen($buf) == 0)
{
return 1;
}
$this->rec->startip= (substr($buf, 0, 17));
$this->rec->endip= trim(substr($buf, 17, 22));
$this->rec->country= trim(substr($buf, 17+22, 13));
$this->rec->local= trim(substr($buf, 17+22+13, 47));
return 0;
}
// go to record number
function seek($recno)
{
return fseek($this->fp, $recno * $this->recordlength + $this->datafieldbegin, seek_set);
}
// where_are_you main fucntion
/*********************************************
* 使用说明
* 参数:
* ip 合法ip地址即可
* szlocal 是保存返回的结果字符串的
* 返回值:
* 此函数有返回值,可以根据返回值自行处理结果
* 0: 查找成功
* -1: 无效的ip
* 1: 打开数据库文件失败
* 2: 数据文件错误(没找到有效记录)
* 3: 未知 ip
**********************************************/
function wru($ip, &$szlocal)
{
$this->rec= new trec;
$nret= 0;
$this->recordlength= 17 + 22 + 13 + 47 + 12 + 1;
if ($this->formatip($ip) != 0)
{
$szlocal= "invalidip";
return -1;
}
$this->fp= fopen(dbfilename, "rb");
if ($this->fp == null) {
$szlocal= "openfileerror";
return 1;
}
// get record count
fseek($this->fp, 0, seek_end);
$recordcount= floor((ftell($this->fp) - $this->datafieldbegin) / $this->recordlength);
if ($recordcount readrec($recno);
if (strcmp($this->ip, $this->rec->startip) >=0 && strcmp($this->ip, $this->rec->endip) ip, $this->rec->startip) > 0)
$rangb= $recno;
else
$range= $recno;
}
if (!($rangb rec->country;
$szlocal.= $this->rec->local;
}
}
fclose($this->fp);
return $nret;
}
}
/*******************************************************************
* 变更记录:
* 2002/08/10 完成版本 1.0a
* 2002/08/12 增加formatip成员函数,提供了对ip的标准格式化,支持
* 202.96.128.68 这类的写法,类的内部自动转为 202.096.128.068,
* 同时提供了完整的对ip地址的有效检查。规则是4个整数部分均不超
* 过255的自然数。
* ********************************************************************/
// below, it is test code.
$wru= new twru;
$szresult="";
$ip= "202.96.134.133";
// $ip= $remote_addr;
$wru->wru($ip, $szresult);
echo $ip."
";
echo $szresult;
//---------------------------------------------------------------------------
?>


相关阅读 更多 +
排行榜 更多 +
西安交大通

西安交大通

生活实用 下载
长江云通

长江云通

生活实用 下载
translatez

translatez

生活实用 下载