Allow only certain countries to post

ClassiBase classifieds script Forums General help Allow only certain countries to post

Tagged: , ,

This topic contains 0 replies, has 1 voice, and was last updated by  infoactivo 1 year, 9 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2421 Reply

    infoactivo
    Participant

    You cant disallow certain IP from your site, via the admin area.
    But maybe you want only certain countries to post.
    I think you can get this with a little change to your theme/layouts/frontend.php file
    Find in your theme/layouts/frontend.php file
    <div class="content<?php
    and change it to

    <?php
    $geotarget = '';
    if($page_type==='ad_post')
    {
      $geoPlugin_array = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $_SERVER['REMOTE_ADDR']) );
    	$country = strtolower($geoPlugin_array['geoplugin_countryCode']);
    	switch ($country) {
    		// NOTE: Lower cases ISO 3166 Country Codes from here
        // http://www.geoplugin.com/iso3166
        case 'gb': // United Kingdom
    		case 'us': // United States
    			// Allow visitors from above countries to post ads
    			$geotarget = '';
    			break;  
    		default:
    			// The rest of the world CAN'T post ads
    			$geotarget = 'style="visibility: hidden;"'; 
    	}
    }
    ?>
    
    			<div <?php echo $geotarget ?> class="content<?php
    
    

    Upload file.
    I wish this can help.
    This uses geoPlugin from http://www.geoplugin.net

Viewing 1 post (of 1 total)
Reply To: Allow only certain countries to post
Your information: