News:

Wondering if this will always be free?  See why free is better.

Main Menu

[TIP] Protected Accounts

Started by RyanJones, February 24, 2006, 08:15:08 PM

Previous topic - Next topic

RyanJones

This modification will allow you to set a list of "protected" users. This is done from outside the forum so it cannot be bypassed very easily.

Open Settings.php in your forums root directory.

In the file (before the ?>) add this:


  $master 
= array();

  
# ///////// PROTECTED USERS //////////////
  
$master['protected_accounts'] = '{USER_ID_LIST}';


Replace {USER_ID_LIST} with a comma seperated list of the account ID's to be protected, exampes could be:

$master['protected_accounts'] = '1';
$master['protected_accounts'] = '2,5';
$master['protected_accounts'] = '2,5,500';

Save the file.

Open the file called Errors.english.php (And any other languages you like) and add this somewhere:


$txt
['no_deleting_protected_account'] = 'The account you have attempted to delete has been classed as protected. This account cannot be removed.';


Close and save the file.


Open Profile.php (Sources Directory)

Find:

	
global 
$ID_MEMBER$user_info$sourcedir$context$db_prefix$user_profile$modSettings;


And replace with:


	
global 
$ID_MEMBER$user_info$sourcedir$boarddir$context$db_prefix$user_profile$modSettings$master;

  
# Stop deletion of certain UID's.
  
$blokedIDs explode(','$master['protected_accounts']);
  if (
in_array($memID$blokedIDs))
	
  
fatal_lang_error('no_deleting_protected_account'true);


And that blocks profile deletion!

Cheers,

Ryan Jones
RyanJ (Ryan Jones)

Support Web Standards!

Currently working On: Additions to the Karma system.

RyanJones

#1
And the admin area:

Open Subs-Members.php (Sources Directory)

Find:

	
global 
$db_prefix$sourcedir$modSettings$ID_MEMBER;


And replace with:


	
global 
$db_prefix$sourcedir$modSettings$ID_MEMBER$master;

      
# Stop deletion of certain UID's.
	
require_once(
$sourcedir '/Errors.php');

  
$blokedIDs explode(','$master['protected_accounts']);
	
foreach (
$users as $user)
  {
    if (
in_array($user$blokedIDs))
	
    
fatal_lang_error('no_deleting_protected_account'true);
  }


Cheers,

Ryan Jones
RyanJ (Ryan Jones)

Support Web Standards!

Currently working On: Additions to the Karma system.

kegobeer

You may want to rename config.php to something else.  One, it's very common and most script kiddies look for such files.  Two, many cheap hosting companies prevent scripts with that name.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

RyanJones

Quote from: kegobeer on February 24, 2006, 08:18:37 PM
You may want to rename config.php to something else.  One, it's very common and most script kiddies look for such files.  Two, many cheap hosting companies prevent scripts with that name.

Not a bad idea.

Would it be possible to intergrate directly into Settings.php?

Cheers,

Ryan Jones
RyanJ (Ryan Jones)

Support Web Standards!

Currently working On: Additions to the Karma system.

RyanJones

UPDATE: This code does work for the Settings.php file so moved the master() array to there. Instructins updated.

Cheers,

Ryan Jones
RyanJ (Ryan Jones)

Support Web Standards!

Currently working On: Additions to the Karma system.

Advertisement: