Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abbe98/request-logging
Request logging library for PHP.
https://github.com/abbe98/request-logging
Last synced: 7 days ago
JSON representation
Request logging library for PHP.
- Host: GitHub
- URL: https://github.com/abbe98/request-logging
- Owner: Abbe98
- Created: 2014-09-11T12:11:56.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-04T11:50:35.000Z (about 10 years ago)
- Last Synced: 2024-10-10T18:54:06.249Z (28 days ago)
- Language: PHP
- Size: 145 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#request-logging
*Request logging library in PHP*
##Installation
Include `rqeuest_logging.php` or add the [composer package][0].
Define the database configuration:
define('HOST', '127.0.0.1'); // the IP of the database
define('DBNAME', 'reqlog_test'); // the database name to be used
define('USERNAME', 'root'); // the username to be used with the database
define('PASSWORD', ''); // the password to be used with the usernameAnd run the following SQL in the database you defined above:
CREATE TABLE IF NOT EXISTS `requests` (
`id` int(255) NOT NULL,
`ip` varchar(45) COLLATE utf8mb4_bin NOT NULL,
`http_forwared` int(45) NOT NULL,
`browser_ua` varchar(600) COLLATE utf8mb4_bin NOT NULL,
`timestamp` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
`tag` varchar(700) COLLATE utf8mb4_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=27 ;
ALTER TABLE `requests`
ADD PRIMARY KEY (`id`);
ALTER TABLE `requests`
MODIFY `id` int(255) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=27;##Usage
Log the current request(IP, HTTP forwarded, Browser User Agent and Time Samp). The `$tagString` is optional:
`$log = new ReqLog($tagString);`
Get the number of visits from the current computer/browser(by adding `$tagString` you get the tag specific data):
`$log->num_visits();`
Get the number of visits from the current computer(`$tagString` is optional):
`$log->num_ip_visits();`
Get the percent that the current browser version has(`$tagString` is not supported):
`$log->this_browser_percent();`
**Licensed under MIT.**
[0]: https://packagist.org/packages/abbe98/request-logging