Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Country Blacklist Feature #8

Closed
rohit1290 opened this issue Apr 14, 2016 · 3 comments
Closed

Country Blacklist Feature #8

rohit1290 opened this issue Apr 14, 2016 · 3 comments

Comments

@rohit1290
Copy link

I really loved the feature where I can restrict country from registering on my elgg website. I understand that it was fassim feature and you removed it when you removed fassim. That is why I have a new code that can help in bringing back the feature without fassim. You just need to paste the below code in your lib/function.php file in the check_spammer() function.

if (!$spammer) {
    //Country Blacklist
    $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$register_ip));    
        if($ip_data && $ip_data->geoplugin_countryName != null){
            $geo_country = $ip_data->geoplugin_countryCode;
        }

        $country_blacklisted = elgg_get_plugin_setting('fassim_blocked_country_list', "spam_login_filter");
        $country_blacklisted = str_replace(' ', '', $country_blacklisted); // cleanup
        $country_list = explode(",",$country_blacklisted);
        if (in_array($geo_country, $country_list)) {
            register_error(elgg_echo('Access denied as the service is not available in your country.'));
            notify_admin($register_email, $register_ip, "Country blacklist");
            $spammer = true;
        }
}
@rohit1290
Copy link
Author

And in spam_login_filter\views\default\plugins\spam_login_filter\setting.php add this:

// Country BlackList
$title = elgg_echo("Country Blacklist");

$content = "<div class='mbs'>";     
$content .= elgg_echo("Block the following countries:");        
$content .= elgg_view("input/text", array("name" => "params[fassim_blocked_country_list]", "value" => $plugin->fassim_blocked_country_list));       
$content .= elgg_view("output/longtext", array("value" => elgg_echo("(Just type in the country abbreviation of the countries you want to block, for multiple countries separated by comma, e.g. US,LV,HK. For a full list of supported country abbreviations click <a href='http://www.worldatlas.com/aatlas/ctycodes.htm' target='_blank'>Country Codes</a>)"), "class" => "elgg-subtext"));       
$content .= "</div>";

echo elgg_view_module("inline", $title, $content);

@beck24
Copy link
Owner

beck24 commented Apr 19, 2016

I'll add this back in at some point, thanks

@rohit1290
Copy link
Author

@beck24 will this be included in next version of the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants