Page 1 of 1

IP address from contacting person

Posted: Wed Nov 16, 2005 12:32 pm
by Kampp
Hi,

How would I go about getting the IP address from the user that’s contacting me through the contact feature on my website?
This way I can block the spammers from seeing the site and thereby spamming!

My guess is to hack the contact component so that it adds the IP to the mail...
Any other suggestion on implementation and/or better way to do this?


Cheers, Kampp

PS. I have a request for this small feature in the Joomla "Wishlists and Feature Requests"!

Re: IP address from contacting person

Posted: Wed Nov 16, 2005 2:30 pm
by mindnsoul
I had this problem before .. what I did was a modrewrite in the htaccess file and blocked the person from accessing my site completely by forwarding them to a homosexual gay websites.

Re: IP address from contacting person

Posted: Wed Nov 16, 2005 2:37 pm
by Kampp
Just my thought - allmost - I want them to see a page that tells them that if they can't act of age they can't talk to people that can!

But how did you get the IP from the contact form?

Re: IP address from contacting person

Posted: Wed Nov 16, 2005 2:40 pm
by mindnsoul
I know the IP address of all users entering my site.. developed my own tracking tool in the codes so that I can sort of hvae my own analytics tools in the backend.

Re: IP address from contacting person

Posted: Mon Mar 27, 2006 11:48 am
by OAS
can ya help a brother out ;) :D
mindnsoul wrote: I know the IP address of all users entering my site.. developed my own tracking tool in the codes so that I can sort of hvae my own analytics tools in the backend.

Re: IP address from contacting person

Posted: Mon Mar 27, 2006 12:37 pm
by dhuelsmann
Kampp wrote: Just my thought - allmost - I want them to see a page that tells them that if they can't act of age they can't talk to people that can!

But how did you get the IP from the contact form?
Take a look at HexIP in the extensions directory. Or add BSQ Stats.

Dave

Re: IP address from contacting person

Posted: Tue Mar 28, 2006 9:21 am
by Kampp
If you have just two visitors there is no way of knowing which one sent the email. The only solid and logical way is to add it as a paramater in contact - if you want to receive the IP in mails or not.

Re: IP address from contacting person

Posted: Fri Mar 31, 2006 11:47 am
by mfyvie
I've just done a simple hack to add both the ip address and a reverse DNS lookup of that address into the email which is generated and sent to the admin (and optionally the person who fills in the contact form).

Here's what the output in the existing email looks like:

This is an enquiry e-mail via http://www.yourjoomlasite.com from: John Doe

After this mod it will look like this:

This is an enquiry e-mail via http://www.yourjoomlasite.com from: John Doe (217.162.172.160 - 217-162-172-160.dclient.hispeed.ch)

Details:

Code: Select all

# Log ip address mod for contact component
#
# This was written and tested for Joomla 1.0.8. It will probably work for 1.0.x, but might not for 1.x and later
#
############################################################## 
## Before Adding This MOD To Your System, You Should Back Up All Files Related To This MOD 
############################################################## 
# 
#-----[ OPEN ]------------------------------------------ 
# 
components/com_contact/contact.php
# 
#-----[ FIND ]------------------------------------------ 
# 
                $text   = $prefix ."\n". $name. ' <'. $email .'>' ."\n\n". stripslashes( $text );
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
                $text   = $prefix ."\n". $name. ' <'. $email .'>('.getenv('REMOTE_ADDR').' - '.gethostbyaddr(getenv('REMOTE_ADDR')).')' ."\n\n". stripslashes( $text );
# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM 

Re: IP address from contacting person

Posted: Fri Mar 31, 2006 1:00 pm
by OAS
thanks mfyvie!

that is perfect

Re: IP address from contacting person

Posted: Mon Sep 17, 2012 11:36 am
by giodoc
Hi Just saw this, where exactly do you add that snippet of code..

Sorry I'm a newbie at this..

Our site has recently been getting some "unfriendly" emails and we would like to track the users IP addresses.. And block them.. I'm on Joomla 1.5, using a zephyr template, so AIcontact safe doesn't seem to be working.. Just want a simple non obtrusive solution..

Thanks

Re: IP address from contacting person

Posted: Wed Mar 05, 2014 5:07 pm
by devkbsc
Hello,

This is solution is very suitable to Joomla 3.X versions. I have just enhanced a bit.

Go to this file

components/com_contact/controllers/contact.php

At the line 159 , you can find this by default

Code: Select all

$body = $prefix."\n".$name.' <'.$email.'>'."\r\n\r\n".stripslashes($body);
You replace this line with this

Code: Select all

$body	= $prefix ."\n". $name. ' <'. $email .'>('.getenv('REMOTE_ADDR').' - '.gethostbyaddr(getenv('REMOTE_ADDR')).')' ."\n\n". stripslashes( $body );

Et voilà