Hi
Just create a directory out of the server web root to store the log then just log ip's into that, then every hour run a cron to add them to the database if you want to do that or if you just want to log it into the database create a table and do it that way....
example....
log into the database!
create a table...
Code:
CREATE TABLE visitors (
ip char(15) NOT NULL default '000.000.000.000',
visits smallint(5) unsigned NOT NULL default '0',
last int(10) unsigned NOT NULL default '0',
content int(10) unsigned NOT NULL default '0',
UNIQUE KEY visitors_ip (ip),
KEY visitors_ip (ip)
);
Go to your install directory!
Open global.php
FIND THIS LINE...
Code:
require_once('./includes/functions.php');
RIGHT BELOW IT ADD.
Code:
include_once ( './includes/functions_visitors.php' );
close that file...
Go to ./includes/
Open functions.php
FIND THIS LINE...
Code:
$output = process_replacement_vars($vartext, $sendheader);
RIGHT BELOW IT ADD
Code:
log_write ( strlen ( $output ) );
close functions.php
In that same directory './includes/'
create a file called...
Code:
functions_visitors.php
In that file paste the following code!
Code:
<?php
function get_ip ()
{
$ip = !empty ( $_SERVER['CLIENT_IP'] ) ? $_SERVER['CLIENT_IP'] : '';
$ip = !empty ($_SERVER['HTTP_X_FORWARDED_FOR'] ) && empty ( $ip ) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $ip;
$ip = !empty ( $_SERVER['REMOTE_ADDR'] ) && empty ( $ip ) ? $_SERVER['REMOTE_ADDR'] : $ip;
return $ip;
}
function log_write ( $sent )
{
global $DB_site;
$user = addslashes ( get_ip () );
$sent = intval ( $sent );
$time = time ();
$DB_site->query ( "INSERT INTO " . TABLE_PREFIX . "visitors VALUES ( '" . $user . "', 1, " . $time . ", " . $sent . " ) ON DUPLICATE KEY UPDATE last = " . $time . ", visits = visits + 1, content = content + " . $sent );
}
?>
That it...
It will log UNIQUE VISITORS, total pages viewed, total bandwidth used and their last visit time!
Note if your using a table PREFIX be sure to add the PREFIX to the CREATE table and the
keys before creating the table! If you want to know how to add a simple viewer in the Admin Panel to view the log, just ask and I will show you how simple it is! It will have to be tomorrow evening as I have no time now, busy reading at the moment!!!
Sonia