1
pmarket
Capture Users IP Address?
  • 2011/6/18 21:04

  • pmarket

  • Just popping in

  • Posts: 62

  • Since: 2008/8/15


How can I add a way to capture a users ip address when the user registers?

I want to add it to profile when a new member registers the module captures his ip address and when the member logs in ip address is captured each time user logs in

Thanks
Palo

2
wishcraft
Re: Capture Users IP Address?

What an excellent suggestion some form of user registration info field in profile module. I think I will make a field that records these settings:

if (!function_exists("xortify_getIPData")) {
    function 
xortify_getIPData($ip=false){
        
$ret = array();
        if (
is_object($GLOBALS['xoopsUser'])) {
            
$ret['uid'] = $GLOBALS['xoopsUser']->getVar('uid');
            
$ret['uname'] = $GLOBALS['xoopsUser']->getVar('uname');
            
$ret['email'] = $GLOBALS['xoopsUser']->getVar('email');
        } else {
            
$ret['uid'] = 0;
            
$ret['uname'] = (isset($_REQUEST['uname'])?$_REQUEST['uname']:'');
            
$ret['email'] = (isset($_REQUEST['email'])?$_REQUEST['email']:'');
        }
        
$ret['agent'] = $_SERVER['HTTP_USER_AGENT'];
        if (!
$ip) {
            if (isset(
$_SERVER["HTTP_X_FORWARDED_FOR"])){ 
                
$ip = (string)$_SERVER["HTTP_X_FORWARDED_FOR"]; 
                
$ret['is_proxied'] = true;
                
$proxy_ip $_SERVER["REMOTE_ADDR"]; 
                
$ret['network-addy'] = @gethostbyaddr($ip); 
                
$ret['long'] = @ip2long($ip);
                if (
is_ipv6($ip)) {
                    
$ret['ip6'] = $ip;
                    
$ret['proxy-ip6'] = $proxy_ip;
                } else {
                    
$ret['ip4'] = $ip;
                    
$ret['proxy-ip4'] = $proxy_ip;
                }
            }else{ 
                
$ret['is_proxied'] = false;
                
$ip = (string)$_SERVER["REMOTE_ADDR"]; 
                
$ret['network-addy'] = @gethostbyaddr($ip); 
                
$ret['long'] = @ip2long($ip);
                if (
is_ipv6($ip)) {
                    
$ret['ip6'] = $ip;
                } else {
                    
$ret['ip4'] = $ip;
                }
            } 
        } else {
            
$ret['is_proxied'] = false;
            
$ret['network-addy'] = @gethostbyaddr($ip); 
            
$ret['long'] = @ip2long($ip);
            if (
is_ipv6($ip)) {
                
$ret['ip6'] = $ip;
            } else {
                
$ret['ip4'] = $ip;
            }
        }
        
$ret['made'] = time();                
        return 
$ret;
    }
}

if (!
function_exists("is_ipv6")) {
    function 
is_ipv6($ip ""
    { 
        if (
$ip == ""
            return 
false;
            
        if (
substr_count($ip,":") > 0){ 
            return 
true
        } else { 
            return 
false
        } 
    } 
}


this is quiet effective code to get those details when thay are needed. And make it so you can only register from one IP only once. So there is no due spammy indian signup sweat shop that depending on how you set spiders up with xortify, allow for he user information not to go into the bots.
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

3
pmarket
Re: Capture Users IP Address?
  • 2011/6/19 15:10

  • pmarket

  • Just popping in

  • Posts: 62

  • Since: 2008/8/15


Bravo Mr. Wishcraft and thank you for your prompt attention to my dilemma.

Where do I insert the code in the profile 1.6 module?

What gave me the idea is; I had a user (member) register in three different cities. At first I created a field in the registration form which requires a member's postal code (zip code) as a way of controlling regional membership. I am creating local Parenting Social Networks across the America which focus on local community. We have built 40+ so far and hope to 100 built by years end.

Collecting the user's IP will allow me to compare it to there Postal Code upon registration and whether to allow their membership.

thanks Palo


4
wishcraft
Re: Capture Users IP Address?

If you need it done in a hurry I charge $40 AUD per hour for GPL titles to be edited as a sponsorship fee.

It is not as simple as inserting the code, you have to make a whole field type for this in profile. I might make it include ipinfodb.com api in it so you get their IP location as well.

You are a commercial enterprise by the sounds of it, you are welcome to hire me, I was just providing the code to get accurate IP information on a user.

Profile 1.68 from my website offers validation already. Contact me on skype if you want to hire or please take a ticket, i have limited hours at the moment.
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

5
pmarket
Re: Capture Users IP Address?
  • 2011/6/19 17:45

  • pmarket

  • Just popping in

  • Posts: 62

  • Since: 2008/8/15


Thanks however I am not a commercial enterprise per se I am creating a place where parents can share information and support one another in a safe local community environment away from all the scammers. A place where parents can connect with other community members.

I do use google ad sense however I only make a few cents a day if anything at all if a user clicks on any of there Ads. Maybe someday this will pay for its self.

How does profile 1.68 validate users?

I see that CBB traps a users IP address

I already heavily modified profile 1.6 for my particular use to ask for; first name, middle initial, last name, occupation and zip code.

thanks for the info I can probably make nominal donation toward the work.

I will play with this once I finish Kansas City And Long Beach.
Before I build Omaha Parents .Com and Tulsa Parents .Com

I like Xoops its easy to use and modify, I have modified virtually all 22 module, tailored them for my particular use including xoops 2.51a. This allow in me to build a complete web site in a couple of hours and get listed on the top page of Google searches.

Again Thanks for the info.




6
wishcraft
Re: Capture Users IP Address?

No worries, I had some time today and did it anyway, I understand your not a commerical enterprise. Anyway try this version out for me and tell me if you have any problems..

There is 3 more fields, IP, ProxyIP and Network Address, which have comparison modes which you can turn on in the preferences for registration.

Thanks.

Download: xoops2.5_profile_1.69.zip
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

7
wishcraft
Re: Capture Users IP Address?

If you want to donate then please do it here: http://www.chronolabs.coop/modules/donations/ it took around 1.5 hours to develop this version of profile for you..

Thanks I would love to know if it fixed the issue for you?
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

Login

Who's Online

381 user(s) are online (275 user(s) are browsing Support Forums)


Members: 0


Guests: 381


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits