Right now I dont have the script here but some basic things I remember
//IP check:
$visitor_ip = getenv ("REMOTE_ADDR");
(of course server must support this environment variable. Usaully they do.)
Clicking check: use simple redirector.
if you had
<a href="file1.html">file1</a>
now it will be
<a href="redirect.php?where=file1.html">file1</a>
I dont remember if I encoded dot "." or left it as it is.
Now the redirect.php
<?PHP
###########
#here your code to track the click:
$visitor_ip = getenv ("REMOTE_ADDR");
the link clicked is stored in $where
variable if register_globals is on
or in $_GET["where"] if
//now u do with $where and $visitor_ip
//whatever you want.
//I inserted 'em to the DB
###########
redirect user to location
header ("Location: $where");
// or
//header ("Location: ".$_GET["where"]);
?>
Of course this is not ready to use script, but I hope this will help you.