jussst wait im working on that, i'll try to post the codes to make it work on lavalair's script. and also codes to ban the whole country!!
Country Detecter Script Help
Collapse
X
-
Guest
-
Here is another ip to country without database script:
http://www.phptutorial.info/iptocountry/the_script.html
and here is a function how to use it:
for iso county code
Code:function iptocountry($ip) { $numbers = preg_split( "/\./", $ip); include("ip_files/".$numbers[0].".php"); $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); foreach($ranges as $key => $value){ if($key<=$code){ if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;} } } if ($two_letter_country_code==""){$two_letter_country_code="unkown";} return $two_letter_country_code; }
Code:function country_name($two_letter_country_code) { include("ip_files/countries.php"); $country_name=$countries[$two_letter_country_code][0]; return $country_name; }
Code:$two_letter_country_code=iptocountry($_SERVER['REMOTE_ADDR']); echo 'County flag: '.country_name($two_letter_country_code);
to show the country flag:
Code:function show_flag($two_letter_country_code) { $file_to_check='./ip_flags/'.strtolower($two_letter_country_code).'.gif'; if (file_exists($file_to_check)){ $FLAG= '[img]'.$file_to_check.'[/img]'; }else{ $FLAG= '[img]./ip_flags/noflag.gif[/img]'; } return $FLAG; }
Code:$two_letter_country_code=iptocountry($_SERVER['REMOTE_ADDR']); echo 'County flag: '.show_flag($two_letter_country_code);
Code:$two_letter_country_code=iptocountry($_SERVER['REMOTE_ADDR']); ///ZA- South africa; DE -Germany/////// if($two_letter_country_code=='ZA' || $two_letter_country_code=='DE'){ echo '<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card> We do not provide any services for your country. </p> </card> </wml>'; exit; }
Comment
-
Here is another ip to country without database script:
http://www.phptutorial.info/iptocountry/the_script.html
and here is a function how to use it:
for iso county code
Code:function iptocountry($ip) { $numbers = preg_split( "/\./", $ip); include("ip_files/".$numbers[0].".php"); $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); foreach($ranges as $key => $value){ if($key<=$code){ if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;} } } if ($two_letter_country_code==""){$two_letter_country_code="unkown";} return $two_letter_country_code; }
for country name:
Code:function country_name($two_letter_country_code) { include("ip_files/countries.php"); $country_name=$countries[$two_letter_country_code][0]; return $country_name; }
Code:$two_letter_country_code=iptocountry($_SERVER['REMOTE_ADDR']); echo 'County flag: '.country_name($two_letter_country_code);
Code:function show_flag($two_letter_country_code) { $file_to_check='./ip_flags/'.strtolower($two_letter_country_code).'.gif'; if (file_exists($file_to_check)){ $FLAG= '[img]'.$file_to_check.'[/img]'; }else{ $FLAG= '[img]./ip_flags/noflag.gif[/img]'; } return $FLAG; }
Code:$two_letter_country_code=iptocountry($_SERVER['REMOTE_ADDR']); echo 'County flag: '.show_flag($two_letter_country_code);
Code:$two_letter_country_code=iptocountry($_SERVER['REMOTE_ADDR']); ///ZA- South africa; DE -Germany/////// if($two_letter_country_code=='ZA' || $two_letter_country_code=='DE'){ echo '<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card> We do not provide any services for your country. </p> </card> </wml>'; exit; }
many thanks to Gum,
1 more question,how can i reserve one user's $two_letter_country_code data in that user's profile to show that user's $two_letter_country_code to all user,i mean wt will b mysql table to save n show $two_letter_country_code to all users?
Comment
-
many thanks to Gum,
1 more question,how can i reserve one user's $two_letter_country_code data in that user's profile to show that user's $two_letter_country_code to all user,i mean wt will b mysql table to save n show $two_letter_country_code to all users?[/b]
so here is very simple example:
you have to add the country row to your users table
Code:UPDATE `users` SET `country`='".$two_letter_country_code."' WHERE id='".$user_id."'
Code:SELECT * FROM `users` WHERE `country`='ZA' LIMIT 0, 10
Comment
-
Guest
I use database to detect country in main page... and in my portal i made a script which doesnt uses databse... My script also detect users network
Comment
-
Guest
many thanks to Gum,
1 more question,how can i reserve one user's $two_letter_country_code data in that user's profile to show that user's $two_letter_country_code to all user,i mean wt will b mysql table to save n show $two_letter_country_code to all users?[/b]
Well yea there is a simple way of doing this in a user friendly way... That is not displaying country code to other users as 2 letter code, instead show it as full name of country...
As Gumslone suggested, this can be made easy if ur ip2country database has a separate column which displays country's name as a a whole... If so its a matter of getting value from approapriate column and inserting that data into users profile in ur database...
Comment
-
Guest
ooh man check this http://ip2location.com, it shows my country, state and the city. and my connection through... i want the codes to show the state and city. does anyone have it?
Comment
-
ooh man check this http://ip2location.com, it shows my country, state and the city. and my connection through... i want the codes to show the state and city. does anyone have it?[/b]
Comment
-
Hmmm, i dont realy understand what do you mean, and i dont know which mysql tables are you using
so here is very simple example:
you have to add the country row to your users table
Code:UPDATE `users` SET `country`='".$two_letter_country_code."' WHERE id='".$user_id."'
Code:SELECT * FROM `users` WHERE `country`='ZA' LIMIT 0, 10
here is user sql table
--
-- Table structure for table `ibwf_users`
--
CREATE TABLE `ibwf_users` (
`id` int(100) NOT NULL auto_increment,
`name` varchar(30) NOT NULL default '',
`pass` varchar(60) NOT NULL default '',
`birthday` varchar(50) NOT NULL default '',
`sex` char(1) NOT NULL default '',
`location` varchar(100) NOT NULL default '',
`perm` char(1) NOT NULL default '0',
`posts` int(100) NOT NULL default '0',
`plusses` int(100) NOT NULL default '0',
`signature` varchar(100) NOT NULL default '',
`avatar` varchar(100) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`site` varchar(50) NOT NULL default '',
`browserm` varchar(50) NOT NULL default '',
`ipadd` varchar(30) NOT NULL default '',
`lastact` int(100) NOT NULL default '0',
`regdate` int(100) NOT NULL default '0',
`chmsgs` int(100) NOT NULL default '0',
`chmood` int(100) NOT NULL default '0',
`shield` char(1) NOT NULL default '0',
`gplus` int(100) NOT NULL default '0',
`budmsg` varchar(100) NOT NULL default '',
`lastpnreas` varchar(100) NOT NULL default '',
`lastplreas` varchar(100) NOT NULL default '',
`shouts` int(100) NOT NULL default '0',
`pollid` int(100) NOT NULL default '0',
`rbcid` varchar(255) NOT NULL default '',
`hvia` char(1) NOT NULL default '1',
`lastvst` int(100) NOT NULL default '0',
`battlep` int(100) NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `id` (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
--
-- Dumping data for table `ibwf_users`
--
and
[attachment=1261:index.php]
[attachment=1260:core.php]
i want to show in users profile like this
More Information
Send PM
add to buddy list
Member's ID:
Status: Vinyl Shaker
A/S/L: 18/Male/
IP country:South Africa Flag image
Topics: 9
Posts: 127/152
PMs IN: 26 - OUT: 52
Game Plusses: 93
Chat Posts: 22
Fun Points: 0
Shouts: 28/42
Joined rw: 02 07 07-17:23:51
Last Active: 07 10 07-18:20:37
Last Visit: 07 10 07-12:13:11
Browser: Opera
E-mail:
Signature:Attached Files
Comment
-
Guest
most of the country dedeceter scripts, doesnt detect my country from ip at all. it says unknown country. Where as this one showed exact location of me... and yeah its payable service
Comment
-
Guest
most of the country dedeceter scripts, doesnt detect my country from ip at all. it says unknown country. Where as this one showed exact location of me... and yeah its payable service [/b]
Bro pls check country detector in my site and let me know if it doesnt detect ur country...
Comment
-
Guest
it would not work with mobile phone users only with pc users also you have to pay for this service and its also does not show correct information as for me.[/b]
Agree with u Gums... U have to pay for the service and what it detects is the nearest exchange of your internet service provider. Which doesn't always be your hometown.. Similar scripts are used in many porn sites etc just to lure users ... But funny side of it is when it shows a city about 50-100 kms from your city... This happens coz most of the ip2loaction services only use ip to detect the location, and user ip may be interfered by many intermediates..
Comment
-
Guest
Bro pls check country detector in my site and let me know if it doesnt detect ur country...[/b]
Comment
-
well im using lavalair wml script
here is user sql table
--
-- Table structure for table `ibwf_users`
--
CREATE TABLE `ibwf_users` (
`id` int(100) NOT NULL auto_increment,
`name` varchar(30) NOT NULL default '',
`pass` varchar(60) NOT NULL default '',
`birthday` varchar(50) NOT NULL default '',
`sex` char(1) NOT NULL default '',
`location` varchar(100) NOT NULL default '',
`perm` char(1) NOT NULL default '0',
`posts` int(100) NOT NULL default '0',
`plusses` int(100) NOT NULL default '0',
`signature` varchar(100) NOT NULL default '',
`avatar` varchar(100) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`site` varchar(50) NOT NULL default '',
`browserm` varchar(50) NOT NULL default '',
`ipadd` varchar(30) NOT NULL default '',
`lastact` int(100) NOT NULL default '0',
`regdate` int(100) NOT NULL default '0',
`chmsgs` int(100) NOT NULL default '0',
`chmood` int(100) NOT NULL default '0',
`shield` char(1) NOT NULL default '0',
`gplus` int(100) NOT NULL default '0',
`budmsg` varchar(100) NOT NULL default '',
`lastpnreas` varchar(100) NOT NULL default '',
`lastplreas` varchar(100) NOT NULL default '',
`shouts` int(100) NOT NULL default '0',
`pollid` int(100) NOT NULL default '0',
`rbcid` varchar(255) NOT NULL default '',
`hvia` char(1) NOT NULL default '1',
`lastvst` int(100) NOT NULL default '0',
`battlep` int(100) NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `id` (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
--
-- Dumping data for table `ibwf_users`
--
and
[attachment=1261:index.php]
[attachment=1260:core.php]
i want to show in users profile like this
More Information
Send PM
add to buddy list
Member's ID:
Status: Vinyl Shaker
A/S/L: 18/Male/
IP country:South Africa Flag image
Topics: 9
Posts: 127/152
PMs IN: 26 - OUT: 52
Game Plusses: 93
Chat Posts: 22
Fun Points: 0
Shouts: 28/42
Joined rw: 02 07 07-17:23:51
Last Active: 07 10 07-18:20:37
Last Visit: 07 10 07-12:13:11
Browser: Opera
E-mail:
Signature:[/b]
if ($IP_COUNTRY_FROM_SCRIPT_COUNTRY_DETECTOR == $IP_FROM_MY_USERS_DATABASE){echo "FKNG_FLAG"}
Comment
Comment