For All You Smart Coders ->> Tracking clicks on AIM profiles - Deciphering the Code

udonoogen

Diamond Member
Dec 28, 2001
3,243
0
76
hi there ... got this script off of the net. it's PHP. okay, the deal is that you add the php link to anything in your AOL Instant messenger profile, right? well ... it works fine only that it records a person's visit and whenever they visit again, it ignores it and doesnt record it. i've done some LISP but i can't follow this at all. how can i get it so it logs every visit? what line of code do i remove?

this is quite similar to the service provided by www.imchaos.com except it doesn't have those stupid ads. does anyone know any way of tracking ip's in addition to screen names? i'm just curious of where the hits on my website our coming from. thanks!

(i added a javascript redirect in the code to automatically redirect the person to my website after they reached the log.html page as well ... if this is inefficient, is there a better way?)

thanks!


edit: clarification


- - - - - - - - - - - - - - - - - - - - - - - - - - - -

<?

$ururl = "http://[insert website here]";

$dir = ".";
if (is_dir($dir)) {
if (isset($sn)) {
if (!stristr($sn,"%n")) {
$sn = $_GET["sn"];
$rfile = fopen("$dir/log.html","r+");
$people = fread($rfile, filesize("$dir/log.html"));
fclose($rfile);
$sn = str_replace("+"," ",$sn);
$sn = str_replace("%20"," ",$sn);
$the_query = $QUERY_STRING . " " . $SERVER_PROTOCOL;
$sn = ereg_replace(".*sn=", "", $the_query);
$sn = ereg_replace("&.*", "", $sn);
$sn = ereg_replace("HTTP/*.*","",$sn);
$people = ereg_replace(" ", "", $people);
$sntemp = ereg_replace(" " , "", $sn);
if (!stristr($people,$sntemp)) {
$rfile = fopen("$dir/log.html","a");
fputs($rfile,"$sn
");
fclose($rfile);
}
echo "
";
}
}

echo "<HTML><BODY>";

echo "<FONT FACE='verdana' SIZE=2>";
if (isset($sn)) {
include("$dir/log.html");
}
}
?>
</FONT></BODY></HTML>
</FONT></BODY></HTML>
 

RSMemphis

Golden Member
Oct 6, 2001
1,521
0
0
$sn = $_GET["sn"]; // The AOL screen name is passed onto the script with the "GET" method of HTTP. This line retrieves it, stores it.
$rfile = fopen("$dir/log.html","r+"); // open your logfile
$people = fread($rfile, filesize("$dir/log.html")); // read the logfile into a variable called people
fclose($rfile); // close the log file
$sn = str_replace("+"," ",$sn); // the screen name is sent "quoted printable", this and the next line just change + or %20 into space
$sn = str_replace("%20"," ",$sn); // essentially, this line and the last one are superfluous, since it will be overwritten with the query string below.
$the_query = $QUERY_STRING . " " . $SERVER_PROTOCOL; // this is a bit more complicated... it puts the querystring (anything after ?) and the protocol in one variable.
$sn = ereg_replace(".*sn=", "", $the_query); // replace the string .*sn= with a blank in the query
$sn = ereg_replace("&.*", "", $sn);
$sn = ereg_replace("HTTP/*.*","",$sn);
$people = ereg_replace(" ", "", $people); // take all spaces out
$sntemp = ereg_replace(" " , "", $sn); // again
if (!stristr($people,$sntemp)) { // if we can find it, then we are all done
$rfile = fopen("$dir/log.html","a"); // otherwise, we add the screen name in the next three lines
fputs($rfile,"$sn");
fclose($rfile);


The script seems complicated, because apparently it did not work out the way the user wanted it to be. Two lines are completely superfluous.
Basically, the query string contains the screen name of the person trying to find out something about your profile, and the protocol probably depends on the Instant Messaging system, so maybe you can use this script for more than one profile. That way, if someone uses MSN, and someone uses AIM, anmd you have the same profile, and they have the same screen name in both, it records both once. I think that's why the person changed away from the "get" towards the query string.

Was that of any help?