"Pursuit" has now been vigorous, his success is the perseverance of its database maintenance,
Many software is using its data, some changed the name, become xxx.dat, 嗬嗬, I think it is not easy, there is something wrong.
My code has also used him, and it doesn't matter if it doesn't change the name. The key to respect people's work is good.
Add a simple code on the web page to display the location of the visitor.
You can also write a personalized log in your own website, and record the IP also record the location.
The effect can check the lower corner of www.fogsun.com.
php / **************************************************************** ************************ IP Source Tracking Ver 1.1a * author 子 paze@21cn.com http://www.fogsun.com* 2002 / 08/10 * * The database in the program comes from "pursuing". Please copy the wry.dll in the champion to the current directory. * The pursued database is a DBF file, but its extension name turns a DLL. * In 2000, I found his DLL's true format in an accidental opportunity. Later, many articles mentioned this format, * "The" chasing "data files are currently available very widely, and many of the basics of IP source programs are basically used. His database. * If there is an advertisement, you can display the QQ of the IP source to use him. * A PHP function is written in early 2001, but the PHP's DBF module is required, and many websites do not provide this module. * The current version is read and written in binary files, does not rely on PHP's DBF support, no * any shell command. * Since the data file itself is ordered, it is very convenient to use a folded half-find algorithm, * The speed is very fast, the current 20020325 version of the database, about 28,905 records, up to 14 times. ** Thanks here "Hu Zhihong" "Feng Zhihong" * If you have any questions, please contact me, thank you! Pazee@21cn.com * * * Declaration: * You can spread, copy, modify this program, but keep this paragraph. * Code Do not use it on commercial software, do not use in an improper place (this is "chasing" requirements), * again expressed thank you. *********************************************************** ******************** /
// define path of wry.dlldefine ("dbfilename", "wry.dll");
Class TREC {Var $ Startip; Var $ ENDIP; VAR $ currently; var $ local;
Class TWRU {var $ ip; var $ fp; var $ data; var $ datafieldbegin = 0xc2; var $ recordlength; // check ip and format ip function formatip ($ ip) {$ RET = EREG ("^ 9] ) /. ([0-9] ) /. ([0-9] ) /. ([0-9] ) $ ", $ IP, $ IPSECTION; if ($ RET == False) Return -1; // Invild IP $ this-> IP = '; for ($ I = 1; $ I <= 4; $ I ) IF ($ IPSECTION [$ I]> 255) Return -1; Else $ this-> ip. = Sprintf ("% 03.0F", $ IPSECTION [$ I]). ($ I <4)? '.': '); Return 0;} //} // Read a Record from DB Function ReadRec ($ 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 $ THI SEEK_SET);} // where_are_you main fucntion / ****************************************** ********* * Use instructions * Parameters: * IP legal IP address can * Szlocal is the * return value of the returned result string: * This function has a return value, you can process it according to the return value Result * 0: Find success * -1: Invalid IP * 1: Open database file failed * 2: Data file error (did not find a valid record) * 3: Unknown IP ************ ***************************************** / Function WRU ($ IP, & $ SZLOCAL) {$ this-> REC = New TREC; $ nret = 0; $ this-> recordlength = 17 22 13 47 12 1;
IF ($ this-> formatip ($ i)! = 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_ek_end); $ recordcount = floor ((ftell ($ this-> fp) - $ This-> datafieldbegin) / $ this-> recordlength; if ($ recordcount <= 1) {$ szlocal = "fileDatarror"; $ nret = 2;} else {$ rangb = 0; $ RANGE = $ recordcount; // Match ... while ($ RANGB <$ RANGE-1) {$ RECNO = Floor (($ RANGB $ RANGE) / 2); $ this-> Readrec ($ Recno); if (Strcmp ($ this-> ip $ this-> Rec-> startip> = 0 && strcmp ($ this-> ip, $ this-> r-> endip) <= 0) BREAK; // Found Match Record IF ($ this-> IP, $ this-> Rec-> startip> 0) $ rangb = $ recno; else $ RANGE = $ Recno;} IF (! ($ rangb <$ range-1))) {$ Szlocal = "unknowlocal!"; $ Nret = 3;} else {// Match Success $ szlocal = $ this-> Rec-> country; $ szlocal. = $ This-> r-> local;}} fclose $ this-> fp); return $ nret;}}
/ ************************************************** ***************** Change record: * 2002/08/10 Complete version 1.0A * 2002/08/12 Add Formatip member function, providing the standard format for IP The write method of this class, the internal automatic transfer of the class is 202.096.128.068, * At the same time, a complete valid check for IP addresses is available. The rule is that the four integer parts do not exceed the number of natural numbers of 255. * ********************************************************** ******************* /?>
// Test Code. $ SZRESULT = ""; $ IP = "202.96.134.133"; // $ ip = $ remote_addr; $ wru-> WRU ($ IP, $ SZRESULT); ECHO $ IP. "
"; Echo $ szResult; // ----------------------------------- ----------------------------------------?>