mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
- removed download mode selection (the column info and constants will not be removed, we or others may be able to re-use them later on)
- removing extension from physical filename for uploaded attachments (as has been suggested some time ago from our community), can still be used by using the new 'unique_ext' mode on file cleaning - fixed a bug with copying attachments if copying a topic - made sure no attachment files get removed used at another location - changed media player "embed" code. For some this may result in no auto-resizing - though a download link has been added. git-svn-id: file:///svn/phpbb/trunk@6831 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
1ca8081635
commit
732ad23cd7
13 changed files with 84 additions and 128 deletions
|
@ -187,10 +187,6 @@
|
|||
<dt><label for="allow_in_pm">{L_ALLOW_IN_PM}:</label></dt>
|
||||
<dd><input type="checkbox" class="radio" id="allow_in_pm" name="allow_in_pm" value="1"<!-- IF ALLOW_IN_PM --> checked="checked"<!-- ENDIF --> /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="download_mode">{L_DOWNLOAD_MODE}:</label><br /><span>{L_DOWNLOAD_MODE_EXPLAIN}</span></dt>
|
||||
<dd>{S_DOWNLOAD_SELECT}</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="upload_icon">{L_UPLOAD_ICON}:</label></dt>
|
||||
<dd><select name="upload_icon" id="upload_icon" onchange="update_image(this.options[selectedIndex].value);">
|
||||
|
|
|
@ -161,6 +161,7 @@ else if (($display_cat == ATTACHMENT_CATEGORY_NONE || $display_cat == ATTACHMENT
|
|||
// Determine the 'presenting'-method
|
||||
if ($download_mode == PHYSICAL_LINK)
|
||||
{
|
||||
// This presenting method should no longer be used
|
||||
if (!@is_dir($phpbb_root_path . $config['upload_path']))
|
||||
{
|
||||
trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']);
|
||||
|
|
|
@ -424,11 +424,17 @@ class acp_attachments
|
|||
|
||||
if ($group_id)
|
||||
{
|
||||
$sql = 'SELECT * FROM ' . EXTENSION_GROUPS_TABLE . "
|
||||
$sql = 'SELECT *
|
||||
FROM ' . EXTENSION_GROUPS_TABLE . "
|
||||
WHERE group_id = $group_id";
|
||||
$result = $db->sql_query($sql);
|
||||
$ext_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!$ext_row)
|
||||
{
|
||||
trigger_error($user->lang['NO_EXT_GROUP_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -484,13 +490,17 @@ class acp_attachments
|
|||
'group_name' => $group_name,
|
||||
'cat_id' => request_var('special_category', ATTACHMENT_CATEGORY_NONE),
|
||||
'allow_group' => ($allow_group) ? 1 : 0,
|
||||
'download_mode' => request_var('download_mode', INLINE_LINK),
|
||||
'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon,
|
||||
'max_filesize' => $max_filesize,
|
||||
'allowed_forums'=> ($forum_select) ? serialize($allowed_forums) : '',
|
||||
'allow_in_pm' => ($allow_in_pm) ? 1 : 0,
|
||||
);
|
||||
|
||||
if ($action == 'add')
|
||||
{
|
||||
$group_ary['download_mode'] = INLINE_LINK;
|
||||
}
|
||||
|
||||
$sql = ($action == 'add') ? 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' : 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' SET ';
|
||||
$sql .= $db->sql_build_array((($action == 'add') ? 'INSERT' : 'UPDATE'), $group_ary);
|
||||
$sql .= ($action == 'edit') ? " WHERE group_id = $group_id" : '';
|
||||
|
@ -523,7 +533,7 @@ class acp_attachments
|
|||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$this->rewrite_extensions();
|
||||
$cache->destroy('_extensions');
|
||||
|
||||
if (!sizeof($error))
|
||||
{
|
||||
|
@ -569,7 +579,7 @@ class acp_attachments
|
|||
|
||||
add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $group_name);
|
||||
|
||||
$this->rewrite_extensions();
|
||||
$cache->destroy('_extensions');
|
||||
|
||||
trigger_error($user->lang['EXTENSION_GROUP_DELETED'] . adm_back_link($this->u_action));
|
||||
}
|
||||
|
@ -612,7 +622,6 @@ class acp_attachments
|
|||
'cat_id' => 0,
|
||||
'allow_group' => 1,
|
||||
'allow_in_pm' => 1,
|
||||
'download_mode' => 1,
|
||||
'upload_icon' => '',
|
||||
'max_filesize' => 0,
|
||||
);
|
||||
|
@ -698,7 +707,6 @@ class acp_attachments
|
|||
'ASSIGNED_EXTENSIONS' => $assigned_extensions,
|
||||
|
||||
'S_CATEGORY_SELECT' => $this->category_select('special_category', $group_id, 'category'),
|
||||
'S_DOWNLOAD_SELECT' => $this->download_select('download_mode', $group_id, 'download_mode'),
|
||||
'S_EXT_GROUP_SIZE_OPTIONS' => size_select_options($size_format),
|
||||
'S_EXTENSION_OPTIONS' => $s_extension_options,
|
||||
'S_FILENAME_LIST' => $filename_list,
|
||||
|
@ -827,7 +835,7 @@ class acp_attachments
|
|||
$delete_files = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
phpbb_unlink($row['physical_filename']);
|
||||
phpbb_unlink($row['physical_filename'], 'file');
|
||||
|
||||
if ($row['thumbnail'])
|
||||
{
|
||||
|
@ -1076,47 +1084,6 @@ class acp_attachments
|
|||
return $group_select;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build select for download modes
|
||||
*/
|
||||
function download_select($select_name, $group_id = false, $key = '')
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$types = array(
|
||||
INLINE_LINK => $user->lang['MODE_INLINE'],
|
||||
PHYSICAL_LINK => $user->lang['MODE_PHYSICAL']
|
||||
);
|
||||
|
||||
if ($group_id)
|
||||
{
|
||||
$sql = "SELECT download_mode
|
||||
FROM " . EXTENSION_GROUPS_TABLE . "
|
||||
WHERE group_id = " . (int) $group_id;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$download_mode = (!($row = $db->sql_fetchrow($result))) ? INLINE_LINK : $row['download_mode'];
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$download_mode = INLINE_LINK;
|
||||
}
|
||||
|
||||
$group_select = '<select name="' . $select_name . '"' . (($key) ? ' id="' . $key . '"' : '') . '>';
|
||||
|
||||
foreach ($types as $type => $mode)
|
||||
{
|
||||
$selected = ($type == $download_mode) ? ' selected="selected"' : '';
|
||||
$group_select .= '<option value="' . $type . '"' . $selected . '>' . $mode . '</option>';
|
||||
}
|
||||
|
||||
$group_select .= '</select>';
|
||||
|
||||
return $group_select;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Imagick
|
||||
*/
|
||||
|
@ -1376,45 +1343,6 @@ class acp_attachments
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-Write extensions cache file
|
||||
*/
|
||||
function rewrite_extensions()
|
||||
{
|
||||
global $db, $cache;
|
||||
|
||||
$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 = $row['extension'];
|
||||
|
||||
$extensions[$extension]['display_cat'] = (int) $row['cat_id'];
|
||||
$extensions[$extension]['download_mode']= (int) $row['download_mode'];
|
||||
$extensions[$extension]['upload_icon'] = (string) $row['upload_icon'];
|
||||
$extensions[$extension]['max_filesize'] = (int) $row['max_filesize'];
|
||||
|
||||
$allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array();
|
||||
|
||||
if ($row['allow_in_pm'])
|
||||
{
|
||||
$allowed_forums = array_merge($allowed_forums, array(0));
|
||||
}
|
||||
|
||||
// Store allowed extensions forum wise
|
||||
$extensions['_allowed_'][$extension] = (!sizeof($allowed_forums)) ? 0 : $allowed_forums;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$cache->destroy('_extensions');
|
||||
$cache->put('_extensions', $extensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write display_order config field
|
||||
*/
|
||||
|
|
|
@ -30,8 +30,7 @@ class acp_php_info
|
|||
|
||||
ob_start();
|
||||
@phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES);
|
||||
$phpinfo = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$phpinfo = ob_get_clean();
|
||||
|
||||
$phpinfo = trim($phpinfo);
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ define('FULL_FOLDER_HOLD', -1);
|
|||
|
||||
// Download Modes - Attachments
|
||||
define('INLINE_LINK', 1);
|
||||
// This mode is only used internally to allow modders extending the attachment functionality
|
||||
define('PHYSICAL_LINK', 2);
|
||||
|
||||
// Confirm types
|
||||
|
|
|
@ -2463,7 +2463,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,
|
|||
global $extensions, $config, $phpbb_root_path, $phpEx;
|
||||
|
||||
//
|
||||
$force_physical = false;
|
||||
$compiled_attachments = array();
|
||||
|
||||
if (!isset($template->filename['attachment_tpl']))
|
||||
|
@ -2631,7 +2630,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,
|
|||
$display_cat = ATTACHMENT_CATEGORY_NONE;
|
||||
}
|
||||
|
||||
$download_link = (!$force_physical && $attachment['attach_id']) ? append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&f=' . (int) $forum_id) : $filename;
|
||||
$download_link = append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&f=' . (int) $forum_id);
|
||||
|
||||
switch ($display_cat)
|
||||
{
|
||||
|
@ -2649,7 +2648,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,
|
|||
// Images, but display Thumbnail
|
||||
case ATTACHMENT_CATEGORY_THUMB:
|
||||
$l_downloaded_viewed = $user->lang['VIEWED'];
|
||||
$thumbnail_link = (!$force_physical && $attachment['attach_id']) ? append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&t=1&f=' . (int) $forum_id) : $thumbnail_filename;
|
||||
$thumbnail_link = append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&t=1&f=' . (int) $forum_id);
|
||||
|
||||
$block_array += array(
|
||||
'S_THUMBNAIL' => true,
|
||||
|
@ -2663,10 +2662,11 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,
|
|||
|
||||
// Giving the filename directly because within the wm object all variables are in local context making it impossible
|
||||
// to validate against a valid session (all params can differ)
|
||||
$download_link = $filename;
|
||||
// $download_link = $filename;
|
||||
|
||||
$block_array += array(
|
||||
'U_FORUM' => generate_board_url(),
|
||||
'ATTACH_ID' => $attachment['attach_id'],
|
||||
'S_WM_FILE' => true,
|
||||
);
|
||||
|
||||
|
|
|
@ -767,7 +767,7 @@ function delete_attachments($mode, $ids, $resync = true)
|
|||
$space_removed = $files_removed = 0;
|
||||
foreach ($physical as $file_ary)
|
||||
{
|
||||
if (phpbb_unlink($file_ary['filename'], 'file'))
|
||||
if (phpbb_unlink($file_ary['filename'], 'file', true))
|
||||
{
|
||||
$space_removed += $file_ary['filesize'];
|
||||
$files_removed++;
|
||||
|
@ -775,7 +775,7 @@ function delete_attachments($mode, $ids, $resync = true)
|
|||
|
||||
if ($file_ary['thumbnail'])
|
||||
{
|
||||
phpbb_unlink($file_ary['filename'], 'thumbnail');
|
||||
phpbb_unlink($file_ary['filename'], 'thumbnail', true);
|
||||
}
|
||||
}
|
||||
set_config('upload_dir_size', $config['upload_dir_size'] - $space_removed, true);
|
||||
|
@ -1001,14 +1001,28 @@ function update_posted_info(&$topic_ids)
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete File
|
||||
* Delete attached file
|
||||
*/
|
||||
function phpbb_unlink($filename, $mode = 'file')
|
||||
function phpbb_unlink($filename, $mode = 'file', $entry_removed = false)
|
||||
{
|
||||
global $config, $user, $phpbb_root_path;
|
||||
global $db, $phpbb_root_path, $config;
|
||||
|
||||
$filename = ($mode == 'thumbnail') ? $phpbb_root_path . $config['upload_path'] . '/thumb_' . basename($filename) : $phpbb_root_path . $config['upload_path'] . '/' . basename($filename);
|
||||
return @unlink($filename);
|
||||
// Because of copying topics or modifications a physical filename could be assigned more than once. If so, do not remove the file itself.
|
||||
$sql = 'SELECT COUNT(attach_id) AS num_entries
|
||||
FROM ' . ATTACHMENTS_TABLE . "
|
||||
WHERE physical_filename = '" . $db->sql_escape(basename($filename)) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$num_entries = (int) $db->sql_fetchfield('num_entries');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Do not remove file if at least one additional entry with the same name exist.
|
||||
if (($entry_removed && $num_entries > 0) || (!$entry_removed && $num_entries > 1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$filename = ($mode == 'thumbnail') ? 'thumb_' . basename($filename) : basename($filename);
|
||||
return @unlink($phpbb_root_path . $config['upload_path'] . '/' . $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,7 +76,7 @@ class filespec
|
|||
/**
|
||||
* Cleans destination filename
|
||||
*
|
||||
* @param real|unique $mode real creates a realname, filtering some characters, lowering every character. Unique creates an unique filename
|
||||
* @param real|unique|unique_ext $mode real creates a realname, filtering some characters, lowering every character. Unique creates an unique filename
|
||||
* @param string $prefix Prefix applied to filename
|
||||
* @access public
|
||||
*/
|
||||
|
@ -106,6 +106,10 @@ class filespec
|
|||
break;
|
||||
|
||||
case 'unique':
|
||||
$this->realname = $prefix . md5(unique_id());
|
||||
break;
|
||||
|
||||
case 'unique_ext':
|
||||
default:
|
||||
$this->realname = $prefix . md5(unique_id()) . '.' . $this->extension;
|
||||
break;
|
||||
|
|
|
@ -976,6 +976,7 @@ function mcp_fork_topic($topic_ids)
|
|||
'post_msg_id' => (int) $new_post_id,
|
||||
'topic_id' => (int) $new_topic_id,
|
||||
'in_message' => 0,
|
||||
'is_orphan' => (int) $attach_row['is_orphan'],
|
||||
'poster_id' => (int) $attach_row['poster_id'],
|
||||
'physical_filename' => (string) basename($attach_row['physical_filename']),
|
||||
'real_filename' => (string) basename($attach_row['real_filename']),
|
||||
|
|
|
@ -27,7 +27,7 @@ class ucp_attachments
|
|||
|
||||
$delete = (isset($_POST['delete'])) ? true : false;
|
||||
$confirm = (isset($_POST['confirm'])) ? true : false;
|
||||
$delete_ids = request_var('attachment', array(0));
|
||||
$delete_ids = array_keys(request_var('attachment', array(0)));
|
||||
|
||||
if ($delete && sizeof($delete_ids))
|
||||
{
|
||||
|
|
|
@ -71,8 +71,6 @@ $lang = array_merge($lang, array(
|
|||
'DEFINE_ALLOWED_IPS' => 'Define allowed IPs/hostnames',
|
||||
'DEFINE_DISALLOWED_IPS' => 'Define disallowed IPs/hostnames',
|
||||
'DOWNLOAD_ADD_IPS_EXPLAIN' => 'To specify several different IPs or hostnames enter each on a new line. To specify a range of IP addresses separate the start and end with a hyphen (-), to specify a wildcard use *',
|
||||
'DOWNLOAD_MODE' => 'Download mode',
|
||||
'DOWNLOAD_MODE_EXPLAIN' => 'If you experience problems downloading files, set this to “physical”, the user will be directed to the file directly. Do not set it to physical if not really needed, it discloses the filename.',
|
||||
'DOWNLOAD_REMOVE_IPS_EXPLAIN' => 'You can remove (or un-exclude) multiple IP addresses in one go using the appropriate combination of mouse and keyboard for your computer and browser. Excluded IPs have a blue background.',
|
||||
'DISPLAY_INLINED' => 'Display images inline',
|
||||
'DISPLAY_INLINED_EXPLAIN' => 'If set to No image attachments will show as a link.',
|
||||
|
|
|
@ -191,6 +191,11 @@ switch ($mode)
|
|||
break;
|
||||
|
||||
case 'quote':
|
||||
|
||||
$post_data['post_edit_locked'] = 0;
|
||||
|
||||
// no break;
|
||||
|
||||
case 'reply':
|
||||
if ($auth->acl_get('f_reply', $forum_id))
|
||||
{
|
||||
|
|
|
@ -21,30 +21,39 @@
|
|||
|
||||
<!-- IF _file.S_FILE -->
|
||||
<span class="genmed">
|
||||
<!-- IF _file.UPLOAD_IMAGE -->{_file.UPLOAD_IMAGE} <!-- ENDIF -->
|
||||
<!-- IF _file.UPLOAD_ICON -->{_file.UPLOAD_ICON} <!-- ENDIF -->
|
||||
<a href="{_file.U_DOWNLOAD_LINK}">{_file.DOWNLOAD_NAME}</a> [{_file.FILESIZE} {_file.SIZE_LANG}]
|
||||
</span><br />
|
||||
<span class="gensmall">{_file.L_DOWNLOADED_VIEWED} {_file.L_DOWNLOAD_COUNT}</span>
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF _file.S_WM_FILE -->
|
||||
<object width="320" height="285" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">
|
||||
<param name="URL" value="{_file.U_DOWNLOAD_LINK}" />
|
||||
<param name="AutoStart" value="False" />
|
||||
<param name="ShowControls" value="True" />
|
||||
<embed name="application/x-mplayer2"
|
||||
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
|
||||
src="{_file.U_DOWNLOAD_LINK}"
|
||||
name="MediaPlayer"
|
||||
autostart="0"
|
||||
height="285"
|
||||
width="320"
|
||||
transparentatstart="0"
|
||||
animationatstart="0"
|
||||
showcontrols="1"
|
||||
autosize="0"
|
||||
displaysize="0">
|
||||
</embed>
|
||||
<!-- method used here from http://alistapart.com/articles/byebyeembed / autosizing seems to not work always, this will not fix -->
|
||||
<object width="320" height="285" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="wmstream_{_file.ATTACH_ID}">
|
||||
<param name="url" value="{_file.U_DOWNLOAD_LINK}" />
|
||||
<param name="showcontrols" value="1" />
|
||||
<param name="showdisplay" value="0" />
|
||||
<param name="showstatusbar" value="0" />
|
||||
<param name="autosize" value="1" />
|
||||
<param name="autostart" value="0" />
|
||||
<param name="visible" value="1" />
|
||||
<param name="animationstart" value="0" />
|
||||
<param name="loop" value="0" />
|
||||
<param name="src" value="{_file.U_DOWNLOAD_LINK}" />
|
||||
<!--[if !IE]>-->
|
||||
<object width="320" height="285" type="video/x-ms-wmv" data="{_file.U_DOWNLOAD_LINK}">
|
||||
<param name="src" value="{_file.U_DOWNLOAD_LINK}" />
|
||||
<param name="controller" value="1" />
|
||||
<param name="showcontrols" value="1" />
|
||||
<param name="showdisplay" value="0" />
|
||||
<param name="showstatusbar" value="0" />
|
||||
<param name="autosize" value="1" />
|
||||
<param name="autostart" value="0" />
|
||||
<param name="visible" value="1" />
|
||||
<param name="animationstart" value="0" />
|
||||
<param name="loop" value="0" />
|
||||
</object>
|
||||
<!--<![endif]-->
|
||||
</object>
|
||||
|
||||
<!-- ELSEIF _file.S_FLASH_FILE -->
|
||||
|
@ -102,7 +111,7 @@
|
|||
<!-- IF _file.S_WM_FILE or _file.S_RM_FILE or _file.S_FLASH_FILE or _file.S_QUICKTIME_FILE -->
|
||||
<br />
|
||||
<!-- IF _file.S_QUICKTIME_FILE --><a href="javascript:play_qt_file(document.qtstream_{_file.ATTACH_ID});">[ {L_PLAY_QUICKTIME_FILE} ]</a> <!-- ENDIF -->
|
||||
<span class="gensmall">{_file.DOWNLOAD_NAME} [ {_file.FILESIZE} {_file.SIZE_LANG} | {_file.L_DOWNLOADED_VIEWED} {_file.L_DOWNLOAD_COUNT} ]</span>
|
||||
<span class="gensmall"><a href="{_file.U_DOWNLOAD_LINK}">{_file.DOWNLOAD_NAME}</a> [ {_file.FILESIZE} {_file.SIZE_LANG} | {_file.L_DOWNLOADED_VIEWED} {_file.L_DOWNLOAD_COUNT} ]</span>
|
||||
<!-- ENDIF -->
|
||||
|
||||
<br />
|
||||
|
|
Loading…
Add table
Reference in a new issue