FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Stat Trackers





polly-gone
How do website stat trackers that collect data like visitor's IP, referrer, etc. work without putting a snippet of code on each page?

Thanks,

-Nick Smile Smile Smile
imagefree
polly-gone wrote:
How do website stat trackers that collect data like visitor's IP, referrer, etc. work without putting a snippet of code on each page?

Thanks,

-Nick Smile Smile Smile


If you are using third party service for collecting Visitor's info, you need code snipped (that may open an image or a js file). If you are using your own service you dont need to use an image and js for this (coz the page that is loaded is sufficient to collect the said info).

More explanations or bad english?
polly-gone
How does one central script collect all of the page views without having a script on each page?
rickylau
Without having CLIENT SCRIPTING (javascript):
In PHP, you can use different system-defined variables (like $_SERVER ['REMOTE_ADDR'] for client IP address, $_SERVER ['HTTP_REFERER'] for referer). And you can store these informations inside database / text file / send these to your email if you want using PHP.

Without having ANY SCRIPT (including PHP):
Server software (assuming you are using Apache, or hosting in Frihost) will store these information for you, because the server knows these Wink .


And for "central script"... What I can think is only a standalone PHP script doing this job. As you can include the script in every PHP file, you need only one PHP script to do so. Is that what you mean?
oly0015
http://www.theblog.ca/php-ip

I was planning on doing something a little similar so I think I might be able to help on this one. At least for how mine is ran I put a php include on each page that links to an external php file then the next line calls visit(). So that means now every page calls visit which can store whatever you would like to get in terms of information.

On mine I stored hits based on an ipaddress not seen there for the last 20min so its just counts hits once per person. If you use the link above I'm pretty sure you can get whatever information you need to get for your project.
imagefree
Code:
function _stats()
{
   GLOBAL $_data;//, $user;
   $ip            = _escape(filter_var($_SERVER["REMOTE_ADDR"], FILTER_VALIDATE_IP));
   $iip         = ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? _escape($_SERVER["HTTP_X_FORWARDED_FOR"]) : '' );
   $time         = $_SERVER['REQUEST_TIME'];
   $agent         = ( isset($_SERVER["HTTP_USER_AGENT"]) ? _escape($_SERVER["HTTP_USER_AGENT"]) : '' );
   $referer      = ( isset($_SERVER["HTTP_REFERER"]) ? _escape($_SERVER["HTTP_REFERER"]) : '' );
   $uri         = _escape($_SERVER['REQUEST_URI']);
   $query_string   = _escape($_SERVER['QUERY_STRING']);
   $script_name   = _escape($_SERVER['SCRIPT_NAME']);
   $login         = ( $_data['login'] ? $_data['id'] : 0 );
   $query         = "INSERT INTO table_stats ( st_id , st_uri , st_querystring , st_scriptname , st_ip , st_iip , st_agent , st_ref , st_mid , st_date )
                  VALUES    ( NOT NULL , '$uri' , '$query_string' , '$script_name' , '$ip' , '$iip' , '$agent' , '$referer' , '$login' , '$time' )";
   _sql($query);
   return @_database('insert_id');
}


_stats();


this is what i do on each request. My system is centralized so that each request is server by just one centralized page. Even if you dont have centralized script, so can save this code in any file, modify it according to your needs and then include that file into any script (or all scripts) you want.

REMEMBER: _escape() is not a default php function. i defined this function somewhere else just to escape everything at one place. You can replace it with mysql_real_escape_string()
Peterssidan
On frihost they have something called Webalizer that you can use. It's all server side. Good thing is that you don't need to include anything extra in your php script either.
rvec
you could take a look at google analytics, it stores everything you would want and more (seriously, it stores more than you'd want).
Related topics
Favourite game? (OFFICIAL THREAD)
Do you sell ICQ numbers??
Fantastico could be updated
gmail drive
Statistics
suggestion
Laserjet 3p and cups problems
KNIGHT ONLINE !
Statistics
Web/Ftp Statistics have errors
[var][tecg]Dos más de piratas...!!...Y MÁS!!
Where is the WEB/STAT
Problem with Stat
Stat counter on PHPBB
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.