So this is broken down simple stupid line by line item by item, if you just want the code scroll to the bottom.
Well here is a little php fu for you guys.
Ok so the first line is:
$newb = "\n";
$newb is a variable we are declaring. By = "\n" we are telling it what the variable is. \n is special and declares a new line. Sp basically \n is a line break.
The quotes are necessary for \n to work because it is a string. The semicolon is used to end the line.
$ip = $_SERVER['REMOTE_ADDR'];
This is a server variable, of the person who is visiting the site.
$handle = fopen('info.txt', 'a+');
So fwrite says to call the variable with the fopen function and then writes the IP to the text file.
fwrite($handle, $newb);
Calls the same variable with to the text file and enters a line break or the $newb variable.
fclose($handle);
So fclose closes the file.
So here is the sum of the code:
$newb = "\n";
$ip = $_SERVER['REMOTE_ADDR'];
$handle = fopen('info.txt', 'a+');
fwrite($handle, $ip);
fwrite($handle, $newb);
fclose($handle);
And remember to go ahead and create info.txt. Also I was using WAMP so I didn't deal with any chmod stuff it's not working check your permissions, I have put this on a *nix server with 777 perms, but don't do that in a production environment, it's insecure.
Friday, May 23, 2008
Yo, BSDPunk I want to know what IP's are looking at my site.
Subscribe to:
Post Comments (Atom)
1 comment:
what a lame blog. is this aimed at someone with less than 3 months freebsd exp.? i hope others outside nashville do not judge our *nix and computer exploration community upon this.
Post a Comment