IP address from contacting person

General questions relating to Joomla! There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
User avatar
Kampp
Joomla! Guru
Joomla! Guru
Posts: 563
Joined: Tue Aug 30, 2005 9:18 am
Location: Denmark
Contact:

IP address from contacting person

Post by Kampp » Wed Nov 16, 2005 12:32 pm

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"!
http://www.toolmaster.dk - Danish Joomla Services!

mindnsoul
Joomla! Intern
Joomla! Intern
Posts: 81
Joined: Thu Sep 22, 2005 8:29 pm

Re: IP address from contacting person

Post by mindnsoul » Wed Nov 16, 2005 2:30 pm

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.

User avatar
Kampp
Joomla! Guru
Joomla! Guru
Posts: 563
Joined: Tue Aug 30, 2005 9:18 am
Location: Denmark
Contact:

Re: IP address from contacting person

Post by Kampp » Wed Nov 16, 2005 2:37 pm

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?
http://www.toolmaster.dk - Danish Joomla Services!

mindnsoul
Joomla! Intern
Joomla! Intern
Posts: 81
Joined: Thu Sep 22, 2005 8:29 pm

Re: IP address from contacting person

Post by mindnsoul » Wed Nov 16, 2005 2:40 pm

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.

OAS
Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Tue Jan 10, 2006 3:36 pm
Location: Australia

Re: IP address from contacting person

Post by OAS » Mon Mar 27, 2006 11:48 am

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.

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19657
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: IP address from contacting person

Post by dhuelsmann » Mon Mar 27, 2006 12:37 pm

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
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

User avatar
Kampp
Joomla! Guru
Joomla! Guru
Posts: 563
Joined: Tue Aug 30, 2005 9:18 am
Location: Denmark
Contact:

Re: IP address from contacting person

Post by Kampp » Tue Mar 28, 2006 9:21 am

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.
http://www.toolmaster.dk - Danish Joomla Services!

mfyvie
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Tue Jan 31, 2006 12:59 pm

Re: IP address from contacting person

Post by mfyvie » Fri Mar 31, 2006 11:47 am

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 

OAS
Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Tue Jan 10, 2006 3:36 pm
Location: Australia

Re: IP address from contacting person

Post by OAS » Fri Mar 31, 2006 1:00 pm

thanks mfyvie!

that is perfect

giodoc
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Mon Jul 12, 2010 7:44 am

Re: IP address from contacting person

Post by giodoc » Mon Sep 17, 2012 11:36 am

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

devkbsc
Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Sat Jul 03, 2010 2:03 pm

Re: IP address from contacting person

Post by devkbsc » Wed Mar 05, 2014 5:07 pm

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à


Locked

Return to “General Questions - 1.0.x”