Customizing SMF > SMF Coding Discussion
[TRICK] No attachment limits for admins
(1/1)
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) --- // 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';
--- End code ---
--- Code: (Replace) --- // 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;
}
--- End code ---
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
Antechinus:
Nice one. :)
ChalkCat:
Cool, thank you :)
Arbalot:
Thank you Elmacik.
Navigation
[0] Message Index
Go to full version