Advertisement:

Author Topic: Disable deletion of yourself  (Read 85964 times)

Offline Tristan Perry

  • SMF Hero
  • ******
  • Posts: 2,498
  • Gender: Male
    • Tristan Perry
Disable deletion of yourself
« on: September 11, 2004, 09:56:11 AM »
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: [Select]
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:

Code: [Select]
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:
Code: [Select]
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:

Code: [Select]
// 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
« Last Edit: March 24, 2008, 07:24:32 AM by Tristan Perry »

Offline Amacythe

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,060
  • Gender: Female
Re: Disable deletion of yourself.
« Reply #1 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.

Offline Tristan Perry

  • SMF Hero
  • ******
  • Posts: 2,498
  • Gender: Male
    • Tristan Perry
Re: Disable deletion of yourself.
« Reply #2 on: September 11, 2004, 10:26:14 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.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Disable deletion of yourself.
« Reply #3 on: September 11, 2004, 03:28:08 PM »
Code: [Select]
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]

Offline Tristan Perry

  • SMF Hero
  • ******
  • Posts: 2,498
  • Gender: Male
    • Tristan Perry
Re: Disable deletion of yourself.
« Reply #4 on: September 11, 2004, 04:12:51 PM »
Code: [Select]
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?)

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Disable deletion of yourself.
« Reply #5 on: September 11, 2004, 04:23:57 PM »
Nope, none really in this case.... although, I prefer "||" over the word form "or".... then again I like C/C++ ;).

-[Unknown]

Offline double_d

  • Semi-Newbie
  • *
  • Posts: 35
  • More cow bell!
Re: Disable deletion of yourself.
« Reply #6 on: January 25, 2005, 05:40:46 PM »
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.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Disable deletion of yourself.
« Reply #7 on: January 25, 2005, 06:45:40 PM »
It's a permission.  Simply disallow it.

-[Unknown]

Offline Sol

  • Jr. Member
  • **
  • Posts: 125
    • Frider Wave Studios
Re: Disable deletion of yourself.
« Reply #8 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.

Offline Tristan Perry

  • SMF Hero
  • ******
  • Posts: 2,498
  • Gender: Male
    • Tristan Perry
Re: Disable deletion of yourself.
« Reply #9 on: January 27, 2005, 12:19:23 PM »
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  :)
« Last Edit: January 27, 2005, 01:10:32 PM by Tau Online »

Offline Sol

  • Jr. Member
  • **
  • Posts: 125
    • Frider Wave Studios
Re: Disable deletion of yourself.
« Reply #10 on: January 27, 2005, 03:45:44 PM »
As soon as possible please :P

Offline azuregenesis

  • Semi-Newbie
  • *
  • Posts: 86
Re: Disable deletion of yourself.
« Reply #11 on: May 24, 2005, 11:58:02 PM »
working fix for 1.03 (tested) just quoted TauOnline and edited it :)

find in Sources/ManageMembers.php
Code: [Select]
function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;
In Sources/ManageMembers.php

and replace it with:


Code: [Select]
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.

Offline Jako

  • Semi-Newbie
  • *
  • Posts: 49
  • Gender: Male
  • Saint Jako
    • Operation Flamingo
Re: Disable deletion of yourself.
« Reply #12 on: June 26, 2005, 04:59:20 AM »
Am I the only one that's scared to test this mod out? >>
Maximus: Brothers, what we do in life... echoes in eternity.


Offline Tristan Perry

  • SMF Hero
  • ******
  • Posts: 2,498
  • Gender: Male
    • Tristan Perry
Re: Disable deletion of yourself
« Reply #13 on: June 26, 2005, 05:37:49 AM »
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.

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.
« Last Edit: June 26, 2005, 05:53:55 AM by Tau Online »

Offline azuregenesis

  • Semi-Newbie
  • *
  • Posts: 86
Re: Disable deletion of yourself.
« Reply #14 on: June 26, 2005, 08:18:04 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.

Offline Metal_GunBlade

  • Jr. Member
  • **
  • Posts: 134
  • Gender: Male
  • Life is ours to be spent, not to be saved
Re: Disable deletion of yourself
« Reply #15 on: July 10, 2005, 12:34:42 PM »
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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Disable deletion of yourself
« Reply #16 on: July 10, 2005, 07:43:45 PM »
It's in Subs-Members.php.

-[Unknown]

Offline rojamaia

  • Semi-Newbie
  • *
  • Posts: 83
Re: Disable deletion of yourself
« Reply #17 on: August 27, 2005, 08:05:21 AM »

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

can i just add comma to the number like
Code: [Select]
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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Disable deletion of yourself
« Reply #18 on: August 27, 2005, 01:17:58 PM »
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]

Offline rojamaia

  • Semi-Newbie
  • *
  • Posts: 83
Re: Disable deletion of yourself
« Reply #19 on: August 27, 2005, 01:28:31 PM »
so if it's three users, i just add more "or"s?


something like this?
Code: [Select]
if ($users == 1 or $users == 2 or $users == 36 or @in_array(1, $users) or @in_array(2, $users) or @in_array(3, $users))
« Last Edit: August 27, 2005, 01:30:29 PM by malinaobenny »