News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

No attachment limit for admins

Started by dschwab9, September 26, 2004, 10:51:06 PM

Previous topic - Next topic

bodyboard_jerez

Hi, I have the 1.1.2 version and this Tips and Tricks doesn't runs for me...

Please, could you help me? Thanks a lot "!"
Thank you to everybody of the SMF forum !!! Great help and free service !!

bodyboard_jerez

Quote from: bodyboard_jerez on May 28, 2007, 11:04:29 AM
Hi, I have the 1.1.2 version and this Tips and Tricks doesn't runs for me...

Please, could you help me? Thanks a lot "!"

Somebody does this trick runs on 1.1.2 version? How please?
Thank you to everybody of the SMF forum !!! Great help and free service !!

Kolya

For SMF 2.02 to exempt the admin from upload size limits and file extension checks: Basically just add !$user_info['is_admin'] && to all these checks...

In Sources/Post.php:
FIND:
if (!empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
fatal_lang_error('file_too_big', false, array($modSettings['attachmentSizeLimit']));

$quantity++;
if (!empty($modSettings['attachmentNumPerPostLimit']) && $quantity > $modSettings['attachmentNumPerPostLimit'])
fatal_lang_error('attachments_limit_per_post', false, array($modSettings['attachmentNumPerPostLimit']));

$total_size += $_FILES['attachment']['size'][$n];
if (!empty($modSettings['attachmentPostLimit']) && $total_size > $modSettings['attachmentPostLimit'] * 1024)
fatal_lang_error('file_too_big', false, array($modSettings['attachmentPostLimit']));

if (!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['cant_upload_type'] . ' ' . $modSettings['attachmentExtensions'] . '.', false);
}



REPLACE with:
if (!$user_info['is_admin'] && !empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
fatal_lang_error('file_too_big', false, array($modSettings['attachmentSizeLimit']));

$quantity++;
if (!$user_info['is_admin'] && !empty($modSettings['attachmentNumPerPostLimit']) && $quantity > $modSettings['attachmentNumPerPostLimit'])
fatal_lang_error('attachments_limit_per_post', false, array($modSettings['attachmentNumPerPostLimit']));

$total_size += $_FILES['attachment']['size'][$n];
if (!$user_info['is_admin'] && !empty($modSettings['attachmentPostLimit']) && $total_size > $modSettings['attachmentPostLimit'] * 1024)
fatal_lang_error('file_too_big', 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['cant_upload_type'] . ' ' . $modSettings['attachmentExtensions'] . '.', false);
}


FIND:
// Check the total upload size for this post...
$total_size += $_FILES['attachment']['size'][$n];
if (!empty($modSettings['attachmentPostLimit']) && $total_size > $modSettings['attachmentPostLimit'] * 1024)
{
checkSubmitOnce('free');
fatal_lang_error('file_too_big', false, array($modSettings['attachmentPostLimit']));
}


REPLACE with:
// 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)
{
checkSubmitOnce('free');
fatal_lang_error('file_too_big', false, array($modSettings['attachmentPostLimit']));
}

michaeloeser

Doesn´t seem to work for me. I´m the main and only administrator of my forum and although I made the changes to Post.php I´m not able to upload more and bigger files as defined in the attachment settings. Using SMF 2.0.2.

Any ideas?

Chalky

Quote from: michaeloeser on March 02, 2012, 04:19:05 AM
Doesn´t seem to work for me. I´m the main and only administrator of my forum and although I made the changes to Post.php I´m not able to upload more and bigger files as defined in the attachment settings. Using SMF 2.0.2.

Any ideas?

For me neither.  I'm using 2.0.2, just made exactly the edits shown above, but nothing happened...

searchgr


mybiafraland

"I don't know the key to success, but the key to failure is trying to please everybody." - Bill Cosby
on another note==>> Before sex.. you help each other get na'ked, after
sex you only dress yourself.... Moral of the story:
in life no one helps you once you're fuc'ked
My mentor's Blog hoping  my site beats nairaland someday

Kays

Hi, look in Subs-Post.php for the same set of checks and make the recommended change to those also.
Except, instead of !$user_info['is_admin'] use !$context['user']['is_admin']

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Elmacik

#28
Home of Elmacik

dougiefresh

#29
Quote from: Chalky on March 17, 2012, 10:48:23 AM
Quote from: michaeloeser on March 02, 2012, 04:19:05 AM
Doesn´t seem to work for me. I´m the main and only administrator of my forum and although I made the changes to Post.php I´m not able to upload more and bigger files as defined in the attachment settings. Using SMF 2.0.2.

Any ideas?

For me neither.  I'm using 2.0.2, just made exactly the edits shown above, but nothing happened...
The reason it doesn't work is it's incomplete.  Modifications must be made to the Themes/default/Post.template.php as well.... 



In Sources/Post.php, find and replace:
Code (find) Select
$context['num_allowed_attachments'] = empty($modSettings['attachmentNumPerPostLimit'])
Code (Replace) Select
$context['num_allowed_attachments'] = ($user_info['is_admin'] || empty($modSettings['attachmentNumPerPostLimit']))

In Sources/Subs-Post.php, find and replace:
Code (Find) Select
function createAttachment(&$attachmentOptions)
{
global

Code (Replace) Select
function createAttachment(&$attachmentOptions)
{
global $user_info,


Code (Find) Select
if (!empty($modSettings['attachmentSizeLimit']) && $attachmentOptions['size'] > $modSettings['attachmentSizeLimit'] * 1024)
Code (Replace) Select
if (!$user_info['is_admin'] && !empty($modSettings['attachmentSizeLimit']) && $attachmentOptions['size'] > $modSettings['attachmentSizeLimit'] * 1024)

In Themes/default/Post.template.php, find and replace these:
Code (Find) Select
function template_main()
{
global

Code (Replace) Select
function template_main()
{
global $user_info,


Code (Find) Select
if ($context['num_allowed_attachments'] > 1)]]></search>
Code (Replace) Select
if ($user_info['is_admin'] || $context['num_allowed_attachments'] > 1)

Code (Find) Select
var allowed_attachments = ', $context['num_allowed_attachments'], ';
Code (Replace) Select
var allowed_attachments = ', (empty($user_info['is_admin']) ? $context['num_allowed_attachments'] : 100), ';

Code (Find) Select
if (!empty($modSettings['attachmentCheckExtensions']))
Code (Replace) Select
if (!$user_info['is_admin'] && !empty($modSettings['attachmentCheckExtensions']))

Code (Find) Select
if (!empty($context['attachment_restrictions']))
Code (Replace) Select
if (!$user_info['is_admin'] && !empty($context['attachment_restrictions']))




I've posted up a mod based on this thread with all my modifications (9 operations total) here: No Attachment Limit for Admins.  It hasn't been approved yet....

dougiefresh

It occurs to me that the admin check could be converted into a permission-based group thingy.....

dougiefresh


alastairbrian

Quote from: bodyboard_jerez on May 28, 2007, 11:04:29 AM
Hi, I have the 1.1.2 version and this Tips and Tricks doesn't runs for me...

Please, could you help me? Thanks a lot "!"

It also not working for my version 1.1.2

Kindred

if you are running 1.1.2, you are 18 revisions behind and need to upgrade ASAP.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: