PDA

View Full Version : Can I record IP addresses when people use my guestbook?


master1425
05-16-2008, 04:35 PM
Hey, Im using a guestbook from Joetutorial for a website.

The website, is a support site for a girl who was recently in an ATV accident.
And im using the guestbook as a way that her friends can post her get-well messages.

Well, naturally, there are always people out there who want to be mean and stupid.
So, a few are posting really mean messages like, "dont be retarded", and even much worse.

Im removing them as they are posted, but the family is still seeing things like that and its upsetting them alot.

So, im hoping I can record their IP address. And I know their using the local connection here, and I know that they will look it up for if I can provide the address to them.

So, does anyone have any suggestions?

www.prayforjada.com/jadabook.php is the guestbook.

ScareCrowe
05-16-2008, 05:33 PM
It is possible. Create a text file and name it addresses.txt
upload it to the web root folder and make it writeable. ( change or chmod it's permissions to 0777 )
Add this code to the section in your PHP page that handles the form POST data:


$fh = fopen( 'addresses.txt', 'a+' );
fwrite( $fh, $_POST[ 'name' ] . "|" . $_SERVER[ 'REMOTE_ADDR' ] . "\n" );
fclose( $fh );



This will write the name and IP address to the file of everyone who submits the form.

This will do what you ask, however, I am not convinced it will solve your issue. It is just too easy to fake that info and doesn't deal with proxy.

When/if it gets those peeps, remember to remove or comment that code, you don't want to wind up with a 30 megabyte textfile. ;)

Vege
05-16-2008, 06:03 PM
ban them from the page with their ip that you have logged and give them "we have taken page down because spam" thus making them not coming back again as they think the page has been taken down. If there are only few the problem will be death with.
Ofcos they can use proxys, but usually people dont bother if they think there is no page anymore.

master1425
05-16-2008, 10:15 PM
Thanks for the info guys, I appreciate it.

Hey, I bet you guys wouldnt help me with another issue would you?

The guestbook currently has nearly 200 posts on it.

Currently, the guestbook is displaying all 200 on the same page.

Can you help me brainstorm a way to make it only output say 25 or 30? and put the rest on seperate pages?

ScareCrowe
05-17-2008, 09:32 AM
All you need to do that is a pagination script. Adding this feature will probably require that you tweak some of your code, specifically the SQL query to set a start and limit parameter.

I personally recommend THIS (http://www.phpclasses.org/browse/package/2372.html) one. There are some how-to instructions at the top of the class file.