In addition, the windows line break is "rn" and the linux line break is "n"
The php ip record function is $ _ SERVER ["REMOTE_ADDR"]
PHP obtains the current time function date ("Y-m-d H: I: s", time ())
PHP functions for obtaining the origin site $ _ SERVER ['http _ referer'] must first determine whether it is null, that is, use isset to determine, for example, if we type a URL directly from the browser, there will be no URL record. The final code is very simple, as shown below:
| The code is as follows: |
Copy code |
|
$ Ip = $ _ SERVER ["REMOTE_ADDR"];
$ Time = date ("Y-m-d H: I: s", time ());
$ From = '';
If (isset ($ _ SERVER ['http _ referer'])
{
$ From = $ _ SERVER ['http _ referer'];
}
$ Myfile = 'wtndata/statistic.txt ';
$ Str = "ip = '". $ ip. "' from = '". $ from. "'Time ='". $ time. "'RN ";
$ File_pointer = fopen ($ myfile, "");
Fwrite ($ file_pointer, $ str );
Fclose ($ file_pointer ); |