PHP Classes
elePHPant
Icontem

CodeIgniter PHP Visitor Counter: Keep track of visitors to a Web site

Recommend this page to a friend!
  Info   View files Documentation   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-03-17 (5 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 104 This week: 2All time: 9,168 This week: 163Up
Version License PHP version Categories
ci-visitorcounter 1.0Free for non-comm...5PHP 5, User Management
Description Author

This class can keep track of visitors to a Web site.

It can check the IP address and user agent of the current user accessing a Web site page and appends to a file the details of the user visit.

The class can check if the user browser is not of a robot and determines the user country using GeoIP database.

It can also retrieve the user visitor count for a given date of the year.

  Performance   Level  
Name: harold rita <contact>
Classes: 2 packages by
Country: Philippines Philippines
Age: ???
All time rank: 397835 in Philippines Philippines
Week rank: 176 Up3 in Philippines Philippines Up
Innovation award
Innovation award
Nominee: 1x

 

Details

Visitorcounter

Visitorcounter is a class y for codeigniter to use this class you must install first the geoip2 via composer

  1. Download GeoLite2 Database reader : add this into your composer.json file ` { "require": { "geoip2/geoip2": "~2.0" } } ` or install via composer ` php composer require geoip2/geoip2:~2.0<br/> `
  2. Download MaxMind GeoLite2 Free Downloadable Databases: https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz

To use this class add this line to your controller

$this->library->load('visitorcounter');
$this->visitor->counter->run();

How to get the vist data

$this->library->load('visitorcounter');
//replace the date,year,month you want to display
$this->visitorcounter->read($date,$year,$month);

//For current date
$this->visitorcounter->read();
//Sample output
::1~2019-03-04 02:00 pm~Invalid IP address: ::1~JP~Invalid IP address: ::1 
::2~2019-03-04 02:00 pm~Invalid IP address: ::1~PH~Invalid IP address: ::1 
::3~2019-03-04 02:01 pm~Invalid IP address: ::1~US~Invalid IP address: ::1 
::2~2019-03-04 02:02 pm~Invalid IP address: ::1~PH~Invalid IP address: ::1 
::1~2019-03-04 02:60 pm~Invalid IP address: ::1~JP~Invalid IP address: ::1 
//Getcurrentdata by array
// getcurrentdata($date,$year,$month)
            if($data = $this->visitorcounter->getcurrentdata()){
               var_dump($data);
            }
            //output
              array(3) {
                  [0]=>
                  array(2) {
                    ["country"]=>
                    string(2) "JP"
                    ["counter"]=>
                    int(2)
                  }
                  [1]=>
                  array(2) {
                    ["country"]=>
                    string(2) "PH"
                    ["counter"]=>
                    int(2)
                  }
                  [2]=>
                  array(2) {
                    ["country"]=>
                    string(2) "US"
                    ["counter"]=>
                    int(1)
                  }
                }

  Files folder image Files  
File Role Description
Files folder imagetest (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Plain text file Visitorcounter.php Class Class source

  Files folder image Files  /  test  
File Role Description
Files folder imageapplication (1 file, 2 directories)

  Files folder image Files  /  test  /  application  
File Role Description
Files folder imagecontrollers (1 file)
Files folder imagemodels (1 file)
  Accessible without login Plain text file tb_visits.sql Data Auxiliary data

  Files folder image Files  /  test  /  application  /  controllers  
File Role Description
  Plain text file Visitors.php Class Class source

  Files folder image Files  /  test  /  application  /  models  
File Role Description
  Plain text file Visitors_model.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:104
This week:2
All time:9,168
This week:163Up