News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Disable deletion of yourself

Started by Tristan Perry, September 11, 2004, 09:56:11 AM

Previous topic - Next topic

Tristan Perry

Hello all,
  If you're like me, and very paranoid then this may help you  :P. It stops people [With the correct permissions] from deleting your account on your forums. To do this find:

function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;

In Sources/ManageMembers.php (/Sources/Subs-members.php in SMF 1.1)

and replace it with:

function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;

        // Protect the person who started the forum

       if ($users == 1 or @in_array(1, $users))
              fatal_error('You\'re not allowed to delete the administrator.');


This stops people from deleting your account either through your profile, or through the view/delete members page in the admin panel.
If you're ID isn't 1, but you still want to protect yourself, then just change the 2 numbers in this part:
if ($users == 1 || (is_array($users) && in_array(1, $users)))
to whatever your member ID is.

If you want this to not extend to more than one user, you can do so by doing what JohnyB suggested:

// Protect the person who started the forum

if ($users == 1 or $users == 2 or @in_array(1, $users) or @in_array(2, $users))
     fatal_error('You\'re not allowed to delete the administrator.');


I hope this helps someone.
TauOnline.Org

Amacythe

Keep in mind this only works if the Admin is member number one.  In my case, (an upgraded board that had a 'dummy' admin set up as member number one) I need to change it slightly.

Tristan Perry

Quote from: Amacythe on September 11, 2004, 10:23:49 AM
Keep in mind this only works if the Admin is member number one.  In my case, (an upgraded board that had a 'dummy' admin set up as member number one) I need to change it slightly.
Yeah it's easy to change though  :) I'll edit my post just to show how to do it if people don't know.

[Unknown]

Quote from: Tau Online on September 11, 2004, 09:56:11 AM
if ($users == 1 xor in_array(1, $users) )

Just wondering; is there a particular reason you're using xor here?  It's different from or in that it means one OR the other, but not BOTH.  In this case, it really *couldn't* be both, but or (||) should work too....

-[Unknown]

Tristan Perry

Quote from: [Unknown] on September 11, 2004, 03:28:08 PM
Quote from: Tau Online on September 11, 2004, 09:56:11 AM
if ($users == 1 xor in_array(1, $users) )

Just wondering; is there a particular reason you're using xor here?  It's different from or in that it means one OR the other, but not BOTH.  In this case, it really *couldn't* be both, but or (||) should work too....

-[Unknown]
Your right! Thanks, I'll change it now  :) It wouldn't make a difference though would it? (I mean whether xor or || is used?)

[Unknown]

Nope, none really in this case.... although, I prefer "||" over the word form "or".... then again I like C/C++ ;).

-[Unknown]

double_d

Dont' want to be a pain, but is there a way to keep users from deleting their own accounts?  I hate when people do that.

[Unknown]

It's a permission.  Simply disallow it.

-[Unknown]

Sol

This doesn't seem to work with SMF 1.0.1 Final :'(

I get this error :
2: in_array(): Wrong datatype for second argument
File: /home/sol/public_html/forum/Sources/ManageMembers.php
Line: 984

Line 984 :
if ($users == 1 || in_array(1, $users) )

I've used this trick twice before with RC2 and it's worked fine. I've copied everything exactly right.

Tristan Perry

#9
Quote from: Sol on January 27, 2005, 11:56:38 AM
This doesn't seem to work with SMF 1.0.1 Final :'(

I get this error :
2: in_array(): Wrong datatype for second argument
File: /home/sol/public_html/forum/Sources/ManageMembers.php
Line: 984

Line 984 :
if ($users == 1 || in_array(1, $users) )

I've used this trick twice before with RC2 and it's worked fine. I've copied everything exactly right.
It's not updated to work with SMF 1.0(.1) I'll update it sometime  :)

Sol


azuregenesis

working fix for 1.03 (tested) just quoted TauOnline and edited it :)

find in Sources/ManageMembers.php
function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;

In Sources/ManageMembers.php

and replace it with:


function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;

        // Protect the person who started the forum
if ($users == 1)
{
           fatal_error('You\'re not allowed to delete the administrator.');
           exit();
}


This stops people from deleting your account either through your profile, or through the view/delete members page in the admin panel.
If you're ID isn't 1, but you still want to protect yourself, then just change the number.

Jako

Am I the only one that's scared to test this mod out? >>
Maximus: Brothers, what we do in life... echoes in eternity.


Tristan Perry

#13
I've updated my first post so this now works with updated versions (Tested with 1.1 Beta 3 and 1.0.5)

Credit goes to [Unknown] for this update, he posted an updated/working version of this hack in one of the threads in the Announcements board.

Quote from: Jako on June 26, 2005, 04:59:20 AM
Am I the only one that's scared to test this mod out? >>
:P I was at first. Either backup your database or run SMF on a test server.. It should work though.

azuregenesis

Quote from: Jako on June 26, 2005, 04:59:20 AM
Am I the only one that's scared to test this mod out? >>

you can do what TAU said above or you can also change the user number in the code above. :)

instead of "1" (whcih is the admin) change it to another one, like a member that you're about to remove.

Metal_GunBlade

Dude, I have SMF 1.1 Beta 3 but I can't find the code...
Is there something I'm missing???
Life is ours to be spent, not to be saved

[Unknown]

It's in Subs-Members.php.

-[Unknown]

rojamaia


how about if i want to protect two or more accounts?

can i just add comma to the number like if ($users == 1,2 xor in_array(1,2 $users) )

by the way, which one of the two codes would work for 1.0.5?  could you please label those codes with the versions that it would work with?

thank you!  :D

[Unknown]

No, you can't just add commas like that.  Instead:

if ($users == 1 or $users == 2 or @in_array(1, $users) or @in_array(2, $users))

Would probably be best.

-[Unknown]

rojamaia

#19
so if it's three users, i just add more "or"s?


something like this?
if ($users == 1 or $users == 2 or $users == 36 or @in_array(1, $users) or @in_array(2, $users) or @in_array(3, $users))

Advertisement: