aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_admin.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2007-01-03 16:38:25 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2007-01-03 16:38:25 +0000
commit732ad23cd724e60df801a5cc32611e7d7706240d (patch)
tree3a36d276173f9f784cd7bc96bb6e2fa4d2dccf81 /phpBB/includes/functions_admin.php
parent1ca8081635e10cc47b9e36a56e9f35565fd6c2db (diff)
downloadforums-732ad23cd724e60df801a5cc32611e7d7706240d.tar
forums-732ad23cd724e60df801a5cc32611e7d7706240d.tar.gz
forums-732ad23cd724e60df801a5cc32611e7d7706240d.tar.bz2
forums-732ad23cd724e60df801a5cc32611e7d7706240d.tar.xz
forums-732ad23cd724e60df801a5cc32611e7d7706240d.zip
- 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
Diffstat (limited to 'phpBB/includes/functions_admin.php')
-rw-r--r--phpBB/includes/functions_admin.php28
1 files changed, 21 insertions, 7 deletions
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);
}
/**