vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Auto-Detect User Location At Registration (https://vborg.vbsupport.ru/showthread.php?t=53923)

Raz 06-05-2003 10:00 PM

Auto-Detect User Location At Registration
 
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.

cirisme 06-06-2003 01:26 PM

Cool! 8-)

Moving servers right now, but I will install this when I am done. :)

Tim Wheatley 06-06-2003 02:11 PM

Doesn't work here... Nothing changes at all...

msimplay 06-06-2003 02:13 PM

didn't work for me on vbulletin 2.3

partang2 06-06-2003 04:25 PM

Maybe that is because phpMyAdmin doesn't support files as large as this...?

Tim Wheatley 06-06-2003 05:34 PM

It does, the queries worked eventually. Took a while though. The problem is it's just not working, don't know the reason why though...

-Sidekick- 06-06-2003 05:53 PM

That sucks. I'll have to keep checking back then. Cause I hate when people leave there Location empty and then it shows up blank in the postbit.

Raz 06-06-2003 07:07 PM

Apologies. There are many modifications on my boards, which is why it isn't working on others.

I've installed a vanilla version, and modified the instructions to reflect normal installations. So please try those now :)

Also make sure that your mysql max_packet variable is large enough to handle a 2MB file. I would personally recommend importing the table via ssh.

Boofo 06-06-2003 07:16 PM

Great idea but you really need to make the query into a few smaller ones for those of us that don't have SSH. ;)

Raz 06-06-2003 07:30 PM

Have you tried importing it from phpMyAdmin? It may be large, but its not impossible.


All times are GMT. The time now is 12:34 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01290 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete