Customizing SMF > Tips and Tricks
No attachment limit for admins
forumite:
--- Quote from: seammer on July 04, 2005, 06:00:36 PM ---I couldn't find "Post.php" ANYWHERE...
--- End quote ---
It's in your Sources directory.
xenovanis:
--- Quote from: seammer 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... ???
--- End quote ---
Post.php is in the folder /Sources
rojamaia:
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: --- // 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']))
{
--- End code ---
reznorsoft:
--- Quote from: malinaobenny 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: --- // 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']))
{
--- End code ---
--- End quote ---
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: ---!$user_info['is_admin'] &&
--- End code ---
to the first part of the code
--- Code: ---// Is the file too big?
if (!empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
fatal_lang_error('smf122', false, array($modSettings['attachmentSizeLimit']));
--- End code ---
Peter Duggan:
--- Quote from: [Unknown] on September 26, 2004, 10:58:13 PM ---Post.php, find:
--- Code: ---if (!empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
--- End code ---
Replace:
--- Code: ---if (!$user_info['is_admin'] && !empty($modSettings['attachmentSizeLimit']) && $_FILES['attachment']['size'][$n] > $modSettings['attachmentSizeLimit'] * 1024)
--- End code ---
--- End quote ---
So what's changed here over the past 2+ years that might stop this working?
NB I'm aware of the following:
--- Quote from: [Unknown] on October 17, 2004, 04:02:35 PM ---Maybe it's your per-post limit?
--- End quote ---
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?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version