Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (47) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2024-01-11 (3 months ago) | Not enough user ratings | Total: 178 | All time: 8,734 This week: 99 |
Version | License | PHP version | Categories | |||
simple_counter 5.0.0 | GNU Lesser Genera... | 8.2.0 | Statistics, User Management, PHP 7 |
Description | Author | |
This class can count and display the visits that site pages had. |
Simple Counter is a simple PHP counter that counts your website visitors. It has the ability to either show the count as plain text or images; and whether to count only unique hits, or all hits. (IP Based)
This code is many years old (first started in 2006). I am in the process of bringing it into the modern world, and that includes the documentation. I am working on it, I promise. ;)
[^1]: If you were using custom locations for the logs
and images
directories already, you can change how you instantiate the class to point to these locations instead. See usage.
To install Simple Counter, first install via composer:
composer require esi/simple_counter
There are several options defined by default, however you will likely run into issues if you do not change some of them. More information can be found in Usage below.
Usage is fairly simple once installed. Simply add the following code to the page where you want the counter to be shown:
<?php
// Load the composer autoload file, if not already loaded
require_once 'vendor/autoload.php';
use Esi\SimpleCounter\Counter;
// Options is a string => string | bool, key => value pair array.
// Valid options are:
$options = [
'logDir' => '/path/to/some/dir/logs',
'imageDir' => '/path/to/some/dir/images',
'imageExt' => '.gif', // '.png', '.jpg' etc. default images are GIF images
'useImages' => true, // true = images, false = plain text
'useFileLocking' => true, // recommended = true for file locking on read/write operations for the log files
'countOnlyUnique' => true // true = counts only unique ip's, false = counts all
];
// If no options are passed, uses defaults
$counter = Counter::getInstance();
// ... or maybe custom directories
$counter = Counter::getInstance([
'logDir' => '/var/www/html/hitcounter/logs',
'imageDir' => '/var/www/html/hitcounter/images'
]);
// ... or maybe defaults, but I want to use custom images and higher quality PNG images
$counter = Counter::getInstance([
'imageExt' => '.png'
]);
// Finally, call process(). You can either output it directly or save it to a variable if needed
echo $counter->process();
// ... or ...
$hitCount = $counter->process();
// ..
// ...
// ... do some stuff
echo $hitCount;
?>
Bugs and feature requests are tracked on GitHub
Issues are the quickest way to report a bug. If you find a bug or documentation error, please check the following first:
Simple Counter accepts contributions of code and documentation from the community. These contributions can be made in the form of Issues or Pull Requests on the Simple Counter repository.
Simple Counter is licensed under the GNU LGPL v3 license. When submitting new features or patches to Simple Counter, you are giving permission to license those features or patches under the GNU LGPL v3 license.
Simple Counter tries to adhere to PHPStan level 9 with strict rules and bleeding edge. Please ensure any contributions do as well.
Before we look into how, here are the guidelines. If your Pull Requests fail to pass these guidelines it will be declined, and you will need to re-submit when you?ve made the changes. This might sound a bit tough, but it is required for me to maintain quality of the code-base.
Please ensure all new contributions match the PSR-12 coding style guide. The project is not fully PSR-12 compatible, yet; however, to ensure the easiest transition to the coding guidelines, I would like to go ahead and request that any contributions follow them.
If you change anything that requires a change to documentation then you will need to add it. New methods, parameters, changing default values, adding constants, etc. are all things that will require a change to documentation. The change-log must also be updated for every change. Also, PHPDoc blocks must be maintained.
Please ensure all new contributions adhere to: * PSR-5 PHPDoc * PSR-19 PHPDoc Tags
when documenting new functions, or changing existing documentation.
One thing at a time: A pull request should only contain one change. That does not mean only one commit, but one change - however many commits it took. The reason for this is that if you change X and Y but send a pull request for both at the same time, we might really want X but disagree with Y, meaning we cannot merge the request. Using the Git-Flow branching model you can create new branches for both of these features and send two requests.
Eric Sizemore - <admin@secondversion.com> - <https://www.secondversion.com>
Simple Counter is licensed under the GNU LGPL v3 License - see the COPYING
file for details
Files |
File | Role | Description | ||
---|---|---|---|---|
.github (2 files, 1 directory) | ||||
counter (2 directories) | ||||
src (1 file) | ||||
tests (1 file, 3 directories) | ||||
.php-cs-fixer.dist.php | Aux. | Auxiliary script | ||
.scrutinizer.yml | Data | Auxiliary data | ||
CHANGELOG.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
COPYING | Data | Auxiliary data | ||
COPYING.LESSER | Data | Auxiliary data | ||
phpstan.neon | Data | Auxiliary data | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation | ||
rector.php | Aux. | Auxiliary script | ||
SECURITY.md | Data | Auxiliary data |
Files | / | .github |
File | Role | Description | ||
---|---|---|---|---|
workflows (2 files) | ||||
dependabot.yml | Data | Auxiliary data | ||
FUNDING.yml | Data | Auxiliary data |
Files | / | counter | / | logs |
File | Role | Description |
---|---|---|
.htaccess | Data | Auxiliary data |
counter.txt | Data | Auxiliary data |
ips.txt | Data | Auxiliary data |
Files | / | tests |
File | Role | Description | ||
---|---|---|---|---|
images (11 files) | ||||
logs (3 files) | ||||
src (1 file) | ||||
bootstrap.php | Aux. | Auxiliary script |
Files | / | tests | / | logs |
File | Role | Description |
---|---|---|
.htaccess | Data | Auxiliary data |
counter.txt | Data | Auxiliary data |
ips.txt | Data | Auxiliary data |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.