diff --git a/phpBB/adm/admin_attachments.php b/phpBB/adm/admin_attachments.php
index 39e1bb8c3f..a48c62fba7 100644
--- a/phpBB/adm/admin_attachments.php
+++ b/phpBB/adm/admin_attachments.php
@@ -121,7 +121,7 @@ while ($row = $db->sql_fetchrow($result))
if ($submit && ($mode == 'manage' || $mode == 'cats'))
{
- add_log('admin', 'LOG_SETTING_CONFIG');
+ add_log('admin', 'LOG_ATTACH_CONFIG');
$notify = TRUE;
$notify_msg = $user->lang['ATTACH_CONFIG_UPDATED'];
}
@@ -152,6 +152,9 @@ switch ($mode)
case 'cats':
$l_title = 'MANAGE_CATEGORIES';
break;
+
+ case 'ext_groups':
+ $l_title = 'EXTENSION_GROUPS_TITLE';
}
// Temporary Language Variables
@@ -214,6 +217,162 @@ if ($submit && $mode == 'cats')
test_upload($error, $error_msg, $upload_dir, $new['ftp_path'] . '/thumbs', $new['allow_ftp_upload'], true);
}
+if ($submit && $mode == 'ext_groups')
+{
+ // Change Extension Groups ?
+ $group_change_list = ( isset($_POST['group_change_list']) ) ? $_POST['group_change_list'] : array();
+ $extension_group_list = ( isset($_POST['extension_group_list']) ) ? $_POST['extension_group_list'] : array();
+ $group_allowed_list = ( isset($_POST['allowed_list']) ) ? $_POST['allowed_list'] : array();
+ $download_mode_list = ( isset($_POST['download_mode_list']) ) ? $_POST['download_mode_list'] : array();
+ $category_list = ( isset($_POST['category_list']) ) ? $_POST['category_list'] : array();
+ $upload_icon_list = ( isset($_POST['upload_icon_list']) ) ? $_POST['upload_icon_list'] : array();
+ $filesize_list = ( isset($_POST['max_filesize_list']) ) ? $_POST['max_filesize_list'] : array();
+ $size_select_list = ( isset($_POST['size_select_list']) ) ? $_POST['size_select_list'] : array();
+
+ $allowed_list = array();
+
+ for ($i = 0; $i < count($group_allowed_list); $i++)
+ {
+ for ($j = 0; $j < count($group_change_list); $j++)
+ {
+ if ($group_allowed_list[$i] == $group_change_list[$j])
+ {
+ $allowed_list[$j] = '1';
+ }
+ }
+ }
+
+ for ($i = 0; $i < count($group_change_list); $i++)
+ {
+ $allowed = ( isset($allowed_list[$i]) ) ? 1 : 0;
+
+ $filesize_list[$i] = ( $size_select_list[$i] == 'kb' ) ? round($filesize_list[$i] * 1024) : ( ($size_select_list[$i] == 'mb') ? round($filesize_list[$i] * 1048576) : $filesize_list[$i] );
+
+ $group_sql = array(
+ 'group_name' => $extension_group_list[$i],
+ 'cat_id' => $category_list[$i],
+ 'allow_group' => $allowed,
+ 'download_mode' => $download_mode_list[$i],
+ 'upload_icon' => ($upload_icon_list[$i] == 'no_image') ? '' : $upload_icon_list[$i],
+ 'max_filesize' => $filesize_list[$i]
+ );
+
+ $sql = "UPDATE " . EXTENSION_GROUPS_TABLE . " SET " . $db->sql_build_array('UPDATE', $group_sql) . " WHERE group_id = " . $group_change_list[$i];
+ $db->sql_query($sql);
+ }
+
+ // Delete Extension Groups
+ $group_id_list = ( isset($_POST['group_id_list']) ) ? $_POST['group_id_list'] : array();
+
+ if (count($group_id_list))
+ {
+ $l_group_list = '';
+
+ $sql = "SELECT group_name
+ FROM " . EXTENSION_GROUPS_TABLE . "
+ WHERE group_id IN (" . implode(', ', $group_id_list) . ")";
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $l_group_list .= (($l_group_list != '') ? ', ' : '') . $row['group_name'];
+ }
+ $db->sql_freeresult($result);
+
+ $sql = "DELETE
+ FROM " . EXTENSION_GROUPS_TABLE . "
+ WHERE group_id IN (" . implode(', ', $group_id_list) . ")";
+ $db->sql_query($sql);
+
+ // Set corresponding Extensions to a pending Group
+ $sql = "UPDATE " . EXTENSIONS_TABLE . "
+ SET group_id = 0
+ WHERE group_id IN (" . implode(', ', $group_id_list) . ")";
+ $db->sql_query($sql);
+
+ add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $l_group_list);
+ }
+
+ // Add Extensions Group ?
+ $extension_group = ( isset($_POST['add_extension_group']) ) ? trim(strip_tags($_POST['add_extension_group'])) : '';
+ $download_mode = ( isset($_POST['add_download_mode']) ) ? $_POST['add_download_mode'] : '';
+ $cat_id = ( isset($_POST['add_category']) ) ? $_POST['add_category'] : '';
+ $upload_icon = ( isset($_POST['add_upload_icon']) ) ? $_POST['add_upload_icon'] : '';
+ $filesize = ( isset($_POST['add_max_filesize']) ) ? $_POST['add_max_filesize'] : '';
+ $size_select = ( isset($_POST['add_size_select']) ) ? $_POST['add_size_select'] : '';
+ $is_allowed = ( isset($_POST['add_allowed']) ) ? 1 : 0;
+ $add = ( isset($_POST['add_extension_group_check']) ) ? TRUE : FALSE;
+
+ if ($extension_group != '' && $add)
+ {
+ // check Extension Group
+ $sql = "SELECT group_name
+ FROM " . EXTENSION_GROUPS_TABLE;
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($row['group_name'] == $extension_group)
+ {
+ $error = TRUE;
+ if (isset($error_msg))
+ {
+ $error_msg .= '
';
+ }
+ $error_msg .= sprintf($user->lang['EXTENSION_GROUP_EXIST'], $extension_group);
+ }
+ }
+ $db->sql_freeresult($result);
+
+ if (!$error)
+ {
+ $filesize = ($size_select == 'kb') ? round($filesize * 1024) : (($size_select == 'mb') ? round($filesize * 1048576) : $filesize);
+
+ $group_sql = array(
+ 'group_name' => $extension_group,
+ 'cat_id' => $cat_id,
+ 'allow_group' => $is_allowed,
+ 'download_mode' => $download_mode,
+ 'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon,
+ 'max_filesize' => $filesize
+ );
+
+ $sql = "INSERT INTO " . EXTENSION_GROUPS_TABLE . " " . $db->sql_build_array('INSERT', $group_sql);
+ $db->sql_query($sql);
+
+ add_log('admin', 'LOG_ATTACH_EXTGROUP_ADD', $extension_group);
+ }
+ }
+
+ $sql = "SELECT e.extension, g.*
+ FROM " . EXTENSIONS_TABLE . " e, " . EXTENSION_GROUPS_TABLE . " g
+ WHERE e.group_id = g.group_id
+ AND g.allow_group = 1";
+ $result = $db->sql_query($sql);
+
+ $extensions = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $extension = strtolower(trim($row['extension']));
+
+ $extensions['_allowed_'][] = $extension;
+ $extensions[$extension]['display_cat'] = intval($row['cat_id']);
+ $extensions[$extension]['download_mode'] = intval($row['download_mode']);
+ $extensions[$extension]['upload_icon'] = trim($row['upload_icon']);
+ $extensions[$extension]['max_filesize'] = intval($row['max_filesize']);
+ }
+ $db->sql_freeresult($result);
+
+ $cache->destroy('extensions');
+ $cache->put('extensions', $extensions);
+
+ if (!$error)
+ {
+ $notify = true;
+ $notify_msg = $user->lang['EXTENSION_GROUPS_UPDATED'];
+ }
+}
+
?>
lang[$l_title]; ?>
@@ -242,7 +401,7 @@ else if ($notify)
|
-
-
-
-
+
|
-
-
-
+
lang['BYTES'], $user->lang['KB'], $user->lang['MB']);
- $size_types = array('b', 'kb', 'mb');
+ $imglist = filelist($phpbb_root_path . $img_path, '');
- $select_field = '';
+ $size = isset($_REQUEST['size']) ? intval($_REQUEST['size']) : 0;
+
+ if (!$size && !$submit)
+ {
+ $max_add_filesize = intval($config['max_filesize']);
+ $size = ($max_add_filesize >= 1048576) ? 'mb' : ( ($max_add_filesize >= 1024) ? 'kb' : 'b' );
+ }
+
+ if ($max_add_filesize >= 1048576)
+ {
+ $max_add_filesize = round($max_add_filesize / 1048576 * 100) / 100;
+ }
+ else if ( $max_add_filesize >= 1024)
+ {
+ $max_add_filesize = round($max_add_filesize / 1024 * 100) / 100;
+ }
+
+ $viewgroup = (!empty($_REQUEST['g'])) ? $_REQUEST['g'] : -1;
+?>
+
+
+
+
+
- return ($select_field);
}
+?>
+
+
+
+
+
+lang['BYTES'], $user->lang['KB'], $user->lang['MB']);
+ $size_types = array('b', 'kb', 'mb');
+
+ $select_field = '';
+
+ return ($select_field);
+}
+
+// Build Select for category items
+function category_select($select_name, $group_id = -1)
+{
+ global $db, $user;
+
+ $types = array(
+ NONE_CAT => $user->lang['NONE'],
+ IMAGE_CAT => $user->lang['CAT_IMAGES'],
+ WM_CAT => $user->lang['CAT_WM_FILES'],
+ RM_CAT => $user->lang['CAT_RM_FILES']
+ );
+
+ if ($group_id != -1)
+ {
+ $sql = "SELECT cat_id
+ FROM " . EXTENSION_GROUPS_TABLE . "
+ WHERE group_id = " . intval($group_id);
+ $result = $db->sql_query($sql);
+
+ if (!($row = $db->sql_fetchrow($result)))
+ {
+ $cat_type = NONE_CAT;
+ }
+ else
+ {
+ $cat_type = $row['cat_id'];
+ }
+
+ $db->sql_freeresult($result);
+ }
+ else
+ {
+ $cat_type = NONE_CAT;
+ }
+
+ $group_select = '';
+
+ return($group_select);
+}
+
+// Build select for download modes
+
+function download_select($select_name, $group_id = -1)
+{
+ global $db, $user;
+
+ $types = array(
+ INLINE_LINK => $user->lang['MODE_INLINE'],
+ PHYSICAL_LINK => $user->lang['MODE_PHYSICAL']
+ );
+
+ if ($group_id != -1)
+ {
+ $sql = "SELECT download_mode
+ FROM " . EXTENSION_GROUPS_TABLE . "
+ WHERE group_id = " . intval($group_id);
+ $result = $db->sql_query($sql);
+
+ if (!($row = $db->sql_fetchrow($result)))
+ {
+ $download_mode = INLINE_LINK;
+ }
+ else
+ {
+ $download_mode = $row['download_mode'];
+ }
+
+ $db->sql_freeresult($result);
+ }
+ else
+ {
+ $download_mode = INLINE_LINK;
+ }
+
+ $group_select = '';
+
+ return($group_select);
+}
+
// Get supported Image types
function get_supported_image_types()
{
@@ -657,4 +1114,31 @@ function get_supported_image_types()
return ($types);
}
+function filelist($rootdir, $dir = '', $type = 'gif|jpg|png')
+{
+ static $images = array();
+
+ $dh = opendir($rootdir . $dir);
+
+ while ($fname = readdir($dh))
+ {
+ if (is_file($rootdir . $dir . '/' . $fname) &&
+ preg_match('#\.' . $type . '$#i', $fname) &&
+ filesize($rootdir . $dir . '/' . $fname))
+ {
+ $images[] = array('path' => $dir, 'file' => $fname);
+ }
+ else if ($fname != '.' && $fname != '..' &&
+ !is_file($rootdir . $dir . '/' . $fname) &&
+ !is_link($rootdir . $dir . '/' . $fname))
+ {
+ filelist($rootdir, $dir . '/'. $fname, $type);
+ }
+ }
+
+ closedir($dh);
+
+ return $images;
+}
+
?>
\ No newline at end of file
diff --git a/phpBB/download.php b/phpBB/download.php
index a41b040c4e..42753a5d11 100644
--- a/phpBB/download.php
+++ b/phpBB/download.php
@@ -198,16 +198,12 @@ function send_file_to_browser($real_filename, $mimetype, $physical_filename, $up
header('Content-Transfer-Encoding: none');
// Send out the Headers
- if ($browser_agent == 'ie')
- {
- header('Content-Type: ' . $mimetype);
- header('Content-Disposition: inline; filename="' . $real_filename . '"');
- }
- else
- {
+ header('Content-Type: ' . $mimetype . '; name="' . $real_filename . '"');
+ header('Content-Disposition: inline; filename="' . $real_filename . '"');
+/*
header('Content-Type: ' . $mimetype . '; name="' . $real_filename . '"');
header('Content-Disposition: attachment; filename=' . $real_filename);
- }
+*/
// Now send the File Contents to the Browser
if ($gotit)
diff --git a/phpBB/images/upload_icons/avi.gif b/phpBB/images/upload_icons/avi.gif
new file mode 100644
index 0000000000..55f2116261
Binary files /dev/null and b/phpBB/images/upload_icons/avi.gif differ
diff --git a/phpBB/images/upload_icons/bmp.gif b/phpBB/images/upload_icons/bmp.gif
new file mode 100644
index 0000000000..abd05713ef
Binary files /dev/null and b/phpBB/images/upload_icons/bmp.gif differ
diff --git a/phpBB/images/upload_icons/doc.gif b/phpBB/images/upload_icons/doc.gif
new file mode 100644
index 0000000000..078d9f7a14
Binary files /dev/null and b/phpBB/images/upload_icons/doc.gif differ
diff --git a/phpBB/images/upload_icons/exe.gif b/phpBB/images/upload_icons/exe.gif
new file mode 100644
index 0000000000..b77dd4dcec
Binary files /dev/null and b/phpBB/images/upload_icons/exe.gif differ
diff --git a/phpBB/images/upload_icons/flash.gif b/phpBB/images/upload_icons/flash.gif
new file mode 100644
index 0000000000..00ee0f4f72
Binary files /dev/null and b/phpBB/images/upload_icons/flash.gif differ
diff --git a/phpBB/images/upload_icons/gif.gif b/phpBB/images/upload_icons/gif.gif
new file mode 100644
index 0000000000..5aa8d463e7
Binary files /dev/null and b/phpBB/images/upload_icons/gif.gif differ
diff --git a/phpBB/images/upload_icons/html.gif b/phpBB/images/upload_icons/html.gif
new file mode 100644
index 0000000000..eb948eae6a
Binary files /dev/null and b/phpBB/images/upload_icons/html.gif differ
diff --git a/phpBB/images/upload_icons/jpg.gif b/phpBB/images/upload_icons/jpg.gif
new file mode 100644
index 0000000000..537de1c3a0
Binary files /dev/null and b/phpBB/images/upload_icons/jpg.gif differ
diff --git a/phpBB/images/upload_icons/mid.gif b/phpBB/images/upload_icons/mid.gif
new file mode 100644
index 0000000000..ea7302cb16
Binary files /dev/null and b/phpBB/images/upload_icons/mid.gif differ
diff --git a/phpBB/images/upload_icons/mov.gif b/phpBB/images/upload_icons/mov.gif
new file mode 100644
index 0000000000..55f2116261
Binary files /dev/null and b/phpBB/images/upload_icons/mov.gif differ
diff --git a/phpBB/images/upload_icons/mp3.gif b/phpBB/images/upload_icons/mp3.gif
new file mode 100644
index 0000000000..acf1a5015f
Binary files /dev/null and b/phpBB/images/upload_icons/mp3.gif differ
diff --git a/phpBB/images/upload_icons/mpg.gif b/phpBB/images/upload_icons/mpg.gif
new file mode 100644
index 0000000000..55f2116261
Binary files /dev/null and b/phpBB/images/upload_icons/mpg.gif differ
diff --git a/phpBB/images/upload_icons/netscape.gif b/phpBB/images/upload_icons/netscape.gif
new file mode 100644
index 0000000000..0854440952
Binary files /dev/null and b/phpBB/images/upload_icons/netscape.gif differ
diff --git a/phpBB/images/upload_icons/pdf.gif b/phpBB/images/upload_icons/pdf.gif
new file mode 100644
index 0000000000..8d0603ae65
Binary files /dev/null and b/phpBB/images/upload_icons/pdf.gif differ
diff --git a/phpBB/images/upload_icons/ppt.gif b/phpBB/images/upload_icons/ppt.gif
new file mode 100644
index 0000000000..a3800d12c6
Binary files /dev/null and b/phpBB/images/upload_icons/ppt.gif differ
diff --git a/phpBB/images/upload_icons/rar.gif b/phpBB/images/upload_icons/rar.gif
new file mode 100644
index 0000000000..9c0bd5667e
Binary files /dev/null and b/phpBB/images/upload_icons/rar.gif differ
diff --git a/phpBB/images/upload_icons/txt.gif b/phpBB/images/upload_icons/txt.gif
new file mode 100644
index 0000000000..cc3639b89c
Binary files /dev/null and b/phpBB/images/upload_icons/txt.gif differ
diff --git a/phpBB/images/upload_icons/wav.gif b/phpBB/images/upload_icons/wav.gif
new file mode 100644
index 0000000000..21195252b7
Binary files /dev/null and b/phpBB/images/upload_icons/wav.gif differ
diff --git a/phpBB/images/upload_icons/xls.gif b/phpBB/images/upload_icons/xls.gif
new file mode 100644
index 0000000000..187a19b53c
Binary files /dev/null and b/phpBB/images/upload_icons/xls.gif differ
diff --git a/phpBB/images/upload_icons/zip.gif b/phpBB/images/upload_icons/zip.gif
new file mode 100644
index 0000000000..0141376100
Binary files /dev/null and b/phpBB/images/upload_icons/zip.gif differ
diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php
index d8e9b16974..19aaf3565d 100644
--- a/phpBB/language/en/lang_admin.php
+++ b/phpBB/language/en/lang_admin.php
@@ -124,6 +124,7 @@ $lang = array_merge($lang, array(
'LOG_EMAIL_CONFIG' => 'Altered email settings',
'LOG_AVATAR_CONFIG' => 'Altered avatar settings',
'LOG_AUTH_CONFIG' => 'Altered authentication settings',
+ 'LOG_ATTACH_CONFIG' => 'Altered attachment settings',
'log_prune_user_deac' => 'Users Deactivated
%s',
'log_prune_user_del_del'=> 'Users Pruned and Posts Deleted
%s',
'log_prune_user_del_anon'=> 'Users Pruned and Posts Retained
%s',
@@ -142,6 +143,10 @@ $lang = array_merge($lang, array(
'LOG_ACL_GROUP_ADD' => 'Edited Group permissions
» %s',
'LOG_ACL_PRESET_ADD' => 'Added or edited permission preset
» %s',
'LOG_ACL_PRESET_DEL' => 'Deleted permission preset
» %s',
+ 'LOG_ATTACH_EXT_ADD' => 'Added or edited attachment extension
» %s',
+ 'LOG_ATTACH_EXT_DEL' => 'Removed attachment extension
» %s',
+ 'LOG_ATTACH_EXTGROUP_ADD' => 'Added or edited extension group
» %s',
+ 'LOG_ATTACH_EXTGROUP_DEL' => 'Removed extension group
» %s',
'RUN_HOW' => 'When to run',
'RUN_AS_NOW'=> 'Run now',
@@ -882,6 +887,7 @@ $lang = array_merge($lang, array(
'ATTACH_MANAGE_URL' => 'Configuration',
'ATTACH_CATS_URL' => 'Special Categories',
'ATTACH_EXTENSIONS_URL' => 'Extensions',
+ 'ATTACH_EXT_GROUPS_URL' => 'Extension Groups',
'ATTACHMENT_SETTINGS' => 'Attachment Settings',
'ATTACHMENT_CONFIG_EXPLAIN' => 'Here you can configure the Main Settings for Attachments and the associated Special Categories.',
@@ -947,6 +953,25 @@ $lang = array_merge($lang, array(
'IMAGE_LINK_SIZE' => 'Image Link Dimensions',
'IMAGE_LINK_SIZE_EXPLAIN' => 'If this defined Dimension of an Image is reached, the Image will be displayed as a Link, rather than displaying it inlined,
if Inline View is enabled (Width x Height in pixels).
If it is set to 0x0, this feature is disabled. With some Images this Feature will not work due to limitations in PHP.',
+ 'EXTENSION_GROUPS_TITLE' => 'Manage Extension Groups',
+ 'EXTENSION_GROUPS_TITLE_EXPLAIN' => 'Here you can add, delete and modify your Extension Groups, you can disable Extension Groups, assign a special Category to them, change the download mechanism and you can define an Upload Icon which will be displayed in front of an Attachment belonging to the Group.',
+ 'EXTENSION_GROUPS' => 'Extension groups',
+ 'EXTENSION_GROUP' => 'Extension group',
+ 'SPECIAL_CATEGORY' => 'Special category',
+ 'DOWNLOAD_MODE' => 'Download mode',
+ 'UPLOAD_ICON' => 'Upload icon',
+ 'MAX_EXTGROUP_FILESIZE' => 'Maximum filesize',
+ 'ADD_EXTGROUP' => 'Add extension group',
+
+ 'CAT_IMAGES' => 'Images',
+ 'CAT_WM_FILES' => 'Win Media Streams',
+ 'CAT_RM_FILES' => 'Real Media Streams',
+ 'MODE_INLINE' => 'Inline',
+ 'MODE_PHYSICAL' => 'Physical',
+ 'NO_IMAGE' => 'No Image',
+ 'EXTENSION_GROUPS_UPDATED' => 'Extension Groups updated successfully',
+ 'EXTENSION_GROUP_EXIST' => 'The Extension Group %s already exist',
+
'WELCOME_INSTALL' => 'Welcome to phpBB 2 Installation',
'INITIAL_CONFIG' => 'Basic Configuration',
diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php
index a0727dc6ef..d835fb1b45 100644
--- a/phpBB/language/en/lang_main.php
+++ b/phpBB/language/en/lang_main.php
@@ -486,6 +486,7 @@ $lang = array(
'ATTACHMENT_PHP_SIZE_NA'=> 'The Attachment is too big.
Couldn\'t get the maximum Size defined in PHP.
The Attachment Mod is unable to determine the maximum Upload Size defined in the php.ini file.',
'ATTACHMENT_PHP_SIZE_OVERRUN' => 'The Attachment is too big.
Maximum Upload Size: %d MB.
Please note that this Size is defined in php.ini, this means it\'s set by PHP and the Attachment Mod can not override this value.',
'DISALLOWED_EXTENSION' => 'The Extension %s is not allowed',
+ 'ALLOWED' => 'Allowed',
'BYTES' => 'Bytes',
'KB' => 'KB',
'MB' => 'MB',
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index d2cfb2d09e..df06dc22f5 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -1131,7 +1131,7 @@ foreach ($rowset as $key => $row)
}
else if (trim($extensions[$attachment['extension']]['upload_icon']) != '')
{
- $upload_image = '
';
+ $upload_image = '
';
}
$filesize = $attachment['filesize'];