Page 1 of 1

How do I include IP address in notification email?

Posted: Sun Feb 18, 2007 7:17 pm
by Jase
Have just upgraded to v1.5 mainly for the IP functionality due to consistent abuse of guestbook by one person. I delete malicious messages once they are posted but I need to try and keep a record of them hence I would like to include the IP address (and post time if possible) in the email notification.

What variable is used to store the IP address and can I reference it in the notification email? I have noticed $IP being used quite a lot but I have tried to include that in the email but it comes out blank - could I just use $REMOTE ADDR or is there a variable I can use already defined?

Also where can I change the date format to allow me to capture the time as well as date?

Many thanks

Jase

Posted: Sun Feb 18, 2007 7:25 pm
by Jase
Have been able to change the date format so its just the IP address in the notification email now please :)

Thanks

Posted: Sun Feb 18, 2007 8:49 pm
by Klemen
PHP Stores IP in the

Code: Select all

$_SERVER['REMOTE_ADDR']
variable.

If used inside quotes (like it the $message variable in GBook) you need to use it without the single quotes:

Code: Select all

$_SERVER[REMOTE_ADDR]


By the way, you can select IP to be banned when deleting a message or viewing IP from GBook.

Posted: Sun Feb 18, 2007 10:20 pm
by Jase
Klemen Stirn wrote:PHP Stores IP in the

Code: Select all

$_SERVER['REMOTE_ADDR']
variable.

If used inside quotes (like it the $message variable in GBook) you need to use it without the single quotes:

Code: Select all

$_SERVER[REMOTE_ADDR]


By the way, you can select IP to be banned when deleting a message or viewing IP from GBook.
Thanks Klemen - I had already used remote_addr but liked the way the GB script resolved the IP to a domaim which is why I wanted to use the variable already set but only because Im lazy!

Thanks for a great script :)

Jase

Posted: Sun Feb 18, 2007 11:18 pm
by Klemen
You can use PHP function gethostbyaddr() to get the resolving host (domain/ISP).
http://www.php.net/gethostbyaddr

Posted: Mon Mar 05, 2007 1:10 am
by Me59
Ok, have done it and here the code for 1.5:

1) find line 739 reading:
$email=str_replace($repl,$char,$email);

2) add on line 740 (insert blank line):
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);


3) on line 747 add (under From:):
Sender: $hostname


thats all! - save the script, upload it and here ya go...