Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: spiros on October 30, 2014, 04:30:45 AM

Title: Force log out everyone and disable log in
Post by: spiros on October 30, 2014, 04:30:45 AM
Is it possible to force log out everyone and disable log in to everybody apart from admin?
Title: Re: Force log out everyone and disable log in
Post by: JBlaze on October 30, 2014, 05:18:31 AM
Other than truncating smf_sessions table (which is not really a great idea), and then enabling maintenance mode, not that I can think of.
Title: Re: Force log out everyone and disable log in
Post by: spiros on October 30, 2014, 05:20:24 AM
Thanks, well, I want to avoid maintenance mode. The reason is for a migration scenario where I want the old server to be accessible to people, but not postable.
Title: Re: Force log out everyone and disable log in
Post by: margarett on October 30, 2014, 05:32:18 AM
Force everyone to login --> change cookie name

Your best option is to remove *all* permissions to *all* membergroups. This way no one can post, PM, etc.
So they can still login but they can't do anything. So they will stop logging in :)

Add to that a big message in index.template.php saying that the forum is in "archive mode" so that everyone knows and you're all set ;)
Title: Re: Force log out everyone and disable log in
Post by: spiros on October 30, 2014, 05:36:02 AM
Yes, I tried the permissions trick in the past. The only down-side is getting back the permissions to what they were before. But I guess I could export the permissions table before the changes and reimport it afterwards.

It would be nice if there was some sort of maintenance mode flavour to make the forum read only and then return to its normal status/permissions.
Title: Re: Force log out everyone and disable log in
Post by: Illori on October 30, 2014, 05:41:34 AM
if you change the name of the cookie, it will log everyone out. then maintenance mode will keep them from logging back in unless they are admin. otherwise there is no way to keep them from logging back in.
Title: Re: Force log out everyone and disable log in
Post by: margarett on October 30, 2014, 05:44:40 AM
Good point.

Let me try something here ;)

edit:
OK, prevent someone from loggin' in should be possible but I'm not really imagining how right now.
But here's a dirty trick ;D
In Sources/Security.php we can fool the "allowedTo" function to refuse all permissions when you're not admin. This way you keep your current permissions untouched with a small code edit
Find:
// Administrators are supermen :P.
if ($user_info['is_admin'])
return true;

(lines 823-825 in a clean file)

Add after:
else
return false;
Title: Re: Force log out everyone and disable log in
Post by: spiros on October 30, 2014, 05:59:33 AM
Quote from: margarett on October 30, 2014, 05:44:40 AM
refuse all permissions when you're not admin

I see, I am guessing that they still have the read permissions allowed to visitors? As, this is what I really want, i.e. a read only mode.

By the way, I just realised it has been exactly 10 yrs since I registered here!
Title: Re: Force log out everyone and disable log in
Post by: margarett on October 30, 2014, 06:19:52 AM
Yes, normal board permissions will apply ;)
Title: Re: Force log out everyone and disable log in
Post by: Kindred on October 30, 2014, 09:56:31 AM
WHat if you created a new membergroup - put everyone in it, and then set DENY permission on everything except READ POSTS?

that way, you are not messing with any of the existing permissions... and to get rid of it, just delete the deny membergrou
Title: Re: Force log out everyone and disable log in
Post by: spiros on October 30, 2014, 09:58:38 AM
That sounds like a good option, too :)
Title: Re: Force log out everyone and disable log in
Post by: margarett on October 30, 2014, 11:42:28 AM
IIRC, there is no permission to read posts :o
Title: Re: Force log out everyone and disable log in
Post by: Illori on October 30, 2014, 11:59:07 AM
Quote from: margarett on October 30, 2014, 11:42:28 AM
IIRC, there is no permission to read posts :o

well kinda there is, permission to view the board gives you permission to read the posts.
Title: Re: Force log out everyone and disable log in
Post by: Arantor on October 30, 2014, 12:02:05 PM
Viewing a board isn't actually a permission last I checked... ;) Board access implies read power, though, but it's not enforced as a permission, only through {query_see_board} which is something else entirely.
Title: Re: Force log out everyone and disable log in
Post by: Illori on October 30, 2014, 12:04:07 PM
it is not in the permissions section, but it is a permission that you are granting to the membergroup.
Title: Re: Force log out everyone and disable log in
Post by: Arantor on October 30, 2014, 12:05:01 PM
Eh, semantics.
Title: Re: Force log out everyone and disable log in
Post by: radu81 on October 30, 2014, 12:13:02 PM
Quote from: Kindred on October 30, 2014, 09:56:31 AM
WHat if you created a new membergroup - put everyone in it, and then set DENY permission on everything except READ POSTS?

that way, you are not messing with any of the existing permissions... and to get rid of it, just delete the deny membergrou
great idea  ;) Never thought on that

It took me some time to understand permissions in SMF, but I might say the permission system it's very flexible and powerful ;)
Title: Re: Force log out everyone and disable log in
Post by: spiros on June 09, 2016, 04:48:16 PM
The side effect of this is that it disables searching for everybody. I want searching to be remain allowed even for guests.


Quote from: margarett on October 30, 2014, 05:44:40 AM
Good point.

Let me try something here ;)

edit:
OK, prevent someone from loggin' in should be possible but I'm not really imagining how right now.
But here's a dirty trick ;D
In Sources/Security.php we can fool the "allowedTo" function to refuse all permissions when you're not admin. This way you keep your current permissions untouched with a small code edit
Find:
// Administrators are supermen :P.
if ($user_info['is_admin'])
return true;

(lines 823-825 in a clean file)

Add after:
else
return false;