This program uses php + txt to calculate the number of web page visits. It is simple and practical to record the number of times a user accesses a Web page. This program uses php + txt to calculate the number of web page visits. It is simple and practical to record the number of times a user accesses a Web page.
Script ec (2); script
Include ("counter. php ")
?>
| The Code is as follows: |
|
|
Visitor counter
You are the first Visitors,
Your ip Address:
|
| The Code is as follows: |
|
|
$ Fp = fopen ("counter.txt", "r + ");
$ Counter = fgets ($ fp, 80 );
$ Counter = doubleval ($ counter) + 1;
Fseek ($ fp, 0 );
Fputs ($ fp, $ counter );
Fclose ($ fp );
/*
If you want to make this statistician an image, you can add the following code and make the image named in the images directory.
*/
$ Number = strlen ("$ counter ");
For ($ I = 0; $ I <$ number; $ I ++ ){
$ Gra_counter = substr ($ counter, $ I, 1 );
$ Image = $ image ."";
}
If ($ http_server_vars ["http_x_forwarded_for"])
{
$ Ip = $ http_server_vars ["http_x_forwarded_for"];
}
Elseif ($ http_server_vars ["http_client_ip"])
{
$ Ip = $ http_server_vars ["http_client_ip"];
}
Elseif ($ http_server_vars ["remote_addr"])
{
$ Ip = $ http_server_vars ["remote_addr"];
}
Elseif (getenv ("http_x_forwarded_for "))
{
$ Ip = getenv ("http_x_forwarded_for ");
}
Elseif (getenv ("http_client_ip "))
{
$ Ip = getenv ("http_client_ip ");
}
Elseif (getenv ("remote_addr "))
{
$ Ip = getenv ("remote_addr ");
}
Else
{
$ Ip = "unknown ";
}
|