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

smurfavr

[ View the whole list ]


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

[TUTORIAL] [PHPBB3] SECURITY: Block Guests from Viewing your Topics & Posts

View previous topic View next topic Go down

Guest
Guest
View all awards

PostGuest on Thu 21 Apr 2016, 02:30

Title: [TUTORIAL] SECURITY: Block Guests from Viewing your Topics & Posts
By: Samantha (SamanthaMelissaS)
Date: Thu. 21th April 2016

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

Hi all!

This code will block Guests from Viewing your Topics & Posts.


What it does:
It will check if someone is logged in. If not and a topic or post is requested to be viewed, it will send the guest a message. When the 'OK' button in that request is clicked, it will bring them back to the index page. People will still be able to browse the forums.


The JS code:
Placement: Index + Topics
Name: SECURITY: Block Guests from Viewing your Topics and Posts (Index / Topics) - 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:
$(document).ready(function(){
var CopyrightNotice='Block Guests from Viewing your Topics and Posts. 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';
if(!_userdata.session_logged_in && /\/t\d+/.test(window.location.href)){
        alert('Your Message Here');
        window.location.href = '/';
      }
});


Sample code:
This code will show a guest who tries to read one of the topics or posts a custom-made message in Dutch as well as in English:

Code:
 $(document).ready(function(){
var CopyrightNotice='Block Guests from Viewing your Topics and Posts. 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';
if(!_userdata.session_logged_in && /\/t\d+/.test(window.location.href)){
        alert('Je moet ingelogd zijn om berichten te kunnen bekijken. Registreer je nu op Friendcodes of log in!\n\nYou need to be logged in to be able to watch the topics. Please register with Friendcodes now or log in!');
        window.location.href = '/';
      }
});



Last edited by Samantha on Sun 31 Jul 2016, 05:08; edited 2 times in total
skouliki

Title :
Gender : Female
Posts : 274
Points : 779
Reputation : 107
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki on Thu 21 Apr 2016, 03:26

thats very useful thanks
in my forum invision http://keeponblogging.forumotion.com nothing happens when i put the code
any suggestions ?

when you are in let me know so i can active it again

--------

Guest
Guest
View all awards

PostGuest on Thu 21 Apr 2016, 03:54

@skouliki wrote:thats very useful thanks
in my forum invision http://keeponblogging.forumotion.com nothing happens when i put the code
any suggestions ?

when you are in let me know so i can active it again

@skouliki : It works fine on my phpBB3 site, even on mobile Smile You can see it in action on my site if you want to. I don't know anything about Invision, I'm sorry, but I take it you followed the steps by placing it In the Topics and on The Index, right? Also, you must use the 'copy content' button top right of the code box and then paste it into a new JS.

I've seen on your site, there isn't any other main page, just the '/' , which is fine. So, I don't see why it shouldn't work...

Could you try another browser to test for me please?
skouliki

Title :
Gender : Female
Posts : 274
Points : 779
Reputation : 107
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki on Thu 21 Apr 2016, 04:08

now its active with firefox and chrome i can read the topics as a quest
give it a try

--------

skouliki

Title :
Gender : Female
Posts : 274
Points : 779
Reputation : 107
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki on Thu 21 Apr 2016, 04:12

i think the problem is with the translation
which is the one i have to click

index-main page-subforums-posts-all pages ?

--------

Guest
Guest
View all awards

PostGuest on Thu 21 Apr 2016, 04:15

Yep, it's not working on your site and I have no clue. Since I will be offline for pretty much the remainder of the day because we're gonna get solar panels installed, either you 'll have to wait until I'll be back or perhaps someone else will be generous to help you.

This is what I've got: http://prntscr.com/auxajk
skouliki

Title :
Gender : Female
Posts : 274
Points : 779
Reputation : 107
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki on Thu 21 Apr 2016, 04:21

thank you samatha
i have already checked this 2 so i have to wait for someone to figure this out or you no rush

for now i will de active it and when you have spare time let me know

--------

Guest
Guest
View all awards

PostGuest on Thu 21 Apr 2016, 04:27

@skouliki wrote:thank you samatha
i have already checked this 2 so i have to wait for someone to figure this out or you no rush

for now i will de active it and when you have spare time let me know

Yh, that 'll be ok, ty. Meanwhile, check for JS errors on your site. It's a simple script and it should work, because it should be independent of forum versions as far as I can see. Signing off and ttyl.
Andrei34

Gender : Male
Posts : 137
Points : 686
Reputation : 38
Language : Romanian and English
Browser : Browser : Opera Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile

PostAndrei34 on Thu 21 Apr 2016, 04:54

It will not work because it has an error. Try this code:
Code:
$(document).ready(function(){
var CopyrightNotice='Block Guests from Viewing your Topics and Posts. 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';
if(!_userdata.session_logged_in && /\/t\d+/.test(window.location.href)){
        alert('Your Message Here');
        window.location.href = '/';
      }
});
Guest
Guest
View all awards

PostGuest on Thu 21 Apr 2016, 05:00

What error? Did I copy something wrong? And thanks in advance, really need to be off now. They'll be here any minute now.

EDIT: I see now. I'll correct it when back. I prolly didn't copy the full code. I'm sorry. ty @Andrei34 ! X
skouliki

Title :
Gender : Female
Posts : 274
Points : 779
Reputation : 107
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki on Thu 21 Apr 2016, 06:18

yes now works perfect thanks @Andrei34

i find this code perfect !!

--------

Guest
Guest
View all awards

PostGuest on Thu 21 Apr 2016, 07:18

@skouliki wrote:yes now works perfect thanks @Andrei34

i find this code perfect !!



Thanks @skouliki! Glad to be of help. Works precisely as meant 2b: http://prntscr.com/auz4m7 lol! and perhaps you should add a bit of English to that, maybe, possibly, if ever... Wink . And thanks to @Andrei34 as well. Smile Lovely to see how a team just all work together! TY!

I'll be changing that script of mine soon!

[Powered by Solar Engery]

Love,

Samantha.
skouliki

Title :
Gender : Female
Posts : 274
Points : 779
Reputation : 107
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki on Thu 21 Apr 2016, 08:38

i will thanks !

--------

Guest
Guest
View all awards

PostGuest on Thu 21 Apr 2016, 13:48

Replaced the code in the tuto with the one @Andrei34 made. Ty!
SLGray
Valued Member
Title :
Owner of 2 Forums
Gender : Male
Age : 43
Posts : 2170
Points : 4065
Reputation : 246
Location : United States
Language : English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile http://www.fmthemes.forumotion.com https://www.facebook.com/FM-Themes-655055824604957 https://twitter.com/FMThemes https://pinterest.com/FMThemes

PostSLGray on Thu 21 Apr 2016, 14:41

Why would you use a code when you can set the permissions where guests can not see topics?
Guest
Guest
View all awards

PostGuest on Thu 21 Apr 2016, 14:42

Because it's a fire and forget script, nothing the like setting permissions.
skouliki

Title :
Gender : Female
Posts : 274
Points : 779
Reputation : 107
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki on Fri 22 Apr 2016, 06:17

by this code you give something a taste of the topic to quests ...
its a way to make them register ...this is the way i see it

--------

Guest
Guest
View all awards

PostGuest on Fri 22 Apr 2016, 06:21

@skouliki wrote:by this code you give something a taste of the topic to quests ...
its a way to make them register ...this is the way i see it

If you like the preview mode I've got installed on my website (the little icon behind the topic name), you'll have to wait for the grand re-opening of AvacWeb on Friday 29th April. I'm the co-owner of that website now (and admin), together with LGforum and he's got an OST shared on there to have the code installed on your forum. With the preview code you'll be able to show the lastest post in a topic with guests, without sharing the total topic with them.

AvacWeb also offers a very nice chatbox as a shell around the default FM chat. Here's an example of mine:


I styled the chatbox myself and helped developing it. It's custom placed in a HTML-page, but you can have chat anyway you like it, like anywhere on your forum or on mobile.
skouliki

Title :
Gender : Female
Posts : 274
Points : 779
Reputation : 107
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki on Fri 22 Apr 2016, 06:42

wish you all the best .. for the reopening ...
if i need anything i will ask/see thanks !

--------

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