obey-robots.txt
View Thread
All MODs and their Supported Threads goes here in this Section.
 Print Thread
[MOD]Prevent certain countries to register
Wanabo
If you have a website aimed at only 1 country and receive a lot of spammers from other countries then you can prevent them registering with this mod.

Or just block unwanted countries.

In this example I use XX for the country codes so I cannot offend any countries by listing them here.
Replace XX for the desired country to block.

Open register.php and find around line 86


   if (!preg_match("/^[-0-9A-Z_\.]{1,50}@([-0-9A-Z_\.]+\.){1,50}([0-9A-Z]){2,4}$/i", $email)) {
      $error .= $locale['406']."
\n";
   }


Insert directly below this code.


// block unwanted countries. See Wipmania.com for country list. Mod by Wanabo.
if (getenv(HTTP_X_FORWARDED_FOR)) {$trueip = getenv(HTTP_X_FORWARDED_FOR);} else {$trueip = getenv(REMOTE_ADDR);}
$blockcountry = array("XX","XX","XX");
$country = file_get_contents("http://api.wipmania.com/".$trueip."?".$_SERVER['HTTP_HOST']."");
if ($country == in_array($country,$blockcountry)) {$error .= $locale['406']."
\n";}
// end country mod


Improvements of this code is welcome.
Cool
 
Ankur
Thanks for this Good MOD Wanabo.... Wink

Also, you can Block them through the .htaccess if you want to Block particular IPs or IP Range from a particular Country !!! Smile
Be What you want to be...Wink
 
www.php-fusion.in
Wanabo
But in htaccess, you prevent them from viewing your site as well.
Besides ip ranges change now and then, wipmania.com keeps them updated for you. Smile
Cool
 
Ankur

Quote

Wanabo wrote:
But in htaccess, you prevent them from viewing your site as well.


Agree... Cool
Be What you want to be...Wink
 
www.php-fusion.in
Jump to Forum
New Thread Post Reply
Use BBcode or HTML to refer to; '[MOD]Prevent certain countries to register'
BBcode:
HTML: