Customizing SMF > Tips and Tricks
Disable deletion of yourself
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:
--- Code: ---function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;
--- End code ---
In Sources/ManageMembers.php (/Sources/Subs-members.php in SMF 1.1)
and replace it with:
--- Code: ---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.');
--- End code ---
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:
--- Code: ---if ($users == 1 || (is_array($users) && in_array(1, $users)))
--- End code ---
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:
--- Code: --- // 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.');
--- End code ---
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.
--- End quote ---
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 ---
--- Code: ---if ($users == 1 xor in_array(1, $users) )
--- End code ---
--- End quote ---
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 ---
--- Code: ---if ($users == 1 xor in_array(1, $users) )
--- End code ---
--- End quote ---
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]
--- End quote ---
Your right! Thanks, I'll change it now :) It wouldn't make a difference though would it? (I mean whether xor or || is used?)
Navigation
[0] Message Index
[#] Next page
Go to full version