Advertisement:

Author Topic: No attachment limit for admins  (Read 57155 times)

Offline dschwab9

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,320
  • Gender: Male
    • Technology, Ministry and Other Ramblings
No attachment limit for admins
« on: September 26, 2004, 10:51:06 PM »
I would like to be able to have the file size/extension limits not apply to admins.  Is this easy to do?  There's times I need to upload a couple of meg zip or something, but I don't want to give the world access to do that.  I've been changing the limit, uploading the file, then changing it back.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: No attachment limit for admins
« Reply #1 on: September 26, 2004, 10:58:13 PM »
Post.php, find:
Code: [Select]
if (!empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
Replace:
Code: [Select]
if (!$user_info['is_admin'] && !empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
-[Unknown]

Offline dschwab9

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,320
  • Gender: Male
    • Technology, Ministry and Other Ramblings
Re: No attachment limit for admins
« Reply #2 on: September 26, 2004, 11:10:58 PM »
Perfect!  Thanks

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,702
  • xxx
Re: No attachment limit for admins
« Reply #3 on: September 27, 2004, 09:47:27 AM »
This should be in tips and tricks ;).
Liverpool FC Forum with 14 million+ posts.

Offline dschwab9

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,320
  • Gender: Male
    • Technology, Ministry and Other Ramblings
Re: No attachment limit for admins
« Reply #4 on: September 27, 2004, 05:48:27 PM »
This should be in tips and tricks ;).

Well, can you move it there?

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,702
  • xxx
