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-09-2003 08:39 AM

I don't know of a freely available database that does this.

For larger ISPs it would probably be wrong, as it would just show the HQ of the ISP (who the IPs are registered to).

Pikok 07-14-2003 05:26 AM

I made a small change to the code Tim Wheatley posted for the "member.php" file as follows..

Add:
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");
if (!
$bbuserinfo['field2']) {
  
$bbuserinfo['field2'] = ucwords(strtolower($ct_array['COUNTRY_NAME']));
}
// END CUSTOM ADD AUTO LOCATION 

Above:
PHP Code:

  while ($profilefield=$DB_site->fetch_array($profilefields)) {
    
$profilefieldname="field$profilefield[profilefieldid]"

With the code Tim had posted, the location would be automatically changed to just the country whenever a user modified their profile. With the change I made though, the location will only be automatically changed if the location field is empty (i.e. the user hasn't filled in a location manually).

In other words, if the user already has something in the location field it won't be changed. If the location field is empty, it will be automatically filled in with the country name.

Pikok 07-14-2003 11:44 PM

I also made the following change so no user can leave the location field empty in their profile..

In "root/member.php" find:
PHP Code:

  // check extra profile fields
  
$userfields="";
  
$profilefields=$DB_site->query("SELECT profilefieldid,required,title,size,maxlength
                                  FROM profilefield
                                  WHERE editable = 1"
); 

And Add Below It:
PHP Code:

// CUSTOM ADD AUTO LOCATION 
if (!$field2) {
  
$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");
  
$field2 ucwords(strtolower($ct_array['COUNTRY_NAME']));
}
// END CUSTOM ADD AUTO LOCATION 

In "root/register.php" find:
PHP Code:

  // check extra profile fields
  
$userfields="";
  
$userfieldsnames="(userid";
  
$profilefields=$DB_site->query("SELECT maxlength,profilefieldid,required,title
                                  FROM profilefield
                                  WHERE editable = 1
                                  ORDER BY displayorder"
); 

And Add Below It:
PHP Code:

// CUSTOM ADD AUTO LOCATION 
if (!$field2) {
  
$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");
  
$field2 ucwords(strtolower($ct_array['COUNTRY_NAME']));
}
// END CUSTOM ADD AUTO LOCATION 

With these additions, if a user leaves the location field empty (either when registering or updating their profile), the country will be automatically inserted into the database. Resulting in no empty locations. ;)

tinbin 07-17-2003 12:33 PM

How could i combine this hack with the Flagshack?
So that it looks up what country the IP is in and then update the countryflag next to the username.

Would this be hard to do?

PurpleCow 08-10-2003 05:38 AM

Pikok - The changes you mentioned, will they be the same for ver 2.3.0 also ??

I am really interested in this hack, let me know how your changes and this hack works on 2.3.0 ??

Thank you very much

Cheers

msibm 02-09-2007 06:21 AM

Are there new version for 3.6.4?
Thanks.

steven s 02-10-2007 12:21 AM

I was searching for something else entirely and came across this.

Quote:

Originally Posted by tinbin (Post 418450)
How could i combine this hack with the Flagshack?
So that it looks up what country the IP is in and then update the countryflag next to the username.

Quote:

Originally Posted by msibm (Post 1178134)
Are there new version for 3.6.4?
Thanks.

I was thinking about the same thing about both posts.


All times are GMT. The time now is 12:56 PM.

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.01235 seconds
  • Memory Usage 1,755KB
  • 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
  • (6)bbcode_php_printable
  • (2)bbcode_quote_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
  • (7)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