Latest topics
» How To Install the Code Snippet Button
by SLGray Today at 20:56

» Select Button
by SLGray Today at 20:25

» FM Themes
by SLGray Today at 16:48

» User - Made Creations
by SLGray Today at 16:48

» The Football Forums
by Mati Today at 15:22

» [BUG] Avatar doesn't resize when reading the profile
by Samantha NL Today at 12:33

» Search Bar Options
by Samantha NL Today at 11:38

» Chit Chat Thread
by Jazeon Today at 05:42

» Christmas logo
by Teo! Today at 03:56

» SyncEditor
by keko_ferkeko Today at 00:31

» Private message bg color
by Mr.Alam Yesterday at 22:54

» Multi-step Login Form
by Samantha NL Yesterday at 12:54

» Member of the Month
by Samantha NL Yesterday at 12:38

» Forumactif Edge - Dutch Translation
by Samantha NL Yesterday at 10:49

» Widget : Staff Online
by Samantha NL Yesterday at 10:39

Recent Tutorials
Who is online?
In total there are 4 users online :: 0 Registered, 0 Hidden and 4 Guests :: 1 Bot

None

[ View the whole list ]


Most users ever online was 172 on Fri 19 Feb 2016, 05:17

[TUTORIAL] [PHPBB3] SECURITY: Block Registration by Country or Region

View previous topic View next topic Go down

Guest
Guest
View all awards

PostGuest on Thu 21 Apr 2016, 02:14

Title: [TUTORIAL] SECURITY: Block Registration by Country or Region
By: Samantha (SamanthaMelissaS)
Date: Thu. 21th April 2016

Target platforms: All (as far as I know, didn't test it)

Hi all!

The same way as described in this tutorial: [TUTORIAL] SECURITY: Block and Redirect by Country or Region , one could also block users from other coutries or regions from registering at your site, unless it's listed.


What it does:
It will check where the newbie is from, take away the 'Accept' and 'Decline' buttons on the registration page, give them a notice why they can't register and send them back to the index page. Sidenote: if any proxy is being used from within the allowed country list, it will also block them.


The JSON code:
Placement: In all the pages
Name: SECURITY: Block Registration by Country or Region (All Pages) - ON (Geek sidenote: I always put the placement and status of a script in my descriptions. I like to keep track of anything in a blink of an eye. But it's up to you. You can name it whatever you want.)

Code:
var CopyrightNotice='Restrict Registration by Country. By Samantha at www.friendcodes.nl ©2014-2016. All Rights Reserved. Usage is free and at your own risk. Modifications are allowed. This entire copyright notice MUST remain in the original, copied, or modified script';
$(function(){
if(location.href.match('register')){
    $.getJSON('http://ip-api.com/json', function(data) {
var x = data.country;
        if(x=='XY'){
            $('.button1').css('display','initial');
            $('.button2').css('display','initial');
        }else{
            $('.button1').css('display','none');
            $('.button2').css('display','none');
alert('Your Message Here');}});};});


Multiple entries:

Code:
var CopyrightNotice='Restrict Registration by Country. By Samantha at www.friendcodes.nl ©2014-2016. All Rights Reserved. Usage is free and at your own risk. Modifications are allowed. This entire copyright notice MUST remain in the original, copied, or modified script';
$(function(){
if(location.href.match('register')){
    $.getJSON('http://ip-api.com/json', function(data) {
var x = data.country;
        if(x=='XY'||x=='XY'||x=='XY'){
            $('.button1').css('display','initial');
            $('.button2').css('display','initial');
        }else{
            $('.button1').css('display','none');
            $('.button2').css('display','none');
alert('Your Message Here');}});};});


Sample code:
This code will only allow people from Belgium, Luxemburg and The Netherlands be able to sign up and throw them a nice little notification:

Code:
var CopyrightNotice='Restrict Registration by Country. By Samantha at www.friendcodes.nl ©2014-2016. All Rights Reserved. Usage is free and at your own risk. Modifications are allowed. This entire copyright notice MUST remain in the original, copied, or modified script';
$(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.');}});};});


Last edited by Samantha on Sun 31 Jul 2016, 05:07; edited 1 time in total
Ace 1
Valued Member
Title :
God of Creation
Gender : Male
Age : 17
Posts : 1927
Points : 2312
Reputation : 55
Location : druid hill Park
Language : Eng, Fr, Loud
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Fri 01 Jul 2016, 14:40

But @Samantha can't a guest from that country/region just go to "/register?agreed=true&step=2" and bypass even visiting the Register page?

LOOPHOLES Angel
Guest
Guest
View all awards

PostGuest on Sat 02 Jul 2016, 16:07

Nemesis wrote:But @Samantha can't a guest from that country/region just go to "/register?agreed=true&step=2" and bypass even visiting the Register page?

LOOPHOLES Angel

True that and I've known that little glitch for years now, but there's no way to get around all of the loopholes and get the FM sites 100% secure with JS. And, people can always choose to deactivate JS in their browsers, so the whole script won't run at all Razz

Anyway, it's n00b proof, not fail safe. And together with the other scripts in the tutos I shared it does the job pretty well. High Five
Ace 1
Valued Member
Title :
God of Creation
Gender : Male
Age : 17
Posts : 1927
Points : 2312
Reputation : 55
Location : druid hill Park
Language : Eng, Fr, Loud
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Sat 02 Jul 2016, 18:48

Okay. I still like it though, along with your other two tutorials. Thumb right
BlackScorpion
Valued Member
Title :
Scorpion King
Gender : Male
Posts : 1164
Points : 2292
Reputation : 94
Location : USA
Language : english
Browser : Browser : Google Chrome Forum Version : Forum Version : Other
Awards :
View all awards
View user profile http://themechanger.forumotion.com https://pinterest.com/blkscorpion2

PostBlackScorpion on Sat 02 Jul 2016, 22:34

Thanks for sharing it. Even with the loophole it still better than nothing.

--------

Respect is earned, loyalty returned.

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

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