Prevent Non Usa Users From Registering

View previous topic View next topic Go down

Prevent Non Usa Users From Registering Empty Prevent Non Usa Users From Registering

Post by _Twisted_Mods_ on 1/21/2015, 9:26 am

_Twisted_Mods_
_Twisted_Mods_
Founder
Founder

Posts : 101
Reputation : 3
Birthday : 1986-08-05
Join date : 2014-10-03
Age : 32
Location : USA

View user profile
Code:
$(function(){
    var clist = ['United States','Belgium'];
if(location.href.match('register')){
    $.getJSON('http://ip-api.com/json', function(data) {
            for(i=0;i<clist.length;i++){
        if(data.country == clist[i]){
            $('.button1').remove();
            $('.button2').remove();
alert('       Sorry We Only Accept Users From The United States.\n\n\
       If Your In The United States And Your Seeing This Your \n\
Probably Running On A Proxy And Will Not Be Able To  Register.');}}
    });}});

To check your current location, goto http://ip-api.com/#

place this in your

acp>display>generalities

Code:
<noscript>  <style>html{display:none;}</style>  <meta http-equiv="refresh" content="0.0;url=/"> </noscript>

to prevent JS workaround. It should redirect the member to the homepage if they switched of JS execution in their browser.

Back to top Go down

Prevent Non Usa Users From Registering Empty Re: Prevent Non Usa Users From Registering

Post by Guest on 1/30/2015, 5:59 am

avatar
Guest
Guest


phpBB3 JS coding for this (example) blocking all traffic except for The Netherlands, Belgium and Luxemburg. This one works 100% in FF, IE and GC, and has been tested in at least phpBB3 now:


phpbb3

[script=SECURITY: Restrict Registration by Country or Region=All the pages]
Code:
$(function(){
if(location.href.match('register')){
    $.getJSON('http://ip-api.com/json', function(data) {
var x = data.country;
        if(x=='Belgium'||x=='Luxemburg||x=='Netherlands'){
            $('.button1').css('display','initial');
            $('.button2').css('display','initial');
        }else{
            $('.button1').css('display','none');
            $('.button2').css('display','none');
alert('Sorry!\n\nWe only accept users from:\n\n-Belgium\n-Luxemburg\n-The Netherlands\n\nIf you are located in one of these countries and you are seeing this you are probably running on a proxy and will not be able to register.');}});};});


To prevent JS workaround by switching it off, the user will be redirected to the homepage when placed in acp>display>generalities:

Code:
<noscript>  <style>html{display:none;}</style>  <meta http-equiv="refresh" content="0.0;url=/"> </noscript><br />

finally add this to your CSS to hide the white bar on index:

Code:
.panel.introduction{display:none}


Result:
IE message: http://prntscr.com/5yhkb7
FF message: http://prntscr.com/5yhkkd
GC message: http://prntscr.com/5yhktu

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum