You are here: Re: code checking « All PHP « IT news, forums, messages
Re: code checking

Posted by Steve on 11/10/06 00:23

"moosus" <junk{@}fishingmonthly.com.au> wrote in message
news:C179F8CC.91EE%junk{@}fishingmonthly.com.au...
| Steve
|
| Thanks for the reply.
|
| I am not against doing it using a DB as I have access to one.
|
| I am assuming that I would have to track users by using a session?
|
| Really what I need to be able to do is track the number of visitors I have
| to specific pages (ie venue.php?vid=10)
|
| If you can give me any pointers I would appreciate it
|
| Cheers
| moosus


you can create a required file and require_once to have it in any page you
want tracked. this would be the code in that file (call it
'site.tracking.php', for the sake of argument here):

<?
function siteTracking($page, $user = '')
{
$ip = '';
if (!$ip = $_SERVER['HTTP_CLIENT_IP'])
{
if (!$ip = $_SERVER['HTTP_X_FORWARDED_FOR'])
{
if (!$ip = $_SERVER['REMOTE_ADDR']){ $ip = 'UNKNOWN'; }
}
}
$sql = "
INSERT INTO siteTracking
(
Page ,
IpAddress ,
UserName ,
Stamp
)
VALUES
(
'" . $page . "' ,
'" . $ip . "' ,
'" . $user . "' ,
'" . date('Y-m-d H:i:s') . "'
)
";
db::execute($sql); // php 5. my abstract db class.
// substitute this with your
// system's requirements.
}
?>

so here's a page that would use the function to track a visit:

<?
require_once 'site.tracking.php';
siteTracking($_SERVER['PHP_SELF'], $userName);
?>

the $userName variable is ficticious but represents the login name of a user
who may be logged in. if you'd like a sample report class to display any
query's results, i'm happy to give you a sample that would do nicely with
the tracking piece above.

hth,

me

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация