How to implement different IP address views statistics

Source: Internet
Author: User
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 ');
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.