simple counter

cachousam

Avatar: cachousam

2013-02-16 08:14

hello
I installed the plugin simple counter and it works, but the totals are not fine
Visits per day seems correct although they also take into account the robots, but the big total is wrong. He often returned to zero. Have you ever had the same problem.
thank you

» Quick.Cart v3.x

openzibi

Avatar: openzibi

2013-02-16 08:55

Reset?
Try to change
$rFile = fopen( DB_COUNTER, 'w' );
to
$rFile = fopen( DB_COUNTER, 'r+' );

Example: http://democms.rhh.pl/

hosting-domeny-strony - http://www.rhh.pl

cachousam

Avatar: cachousam

2013-02-18 07:38

Hello,
I made ​​the change and the counter "all time" was not reset this morning. Thank you.
But at 7am, I had 334 visits to the journée.I find it much.
However, I have excluded the robots with modification of the code like this:

in config/general.php

put this
$config['counter'] = $config['dir_db'].'counter.php';
$config['disable_agents'] = 'robot|spider|crawler|curl|google'; // robots that are disabled

and in core/common.php put this

function simpleCounter( ){
if( is_file( DB_COUNTER ) && isset( $_SESSION['iCustomer'.LANGUAGE] ) ){
$aFile = file( DB_COUNTER );
if( isset( $aFile[1] ) && !empty( $aFile[1] ) ){
$aExp = explode( '$', $aFile[1] );
$sDate = date( 'Y-m-d' );
$aVisits[0] = $aExp[0];
$aVisits[1] = ( !empty( $aExp[2] ) && $aExp[2] == $sDate ) ? $aExp[1] : 0;
}


if( !preg_match('/'.$GLOBALS['config']['disable_agents'].'|^$/i', $_SERVER['HTTP_USER_AGENT'] ) && !isset( $_SESSION['bSimpleCounter'] ) ){
$sSave = '<?php exit; ?>'."\n";
$rFile = fopen( DB_COUNTER, 'r+' );
if( isset( $aVisits ) ){
$aVisits[0]++;
$aVisits[1]++;
}
else{
$aVisits = Array( 1, 1 );
}

fwrite( $rFile, $sSave.$aVisits[0].'$'.$aVisits[1].'$'.date( 'Y-m-d' ).'$'."\n" );
fclose( $rFile );
$_SESSION['bSimpleCounter'] = true;
}

if( isset( $aVisits ) )
return $aVisits;
else
return Array( 1, 1 );
In fact I'm on 3.7 and the plugin dont have this function.
So I made an adaptation of the plugin for 6.0.

Maybe some robots still pass, or the total of yesterday was not reset.

Thank you again.

Back to top
about us | contact