ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The code snippet below is from the support website. Instructed to paste this at the start of 'Register.template.php'.
Code:
// Version: 1.1.10; Register
/////////////////////////////////////////////////////////
// mod - 12-21-2009 - prevent certain "problem" countries from
// registering based on their IP address....
// try and get the real IP address...
if (getenv('HTTP_CLIENT_IP')) {
$ip_address = getenv('HTTP_CLIENT_IP');
}elseif (getenv('HTTP_X_FORWARDED_FOR')) {
$ip_address = getenv('HTTP_X_FORWARDED_FOR');
}elseif (getenv('HTTP_X_FORWARDED')) {
$ip_address = getenv('HTTP_X_FORWARDED');
}elseif (getenv('HTTP_FORWARDED_FOR')) {
$ip_address = getenv('HTTP_FORWARDED_FOR');
}elseif (getenv('HTTP_FORWARDED')) {
$ip_address = getenv('HTTP_FORWARDED');
}else {
$ip_address = $_SERVER['REMOTE_ADDR'];
}
// Query for getting visitor countrycode
$country_query = "SELECT country_code2,country_name FROM iptocountry ".
"WHERE IP_FROM<=inet_aton('$ip_address') AND IP_TO>=inet_aton('$ip_address') ";
// Execute above query
$country_exec = mysql_query($country_query);
// Fetch record set
$ccode_array=mysql_fetch_array($country_exec);
// get the country code from the array
$country_code=$ccode_array['country_code2'];
// get the country name from the array
$country_name=$ccode_array['country_name'];
if($country_code==''){$country_code='XX';}
if($country_name==''){$country_name='UNKNOWN';}
//print "$country_code, $country_name";
// countries registration is ALLOWED from
$allow_list[] = 'us'; // USA numbah wun
$allow_list[] = 'US'; // USA numbah wun
$allow_list[] = 'ca'; // Canada, eh?
$allow_list[] = 'CA'; // Canada, eh?
//$allow_list[] = 'PR'; // Puerto Rico
//$allow_list[] = 'VI'; // Virgin Islands, nice beaches
$allow_list[] = 'gb'; // Great Britain/UK, cheerio, guv
$allow_list[] = 'GB'; // Great Britain/UK, cheerio, guv
$allow_list[] = 'uk'; // Great Britain/UK, cheerio, guv
$allow_list[] = 'UK'; // Great Britain/UK, cheerio, guv
//$allow_list[] = 'SE'; // Sweden - always allow blondes!
$allow_list[] = 'au'; // Autralia - throw another dingo on the barbie, mate!
$allow_list[] = 'AU'; // Autralia - throw another dingo on the barbie, mate!
//$allow_list[] = 'FR'; // France, ze land of luuuuuuuuuv
//$allow_list[] = 'ZA'; // South Africa, shucks, why not...
//$allow_list[] = 'VG'; // British Virgin Islands, blimey, eh wot?
//$allow_list[] = 'GL'; // Greenland, too cold for most spammers
//$allow_list[] = 'AQ'; // Antarctica (see 'Greenland')
//$allow_list[] = 'IO'; // British Indian Ocean territory
//$allow_list[] = 'AS'; // American Samoa (they're Yanks, sort of)
if(!in_array($country_code, $allow_list)){
print <<<EOM
<html><head></head>
<body bgcolor="#dcdcdc">
Registration for your country is disabled. Sorry.
</body></html>
EOM;
exit;
}
/////////////////////////////////////////////////////////
The SQL is as follows: My 'Hostmonster' 'myphpadmin' tells me I got a successful install.
Code:
DROP TABLE IF EXISTS iptocountry;
CREATE TABLE iptocountry (
ip int(11) unsigned NOT NULL default '0',
country char(2) NOT NULL default '',
KEY ip (ip)
);
DROP TABLE IF EXISTS iptocountryCountries;
CREATE TABLE iptocountryCountries (
code varchar(4) NOT NULL default '',
iso_code_2 varchar(2) NOT NULL default '',
iso_code_3 varchar(3) default '',
iso_country varchar(255) NOT NULL default '',
country varchar(255) NOT NULL default '',
lat float NOT NULL default '0',
lon float NOT NULL default '0',
PRIMARY KEY (code),
KEY code (code)
);
INSERT INTO iptocountry (ip, country) VALUES(0, 'us');
INSERT INTO iptocountry (ip, country) VALUES(687865856, 'za');
INSERT INTO iptocountry (ip, country) VALUES(689963008, 'eg');
And ends 59348 lines later with this:
INSERT INTO iptocountryCountries (code, iso_code_2, iso_code_3, iso_country, country, lat, lon) VALUES('eu', '', '', '', 'Europe', 0, 0);
INSERT INTO iptocountryCountries (code, iso_code_2, iso_code_3, iso_country, country, lat, lon) VALUES('01', '', '', '', 'Private', 0, 0);
INSERT INTO iptocountryCountries (code, iso_code_2, iso_code_3, iso_country, country, lat, lon) VALUES('ps', 'PS', 'PSE', 'Palestinian Territory, Occupied', 'Palestinian Territory, Occupied', 31.89, 34.9);
INSERT INTO iptocountryCountries (code, iso_code_2, iso_code_3, iso_country, country, lat, lon) VALUES('me', 'ME', 'MNE', 'Montenegro', 'Montenegro', 42.74, 19.31);
When I try to register, I get the 'Registration for your country is disabled. Sorry.' message on my browser screen.
I am at a lose where/what to trouble shoot. Can some one get me on the path to recovery??
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.