aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_attachments.php102
-rw-r--r--phpBB/includes/acp/acp_php_info.php3
-rw-r--r--phpBB/includes/constants.php1
-rw-r--r--phpBB/includes/functions.php8
-rw-r--r--phpBB/includes/functions_admin.php28
-rw-r--r--phpBB/includes/functions_upload.php6
-rw-r--r--phpBB/includes/mcp/mcp_main.php1
-rw-r--r--phpBB/includes/ucp/ucp_attachments.php2
8 files changed, 49 insertions, 102 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index 823e9709c4..1de254f6e2 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -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'])
{
@@ -1077,47 +1085,6 @@ class acp_attachments
}
/**
- * 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
*/
function search_imagemagick()
@@ -1377,45 +1344,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
*/
function display_order($value, $key = '')
diff --git a/phpBB/includes/acp/acp_php_info.php b/phpBB/includes/acp/acp_php_info.php
index 3816285953..342d89addd 100644
--- a/phpBB/includes/acp/acp_php_info.php
+++ b/phpBB/includes/acp/acp_php_info.php
@@ -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);
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index 652bda40a6..99812363b7 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -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
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 5206e51fdd..a160bee7d3 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -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'] . '&amp;f=' . (int) $forum_id) : $filename;
+ $download_link = append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&amp;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'] . '&amp;t=1&amp;f=' . (int) $forum_id) : $thumbnail_filename;
+ $thumbnail_link = append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $attachment['attach_id'] . '&amp;t=1&amp;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,
);
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index ee2d432818..f32bf00254 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -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);
}
/**
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index e1cffaf710..31687ab3fe 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -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;
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index 67f7441725..a53430f1bd 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -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']),
diff --git a/phpBB/includes/ucp/ucp_attachments.php b/phpBB/includes/ucp/ucp_attachments.php
index f995f05bf6..895cb51020 100644
--- a/phpBB/includes/ucp/ucp_attachments.php
+++ b/phpBB/includes/ucp/ucp_attachments.php
@@ -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))
{