Monday, 9 September 2013

strange behavior in my statistics php script

strange behavior in my statistics php script

i ve just created a website, where in the admin panel there is a
statsitics module that is very important, and that recognize if an user
visit the website for the first time (unique) or has already visit the
website (raw).
to recognize if the user is unique or not, the script check if the ip is
the same or if a cookie exist (on the same day).
if( isset( $_COOKIE['c'] ) && !empty( $_COOKIE['c'] ) && ctype_alnum(
$_COOKIE['c'] ) ) {
$cookie = secure_field( $_COOKIE['c'] ); } else { $cookie = NULL; }
mysqli_query( $con, "SELECT id FROM table WHERE ( ip = '$ip' OR id =
'$cookie' )
AND DATE_FORMAT( datetime, '%d.%m.%y' ) = DATE_FORMAT( now(), '%d.%m.%y' )
ORDER BY datetime DESC LIMIT 1" );
if( mysqli_num_rows( $res ) == 0 ) { $unique = 1; } else { $unique = 0; }
with me this script work perfectly (i've try with many browser, deleting
cookie, change IP,..). But now i ve just see a strange behavior with an
user, that use the same IP but all it's visits are registred as UNIQUE!
here the registred records (i've masked the ip for privacy):
2013-09-09 06:06:05 unique 112.201.***.*** Mozilla/5.0 (Windows NT 6.0)
AppleWebKit/537.36 (K...
2013-09-09 06:06:14 unique 112.201.***.*** Mozilla/5.0 (Windows NT 6.0)
AppleWebKit/537.36 (K...
2013-09-09 06:11:58 unique 112.201.***.*** Mozilla/5.0 (Windows NT 6.0)
AppleWebKit/537.36 (K...
2013-09-09 06:14:11 unique 112.201.***.*** Mozilla/5.0 (Windows NT 6.0)
AppleWebKit/537.36 (K...
2013-09-09 06:17:05 unique 112.201.***.*** Mozilla/5.0 (Windows NT 6.0)
AppleWebKit/537.36 (K...
2013-09-09 06:17:15 unique 112.201.***.*** Mozilla/5.0 (Windows NT 6.0)
AppleWebKit/537.36 (K..
How is that possibile? and how i can fix that?

No comments:

Post a Comment