Jump to content

please help, im a little stuck (and new to php)


marsdenc

Recommended Posts

i have the below code but i cant figure out how it works to track an ip when there are many ip's on the same network using it as it only gives the main ip and does not relate to individual users.

 

can any one help?

 

<?php

 

extract($_POST, EXTR_PREFIX_SAME, "post_");

 

putenv("TZ=london");

 

$filename = 'statistics.txt';

 

$somecontent = date('[d/m/Y:H:i:s T O]')." ".$_SERVER['REMOTE_ADDR'].": ".$title.": ".$state."\n";

 

if (is_writable($filename)) {

 

if (!$handle = fopen($filename, 'a')) {

echo "Cannot open file ($filename)";

exit;

}

 

 

if (fwrite($handle, $somecontent) === FALSE) {

echo "Cannot write to file ($filename)";

exit;

}

 

echo "Success, wrote ($somecontent) to IP log ($filename)";

 

fclose($handle);

 

} else {

echo "The file $filename is not writable";

}

 

?>

Link to comment
Share on other sites

A page is requested by a single user (from a single ip) and therefore each call is just a single instance. Hope this make things a little clearer? Unless their logged in or you can correlate from a lookup ip table then no you don't know who the user is, other than being identified by an ip (or other $_SERVER info), all of which can be falsified! Fun isn't it!

Link to comment
Share on other sites

How do you mean track?

Have a look at sessions, e.g. set a session cookie...

 

This will be done a a per browser basis, for instance at times i'll use different browsers from same pc to test multi users from same ip. If you log the ip, browser details and session id then you'll start to have a bigger picture of what's going on!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.