WEB追捕 PHP版 源代码
web|源代码
/**********************************************************************
* IP 来源追踪 Ver 1.1a
* 作者 耙子 pazee@21cn.com http://www.fogsun.com
* 2002/08/10
*
* 程序中的数据库来自《追捕》,请把追捕中wry.dll 拷贝到函数当前目录。
* 追捕的数据库是个的dbf文件,只不过它的扩展名字变成了dll。
* 2000年我在一个偶然的机会发现了他的dll的真实格式,后来的很多文章也提到了此格式,
* 《追捕》的数据文件目前应用非常广泛,很多查IP来源程序的基本都用到了他的数据库。
* 比如有个去广告,能显示IP来源的QQ就使用了他。
* 2001年初写过一个php的函数,但是需要php的dbf模块支持,很多网站并不提供此模块。
* 现在的版本采用二进制的文件读写,不依赖php的dbf的支持了,没有用到
* 任何shell命令.
* 由于数据文件本身是有序的,所以非常方便的采用了折半查找的算法,
* 速度很快,目前的20020325版本的数据库,大约有记录28905条,最多比较14次。
*
* 在此感谢《追捕》作者“冯志宏”
* 有任何问题请于我联系,谢谢! pazee@21cn.com
*
*
* 声明:
* 你可以随意传播、复制、修改此程序,但是请保留此段文字。
* 代码请勿用在商业软件上、请勿用在不正当的地方(这是《追捕》的要求),
* 再次表示谢谢。
***********************************************************************/
// define path of wry.dll
define("DBFILENAME", "wry.dll");
class TRec
{
var $StartIP;
var $EndIP;
var $Country;
var $Local;
}
class TWru
{
var $ip;
var $fp;
var $Rec;
var $DATAFIELDBEGIN= 0xc2;
var $RECORDLENGTH;
// Check IP and Format IP
function FormatIP($ip)
{
$ret= ereg("^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$", $ip, $IPSection);
if ($ret == false)
return -1; // Invild IP
$this->ip= '';
for ($i=1; $iif ($IPSection[$i] > 255)
return -1;
else
$this->ip.= sprintf("%03.0f", $IPSection[$i]). (($ireturn 0;
}
// read a record from DB
function ReadRec($RecNo)
{
$this->Seek($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 {
$szLocal= "FileDataError";
$nRet= 2;
}
else
{
$RangB= 0;
$RangE= $RecordCount;
// Match ...
while ($RangB {
$RecNo= floor(($RangB + $RangE) / 2);
$this->ReadRec($RecNo);
if (strcmp($this->ip, $this->Rec->StartIP) >=0 && strcmp($this->ip, $this->Rec->EndIP) break; //Found match record
if (strcmp($this->ip, $this->Rec->StartIP) > 0)
$RangB= $RecNo;
else
$RangE= $RecNo;
}
if (!($RangB {
$szLocal= "UnknowLocal!";
$nRet= 3;
}
else
{ // Match Success
$szLocal= $this->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;
//---------------------------------------------------------------------------
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

The usage of return in C language is: 1. For functions whose return value type is void, you can use the return statement to end the execution of the function early; 2. For functions whose return value type is not void, the function of the return statement is to end the execution of the function. The result is returned to the caller; 3. End the execution of the function early. Inside the function, we can use the return statement to end the execution of the function early, even if the function does not return a value.

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Source code: publicclassReturnFinallyDemo{publicstaticvoidmain(String[]args){System.out.println(case1());}publicstaticintcase1(){intx;try{x=1;returnx;}finally{x=3;}}}#Output The output of the above code can simply conclude: return is executed before finally. Let's take a look at what happens at the bytecode level. The following intercepts part of the bytecode of the case1 method, and compares the source code to annotate the meaning of each instruction in

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Vue3.2 setup syntax sugar is a compile-time syntax sugar that uses the combined API in a single file component (SFC) to solve the cumbersome setup in Vue3.0. The declared variables, functions, and content introduced by import are exposed through return, so that they can be used in Vue3.0. Problems in use 1. There is no need to return declared variables, functions and content introduced by import during use. You can use syntactic sugar //import the content introduced import{getToday}from'./utils'//variable constmsg='Hello !'//function func

JavaScript functions provide two interfaces to interact with the outside world. The parameters serve as the entrance to receive external information; the return value serves as the outlet to feed back the operation results to the outside world. The following article will take you to understand the JavaScript function return value and briefly analyze the usage of the return statement. I hope it will be helpful to you!
