aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions.php4
-rw-r--r--phpBB/includes/functions_display.php21
-rw-r--r--phpBB/includes/functions_posting.php4
-rw-r--r--phpBB/includes/message_parser.php6
4 files changed, 22 insertions, 13 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index c31969aef4..fcb073a074 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -883,11 +883,13 @@ function obtain_attach_extensions(&$extensions)
{
$extension = strtolower(trim($row['extension']));
- $extensions['_allowed_'][] = $extension;
$extensions[$extension]['display_cat'] = (int) $row['cat_id'];
$extensions[$extension]['download_mode'] = (int) $row['download_mode'];
$extensions[$extension]['upload_icon'] = trim($row['upload_icon']);
$extensions[$extension]['max_filesize'] = (int) $row['max_filesize'];
+
+ // Store allowed extensions forum wise
+ $extensions['_allowed_'][$extension] = (!$row['allowed_forums']) ? 0 : unserialize(trim($row['allowed_forums']));
}
$db->sql_freeresult($result);
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index dc86e48ec9..2ba13d6939 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -331,7 +331,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
}
// Display Attachments
-function display_attachments($blockname, $attachment_data, &$update_count, $force_physical = false, $return = false)
+function display_attachments($forum_id, $blockname, $attachment_data, &$update_count, $force_physical = false, $return = false)
{
global $extensions, $template, $cache, $attachment_tpl;
global $config, $user, $phpbb_root_path, $phpEx, $SID;
@@ -409,11 +409,11 @@ function display_attachments($blockname, $attachment_data, &$update_count, $forc
$display_name = $attachment['real_filename'];
$comment = str_replace("\n", '<br />', censor_text($attachment['comment']));
- $denied = FALSE;
+ $denied = false;
- if (!in_array($attachment['extension'], $extensions['_allowed_']))
+ if ((is_array($extensions['_allowed_'][$attachment['extension']]) && !in_array($forum_id, $extensions['_allowed_'][$attachment['extension']])) || !isset($extensions['_allowed_'][$attachment['extension']]))
{
- $denied = TRUE;
+ $denied = true;
$template_array['VAR'] = array('{L_DENIED}');
$template_array['VAL'] = array(sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
@@ -423,9 +423,16 @@ function display_attachments($blockname, $attachment_data, &$update_count, $forc
// Replace {L_*} lang strings
$tpl = preg_replace('/{L_([A-Z_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $tpl);
- $template->assign_block_vars($blockname, array(
- 'SHOW_ATTACHMENT' => $tpl)
- );
+ if (!$return)
+ {
+ $template->assign_block_vars($blockname, array(
+ 'DISPLAY_ATTACHMENT' => $tpl)
+ );
+ }
+ else
+ {
+ $return_tpl[] = $tpl;
+ }
}
if (!$denied)
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 23bcbd25d4..4c5a3d4c69 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -162,7 +162,7 @@ function update_last_post_information($type, $id)
}
// Upload Attachment - filedata is generated here
-function upload_attachment($filename, $local = false, $local_storage = '')
+function upload_attachment($forum_id, $filename, $local = false, $local_storage = '')
{
global $auth, $user, $config, $db;
@@ -188,7 +188,7 @@ function upload_attachment($filename, $local = false, $local_storage = '')
obtain_attach_extensions($extensions);
// Check Extension
- if (!in_array($filedata['extension'], $extensions['_allowed_']))
+ if ((is_array($extensions['_allowed_'][$filedata['extension']]) && !in_array($forum_id, $extensions['_allowed_'][$filedata['extension']])) || !isset($extensions['_allowed_'][$filedata['extension']]))
{
$filedata['error'][] = sprintf($user->lang['DISALLOWED_EXTENSION'], $filedata['extension']);
$filedata['post_attach'] = false;
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 33a3c5ac30..b1f272eefa 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -706,7 +706,7 @@ class parse_message
// Parse Attachments
function parse_attachments($mode, $post_id, $submit, $preview, $refresh)
{
- global $config, $auth, $user;
+ global $config, $auth, $user, $forum_id;
global $_FILES, $_POST;
$error = array();
@@ -723,7 +723,7 @@ class parse_message
{
if ($num_attachments < $config['max_attachments'] || $auth->acl_gets('m_', 'a_'))
{
- $filedata = upload_attachment($this->filename_data['filename']);
+ $filedata = upload_attachment($forum_id, $this->filename_data['filename']);
$error = $filedata['error'];
@@ -807,7 +807,7 @@ class parse_message
{
if ($num_attachments < $config['max_attachments'] || $auth->acl_gets('m_', 'a_'))
{
- $filedata = upload_attachment($this->filename_data['filename']);
+ $filedata = upload_attachment($forum_id, $this->filename_data['filename']);
$error = array_merge($error, $filedata['error']);