Re: No attachment limit for admins
« Reply #5 on: September 27, 2004, 05:56:13 PM »
Would if I could, my post was a suggestion for someone with move powers, I dont have them :(.

[edit]
Someone did  ;D
[/edit]
Liverpool FC Forum with 14 million+ posts.

CarLBanks

  • Guest
Re: No attachment limit for admins
« Reply #6 on: October 16, 2004, 04:21:34 PM »
I still can't upload anything over 192.

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,702
  • xxx
Re: No attachment limit for admins
« Reply #7 on: October 17, 2004, 09:56:44 AM »
Same here, comes back with

 Your file is too large. The maximum attachment size allowed is 192 KB.

My max attachment setting is 100KB so dunno where it gets 192 KB from.
Liverpool FC Forum with 14 million+ posts.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: No attachment limit for admins
« Reply #8 on: October 17, 2004, 04:02:35 PM »
Maybe it's your per-post limit?

-[Unknown]

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,702
  • xxx
Re: No attachment limit for admins
« Reply #9 on: October 17, 2004, 07:25:09 PM »
Not sure what you mean by per post limit?
Liverpool FC Forum with 14 million+ posts.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: No attachment limit for admins
« Reply #10 on: October 17, 2004, 07:45:41 PM »
Please consult your attachment settings.

-[Unknown]

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,702
  • xxx
Re: No attachment limit for admins
« Reply #11 on: October 17, 2004, 07:52:26 PM »
Doh, never seen that one before. thats two new things I've learnt today.

Have now set it suitably high, thanks for that.
Liverpool FC Forum with 14 million+ posts.

Offline forumite

  • Charter Member
  • Full Member
  • *
  • Posts: 408
    • The RV Forum
Re: No attachment limit for admins
« Reply #12 on: May 28, 2005, 01:12:07 PM »
Post.php, find:

I've just found this topic, so apologies for the late question.

I can find Post.template.php but can't find Post.php  Which sub-directory would it be in?

TIA

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: No attachment limit for admins
« Reply #13 on: May 28, 2005, 01:27:12 PM »

Offline seammer

  • Newbie
  • *
  • Posts: 7
Re: No attachment limit for admins
« Reply #14 on: July 04, 2005, 06:00:36 PM »
I'm watching this topic, as I couldn't find "Post.php" ANYWHERE...

I'm very new to SMF forums... ???

Offline forumite

  • Charter Member
  • Full Member
  • *
  • Posts: 408
    • The RV Forum
Re: No attachment limit for admins
« Reply #15 on: July 05, 2005, 12:53:38 AM »
I couldn't find "Post.php" ANYWHERE...

It's in your Sources directory.

Offline xenovanis

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,988
  • Gender: Female
Re: No attachment limit for admins
« Reply #16 on: July 05, 2005, 02:03:48 AM »
I'm watching this topic, as I couldn't find "Post.php" ANYWHERE...

I'm very new to SMF forums... ???

Post.php is in the folder /Sources
"Insanity: doing the same thing over and over again and expecting different results."

Offline rojamaia

  • Semi-Newbie
  • *
  • Posts: 83
Re: No attachment limit for admins
« Reply #17 on: August 27, 2005, 08:23:55 AM »


i thought that if we should edit it, it should not just be for the over-all attachment limit, but edit more of the code below that, to allow more permissions to the admin.

would this be alright?

Code: [Select]
// Is the file too big?
if (!empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
fatal_lang_error('smf122', false, array($modSettings['attachmentSizeLimit']));

// Have we reached the maximum number of files we are allowed?
$quantity++;
if (!$user_info['is_admin'] && !empty($modSettings['attachmentNumPerPostLimit']) && $quantity > $modSettings['attachmentNumPerPostLimit'])
fatal_lang_error('attachments_limit_per_post', false, array($modSettings['attachmentNumPerPostLimit']));

// Check the total upload size for this post...
$total_size += $_FILES['attachment']['size'][$n];
if (!$user_info['is_admin'] && !empty($modSettings['attachmentPostLimit']) && $total_size > $modSettings['attachmentPostLimit'] * 1024)
fatal_lang_error('smf122', false, array($modSettings['attachmentPostLimit']));

if (!$user_info['is_admin'] && !empty($modSettings['attachmentCheckExtensions']))
{
if (!in_array(strtolower(substr(strrchr($_FILES['attachment']['name'][$n], '.'), 1)), explode(',', strtolower($modSettings['attachmentExtensions']))))
fatal_error($_FILES['attachment']['name'][$n] . '.<br />' . $txt['smf123'] . ' ' . $modSettings['attachmentExtensions'] . '.', false);
}

if (!$user_info['is_admin'] && !empty($modSettings['attachmentDirSizeLimit']))
{
// Make sure the directory isn't full.
$dirSize = 0;
$dir = @opendir($modSettings['attachmentUploadDir']) or fatal_lang_error('smf115b');
while ($file = readdir($dir))
{
if (substr($file, 0, -1) == '.')
continue;

$dirSize += filesize($modSettings['attachmentUploadDir'] . '/' . $file);
}
closedir($dir);

// Too big!  Maybe you could zip it or something...
if ($_FILES['attachment']['size'][$n] + $dirSize > $modSettings['attachmentDirSizeLimit'] * 1024)
fatal_lang_error('smf126');
}

// Find the filename, strip the dir.
$destName = basename($_FILES['attachment']['name'][$n]);

// Check if the file already exists.... (for those who do not encrypt their filenames...)
if (!$user_info['is_admin'] && !empty($modSettings['attachmentEncryptFilenames']))
{

Offline reznorsoft

  • Jr. Member
  • **
  • Posts: 252
  • Gender: Male
Re: No attachment limit for admins
« Reply #18 on: October 21, 2005, 12:17:10 PM »


i thought that if we should edit it, it should not just be for the over-all attachment limit, but edit more of the code below that, to allow more permissions to the admin.

would this be alright?

Code: [Select]
// Is the file too big?
if (!empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
fatal_lang_error('smf122', false, array($modSettings['attachmentSizeLimit']));

// Have we reached the maximum number of files we are allowed?
$quantity++;
if (!$user_info['is_admin'] && !empty($modSettings['attachmentNumPerPostLimit']) && $quantity > $modSettings['attachmentNumPerPostLimit'])
fatal_lang_error('attachments_limit_per_post', false, array($modSettings['attachmentNumPerPostLimit']));

// Check the total upload size for this post...
$total_size += $_FILES['attachment']['size'][$n];
if (!$user_info['is_admin'] && !empty($modSettings['attachmentPostLimit']) && $total_size > $modSettings['attachmentPostLimit'] * 1024)
fatal_lang_error('smf122', false, array($modSettings['attachmentPostLimit']));

if (!$user_info['is_admin'] && !empty($modSettings['attachmentCheckExtensions']))
{
if (!in_array(strtolower(substr(strrchr($_FILES['attachment']['name'][$n], '.'), 1)), explode(',', strtolower($modSettings['attachmentExtensions']))))
fatal_error($_FILES['attachment']['name'][$n] . '.<br />' . $txt['smf123'] . ' ' . $modSettings['attachmentExtensions'] . '.', false);
}

if (!$user_info['is_admin'] && !empty($modSettings['attachmentDirSizeLimit']))
{
// Make sure the directory isn't full.
$dirSize = 0;
$dir = @opendir($modSettings['attachmentUploadDir']) or fatal_lang_error('smf115b');
while ($file = readdir($dir))
{
if (substr($file, 0, -1) == '.')
continue;

$dirSize += filesize($modSettings['attachmentUploadDir'] . '/' . $file);
}
closedir($dir);

// Too big!  Maybe you could zip it or something...
if ($_FILES['attachment']['size'][$n] + $dirSize > $modSettings['attachmentDirSizeLimit'] * 1024)
fatal_lang_error('smf126');
}

// Find the filename, strip the dir.
$destName = basename($_FILES['attachment']['name'][$n]);

// Check if the file already exists.... (for those who do not encrypt their filenames...)
if (!$user_info['is_admin'] && !empty($modSettings['attachmentEncryptFilenames']))
{
I was thinking of doing the exact same thing .. I don't see why it wouldn't work .. guess I'm about to find out  ;)

though it seems you didn't add the string
Code: [Select]
!$user_info['is_admin'] && to the first part of the code
Code: [Select]
// Is the file too big?
if (!empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
fatal_lang_error('smf122', false, array($modSettings['attachmentSizeLimit']));
« Last Edit: October 21, 2005, 12:21:03 PM by reznorsoft »

Offline Peter Duggan

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,663
  • Gender: Male
    • Peat Stack or Pete's Tack?
Re: No attachment limit for admins
« Reply #19 on: February 17, 2007, 04:59:54 AM »
Post.php, find:
Code: [Select]
if (!empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
Replace:
Code: [Select]
if (!$user_info['is_admin'] && !empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)

So what's changed here over the past 2+ years that might stop this working?

NB I'm aware of the following:

Maybe it's your per-post limit?

But still can't attach a 600K image with per post limit of 2000K and max attachment size of 200K 'disabled' as suggested above for admins (so that line at least remains unchanged since 2004!) and suspect there may now be some additional limiting factor?