allowed attachments when posting

Tips & Tricks to use on your phpBB3 Forum.
Post Reply
User avatar
cisco007
Staff
Staff
Posts: 501
Joined: Tue Oct 07, 2008 3:44 am

allowed attachments when posting

Post by cisco007 » 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!

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 ]----


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!

User avatar
LDM
Site Admin
Site Admin
Posts: 1794
Joined: Thu May 29, 2008 6:51 pm

Re: allowed attachments when posting

Post by LDM » Fri Nov 06, 2009 10:27 pm

Cheers cisco, great little tip.

Post Reply