How to achieve the statistics of different IP address views
Guest counter functions
function counter () {
!empty ($_get[' weburl ') | | Die (' Weburl cannot be empty ');
$weburl = $_get[' Weburl ');
$file = '/usr/local/apache/htdocs/mytests/counter.txt ';
if (! file_exists ($file)) {
$num = 1;
$CF = fopen ($file, ' w ');
Fwrite ($CF, $weburl. ' '. $num);
Fclose ($CF);
} else {
$CF = fopen ($file, ' RW ');
$num = fgets ($CF);
$num = substr ($num, 15);
Fclose ($CF);
+ + $num;
$CF = fopen ($file, ' w ');
Fwrite ($CF, $num);
Fclose ($CF);
}
}
?>
Guest counter
Welcome to visit
You are the visitor of the first
place
I want to implement a different IP address and submit it after the "you are the first ... The number of times the corresponding IP was accessed ... I use a TXT file to store the IP address and number of views, in the following format:
Cases:
192.168.0.22 5
192.168.5.44 10
......
How should this program be modified? Storage PHP HTML function Color
Share to:
------Solution--------------------
Why not save the database? Do not know how to write files to help the top.
------Solution--------------------
!--? php
//Guest counter function
Function counter () {
!empty ($_get[' Weburl '])
------ Solution--------------------
Die (' Weburl cannot be empty ');