Advertisement:

Author Topic: [TRICK] No attachment limits for admins  (Read 7768 times)

Offline Elmacik

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,280
  • Gender: Male
  • = Human Draft =
    • IT Store
[TRICK] No attachment limits for admins
« on: June 21, 2012, 05:10:53 AM »
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

Online Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,844
  • Master of BBC Abuse
Re: [TRICK] No attachment limits for admins
« Reply #1 on: June 21, 2012, 05:23:06 AM »
Nice one. :)

Offline Chalky

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,380
  • Gender: Female
  • If in doubt, give me beer...
    • ChalkCat
Re: [TRICK] No attachment limits for admins
« Reply #2 on: June 21, 2012, 03:46:57 PM »
Cool, thank you  :)

Offline Arbalot

  • SMF Hero
  • ******
  • Posts: 3,635
  • Gender: Male
  • SMF Hastası
    • SMF Destek
Re: [TRICK] No attachment limits for admins
« Reply #3 on: June 28, 2012, 04:37:44 AM »
Thank you Elmacik.

Offline Kolya

  • Full Member
  • ***
  • Posts: 433
  • systemshock.org
Re: [TRICK] No attachment limits for admins
« Reply #4 on: July 27, 2013, 07:29:48 AM »
This prevents Attachment Settings from being loaded correctly in the backend.

Online GL700Wing

  • Full Member
  • ***
  • Posts: 467
  • Gender: Female
Re: [TRICK] No attachment limits for admins
« Reply #5 on: July 27, 2013, 08:44:45 AM »
This prevents Attachment Settings from being loaded correctly in the backend.
Use this mod instead: http://custom.simplemachines.org/mods/index.php?mod=3621

Offline Elmacik

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,280
  • Gender: Male
  • = Human Draft =
    • IT Store
Re: [TRICK] No attachment limits for admins
« Reply #6 on: October 04, 2013, 03:49:17 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

Offline TomW

  • Jr. Member
  • **
  • Posts: 294
  • Gender: Male
Re: [TRICK] No attachment limits for admins
« Reply #7 on: October 24, 2013, 08:45:43 AM »
Very nice; I've needed this functionality in the past.  Works great on 2.0.6 !

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,859
  • Mod King
    • XPtsp.com Community
Re: [TRICK] No attachment limits for admins
« Reply #8 on: December 06, 2014, 11:55:50 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...