Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Auto-Detect User Location At Registration Details »»
Auto-Detect User Location At Registration
Version: 1.00, by Raz Raz is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 06-05-2003 Last Update: Never Installs: 9
 
No support by the author.

Simple hack making use of the Directi Ip-to-Country Database (included).

What it does
Auto-detects which country user is from and auto-fills the location field on the registration form using their IP Address.

Installing
Import the 'ip2country' table attached into your forums database. Either use phpMyAdmin or from ssh.
(Make sure your mysql max_packet size is large enough to handle the ~2 Mb file -- otherwise try downloading this split table here)

Open up register.php and look for:
PHP Code:
        while ($profilefield=$DB_site->fetch_array($profilefields)) {
                
$profilefieldname "field$profilefield[profilefieldid]"
Above that place the following:
PHP Code:
// CUSTOM ADD AUTO LOCATION
$ip_number sprintf("%u",ip2long($REMOTE_ADDR));
$ct_array $DB_site->query_first("SELECT COUNTRY_NAME FROM ip2country WHERE $ip_number >= IP_FROM AND $ip_number <= IP_TO LIMIT 1");
$bbuserinfo['field2'] = ucwords(strtolower($ct_array['COUNTRY_NAME']));
// END CUSTOM ADD AUTO LOCATION 
Once you've done that, you're all set.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 06-06-2003, 07:36 PM
Mike11212 Mike11212 is offline
 
Join Date: Jul 2002
Posts: 134
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

dont you have to pay for ip2country database?
Reply With Quote
  #13  
Old 06-06-2003, 07:50 PM
Raz's Avatar
Raz Raz is offline
 
Join Date: Oct 2001
Posts: 84
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

From the site (link posted in first post):
Quote:
The IP-to-Country Database and Tools are available FREE of charge.
Reply With Quote
  #14  
Old 06-06-2003, 07:50 PM
Broekie's Avatar
Broekie Broekie is offline
 
Join Date: Dec 2001
Location: Netherlands
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 10:36 PM Mike11212 said this in Post #11
dont you have to pay for ip2country database?
Yes, you do. You should remit $100 to my swiss bank-account


Okay, I'm kidding...
Here's the serious part of this post:
Quote:
The fourth line of text on http://www.ip-to-country.com:
The IP-to-Country Database and Tools are available FREE of charge.
Reply With Quote
  #15  
Old 06-06-2003, 08:09 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 03:30 PM Raz said this in Post #10
Have you tried importing it from phpMyAdmin? It may be large, but its not impossible.
I tried to do a 2 meg file when I had the Weather hack installed and the author had to make smaller files so others could import them as well.
Reply With Quote
  #16  
Old 06-06-2003, 08:09 PM
Tim Wheatley's Avatar
Tim Wheatley Tim Wheatley is offline
 
Join Date: Nov 2001
Location: England
Posts: 489
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes it works now.

I got it to work when someone updates their profile too:

In member.php above
PHP Code:
  while ($profilefield=$DB_site->fetch_array($profilefields)) {
    
$profilefieldname="field$profilefield[profilefieldid]"
Add the same as in first post.

Works great, thank you. I'm using 2.3.0.
Reply With Quote
  #17  
Old 06-06-2003, 08:11 PM
Raz's Avatar
Raz Raz is offline
 
Join Date: Oct 2001
Posts: 84
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 10:09 PM Boofo said this in Post #14
I tried to do a 2 meg file when I had the Weather hack installed and the author had to make smaller files so others could import them as well.
Feel free to do it yourself.
Reply With Quote
  #18  
Old 06-07-2003, 08:28 AM
AlexanderT's Avatar
AlexanderT AlexanderT is offline
 
Join Date: Mar 2003
Posts: 294
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Really nice! *installed*

I attached a split version of the ip2country table. Make sure you first insert part1 before inserting the other parts (in order to create the table).

Alex
Reply With Quote
  #19  
Old 06-07-2003, 10:17 AM
partang2 partang2 is offline
 
Join Date: Jun 2002
Location: Norway
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks a lot AlexanderT!!
Reply With Quote
  #20  
Old 06-07-2003, 10:37 AM
Raz's Avatar
Raz Raz is offline
 
Join Date: Oct 2001
Posts: 84
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've added a link to the split table in the first post.
Reply With Quote
  #21  
Old 06-07-2003, 11:46 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can someone tell me how many rows there are and what size the table should be? I want to make sure I got it in there right.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:51 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05068 seconds
  • Memory Usage 2,318KB
  • Queries Executed 27 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete