allowed attachments when posting
Posted: Fri Nov 06, 2009 8:24 pm
ever wanted to know what attachment types are allowed when you post, this is a nice little snippet that i found at this website
Joe Kovar III
all credit goes to the author!
here we go!
only took me about 4 minutes to install and works good!
the other thing about this snippet is,if you hover over the attachment type with your mouse it tell you the max size allowed!
Joe Kovar III
all credit goes to the author!
here we go!
Code: Select all
----[ OPEN ]----
styles/prosilver/template/posting_attach_body.html
----[ FIND ]----
<p>{L_ADD_ATTACHMENT_EXPLAIN}</p>
----[ AFTER ADD ]----
<p>{L_ALLOWED} {L_EXTENSION}:<!-- BEGIN allowed_extension --><!-- IF not allowed_extension.FIRST -->,<!-- ENDIF --> <acronym style="cursor:help;" title="{L_ALLOWED} {L_FILESIZE}: {allowed_extension.FILESIZE} {L_KB}">{allowed_extension.EXTENSION}</acronym><!-- END allowed_extension --></p>
----[ OPEN ]----
posting.php
----[ FIND ]----
// Attachment entry
----[ BEFORE ADD ]----
// Allowed extension list
$allowed_extensions = $cache->obtain_attach_extensions($forum_id);
unset($allowed_extensions['_allowed_']);
ksort($allowed_extensions);
$first_extension = true;
foreach($allowed_extensions as $ext => $vals)
{
if($vals['max_filesize'] == 0)
{
$vals['max_filesize'] = min(
eval('return ' . str_replace(array('k','m','g'), array('*1024','*1048576','*1073741824'), strtolower(trim(ini_get('upload_max_filesize')))) . ';'),
eval('return ' . str_replace(array('k','m','g'), array('*1024','*1048576','*1073741824'), strtolower(trim(ini_get('post_max_size')))) . ';')
);
}
$template->assign_block_vars('allowed_extension', array(
'FILESIZE' => number_format($vals['max_filesize'] / 1024, 2),
'EXTENSION' => $ext,
'FIRST' => $first_extension)
);
$first_extension = false;
}
----[ OPEN ]----
includes/ucp/ucp_pm.php
----[ FIND ]----
global $user, $template, $phpbb_root_path, $auth, $phpEx, $db, $config
----[ AFTER ADD ]----
, $cache
----[ FIND ]----
compose_pm($id, $mode, $action);
----[ AFTER ADD]----
// Allowed extension list
$allowed_extensions = $cache->obtain_attach_extensions(false);
unset($allowed_extensions['_allowed_']);
ksort($allowed_extensions);
$first_extension = true;
foreach($allowed_extensions as $ext => $vals)
{
if($vals['max_filesize'] == 0)
{
$vals['max_filesize'] = min(
eval('return ' . str_replace(array('k','m','g'), array('*1024','*1048576','*1073741824'), strtolower(trim(ini_get('upload_max_filesize')))) . ';'),
eval('return ' . str_replace(array('k','m','g'), array('*1024','*1048576','*1073741824'), strtolower(trim(ini_get('post_max_size')))) . ';')
);
}
$template->assign_block_vars('allowed_extension', array(
'FILESIZE' => number_format($vals['max_filesize'] / 1024, 2),
'EXTENSION' => $ext,
'FIRST' => $first_extension)
);
$first_extension = false;
}
----[ SAVE/CLOSE ALL FILES ]----
the other thing about this snippet is,if you hover over the attachment type with your mouse it tell you the max size allowed!