[TRICK] No attachment limits for admins

Started by Elmacik, June 21, 2012, 05:10:53 AM

Previous topic - Next topic

Elmacik

There is already a topic about making admins exempt from attachment limits, but it's quite old and doesn't work now. So I made a new and enhanced trick to make it. :)

Instead of altering codes in every limit check, tricking it once in Load.php is much easier. Open Load.php

Code (Find) Select
// Just build this here, it makes it easier to change/use - administrators can see all boards.
if ($user_info['is_admin'])
$user_info['query_see_board'] = '1=1';


Code (Replace) Select

// Just build this here, it makes it easier to change/use - administrators can see all boards.
if ($user_info['is_admin'])
{
$user_info['query_see_board'] = '1=1';

// Exempt admins from attachment size limits
$modSettings['attachmentSizeLimit'] = (@ini_get('post_max_size') * 1024) or 99999999;
$modSettings['attachmentPostLimit'] = (@ini_get('post_max_size') * 1024) or 99999999;

// Exempt admins from attachment extension restrictions
$modSettings['attachmentCheckExtensions'] = false;

// Exempt admins from max allowed attachment dir limit
$modSettings['attachmentDirSizeLimit'] = 999999999999;

// Exempt admins from max number of attachments allowed in a post
$modSettings['attachmentNumPerPostLimit'] = 100;
}


Now admins are not subject to any attachment limits. (i.e Number of attachments per post, size of an attachment, total size of attachments, attachment extension limits (admins will be able to upload any kind of files while others are not) and attachment directory total limit.) Of course your server's max allowed post size limit still applies since it's nothing to do with SMF. If you want to change that too, go to your php.ini file and edit post_max_size directive to allow larger uploads.

Note the comment lines in the code. Each of them removes a limit for admins. You can remove any lines that you don't want to apply.

Tested to work with SMF 2.0.2
Home of Elmacik


Chalky


Arbalot


Kolya

This prevents Attachment Settings from being loaded correctly in the backend.

GL700Wing

Life doesn't have to be perfect to be wonderful ...

Elmacik

Quote from: Kolya on July 27, 2013, 07:29:48 AM
This prevents Attachment Settings from being loaded correctly in the backend.

Actually this trick has nothing to do with loading attachment settings and it effects no one other than admins. There must be a conflict with any other mod or trick you are using.
Home of Elmacik

TomW

Very nice; I've needed this functionality in the past.  Works great on 2.0.6 !

dougiefresh

Quote from: Elmacik on October 04, 2013, 03:49:17 AM
Quote from: Kolya on July 27, 2013, 07:29:48 AM
This prevents Attachment Settings from being loaded correctly in the backend.

Actually this trick has nothing to do with loading attachment settings and it effects no one other than admins. There must be a conflict with any other mod or trick you are using.
I hate to bump such an old thread, but yeah, doing it this way would prevent the correct settings from being loaded.  You see, the settings for the entire forum are loaded ONCE.  You are modifying those settings AFTER the forum loads the settings.....  Those modified settings will show up in the Attachment Settings page instead of the ones from the database.  A different approach is required for this to work correctly....  Like a settings reload from the cache...

Advertisement: