aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2004-12-12 14:07:02 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2004-12-12 14:07:02 +0000
commit20d18e1a9fec071d6e2e519709b08bacf650d750 (patch)
treee6f71aa6625aae6ef8602b42716a7e531662c626 /phpBB/includes
parentaf82f666589ab73e2e2727015d82c611c93a9c6a (diff)
downloadforums-20d18e1a9fec071d6e2e519709b08bacf650d750.tar
forums-20d18e1a9fec071d6e2e519709b08bacf650d750.tar.gz
forums-20d18e1a9fec071d6e2e519709b08bacf650d750.tar.bz2
forums-20d18e1a9fec071d6e2e519709b08bacf650d750.tar.xz
forums-20d18e1a9fec071d6e2e519709b08bacf650d750.zip
- fix attachment mod errors
- make upload path consistent with all other 2.2 path settings - fix "post title wrong after split" bug git-svn-id: file:///svn/phpbb/trunk@5032 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions_admin.php12
-rw-r--r--phpBB/includes/functions_display.php6
-rw-r--r--phpBB/includes/functions_posting.php126
-rw-r--r--phpBB/includes/functions_privmsgs.php4
-rw-r--r--phpBB/includes/mcp/mcp_main.php4
-rw-r--r--phpBB/includes/mcp/mcp_topic.php6
6 files changed, 90 insertions, 68 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 3022266f7e..eb1554c234 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -677,23 +677,13 @@ function phpbb_unlink($filename, $mode = 'file')
{
global $config, $user, $phpbb_root_path;
- $filename = ($mode == 'thumbnail') ? $config['upload_dir'] . '/thumb_' . $filename : $config['upload_dir'] . '/' . $filename;
+ $filename = ($mode == 'thumbnail') ? $phpbb_root_path . $config['upload_dir'] . '/thumb_' . basename($filename) : $phpbb_root_path . $config['upload_dir'] . '/' . basename($filename);
$deleted = @unlink($filename);
if (file_exists($filename))
{
$filesys = str_replace('/','\\', $filename);
$deleted = @system("del $filesys");
-
- if (file_exists($filename))
- {
- $filename = realpath($filename);
- @chmod($filename, 0777);
- if (!($deleted = @unlink($filename)))
- {
- $deleted = @system("del $filename");
- }
- }
}
return $deleted;
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index a37b9c77be..70636a8962 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -535,8 +535,8 @@ function display_attachments($forum_id, $blockname, &$attachment_data, &$update_
{
// Some basics...
$attachment['extension'] = strtolower(trim($attachment['extension']));
- $filename = $config['upload_dir'] . '/' . $attachment['physical_filename'];
- $thumbnail_filename = $config['upload_dir'] . '/thumb_' . $attachment['physical_filename'];
+ $filename = $phpbb_root_path . $config['upload_dir'] . '/' . basename($attachment['physical_filename']);
+ $thumbnail_filename = $phpbb_root_path . $config['upload_dir'] . '/thumb_' . basename($attachment['physical_filename']);
$upload_image = '';
@@ -554,7 +554,7 @@ function display_attachments($forum_id, $blockname, &$attachment_data, &$update_
$filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize);
- $display_name = $attachment['real_filename'];
+ $display_name = basename($attachment['real_filename']);
$comment = str_replace("\n", '<br />', censor_text($attachment['comment']));
$denied = false;
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index ea8f605a72..4353871719 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -133,7 +133,7 @@ function update_last_post_information($type, $id)
// Upload Attachment - filedata is generated here
function upload_attachment($forum_id, $filename, $local = false, $local_storage = '', $is_message = false)
{
- global $auth, $user, $config, $db;
+ global $auth, $user, $config, $db, $phpbb_root_path;
$filedata = array();
$filedata['error'] = array();
@@ -144,7 +144,7 @@ function upload_attachment($forum_id, $filename, $local = false, $local_storage
return $filedata;
}
- $r_file = $filename;
+ $r_file = trim(basename($filename));
$file = (!$local) ? $_FILES['fileupload']['tmp_name'] : $local_storage;
$filedata['mimetype'] = (!$local) ? $_FILES['fileupload']['type'] : 'application/octet-stream';
@@ -186,6 +186,45 @@ function upload_attachment($forum_id, $filename, $local = false, $local_storage
return $filedata;
}
+ $filedata['thumbnail'] = 0;
+
+ // Prepare Values
+ $filedata['filetime'] = time();
+ $filedata['filename'] = stripslashes($r_file);
+
+ $filedata['destination_filename'] = strtolower($filedata['filename']);
+ $filedata['destination_filename'] = $user->data['user_id'] . '_' . $filedata['filetime'] . '.' . $filedata['extension'];
+
+ $filedata['filename'] = str_replace("'", "\'", $filedata['filename']);
+
+ // Do we have to create a thumbnail?
+ if ($cat_id == ATTACHMENT_CATEGORY_IMAGE && $config['img_create_thumbnail'])
+ {
+ $filedata['thumbnail'] = 1;
+ }
+
+ // Descide the Upload method
+ $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode')) ? 'move' : 'copy';
+ $upload_mode = ($local) ? 'local' : $upload_mode;
+
+ // Ok, upload the File
+ $result = move_uploaded_attachment($upload_mode, $file, $filedata);
+
+ if ($result)
+ {
+ $filedata['error'][] = $result;
+ $filedata['post_attach'] = false;
+
+ return $filedata;
+ }
+
+ $file = (!$local) ? $phpbb_root_path . $config['upload_dir'] . '/' . $filedata['destination_filename'] : $local_storage;
+
+ if (!$filedata['filesize'])
+ {
+ $filedata['filesize'] = @filesize($file);
+ }
+
// Check Image Size, if it is an image
if (!$auth->acl_gets('m_', 'a_') && $cat_id == ATTACHMENT_CATEGORY_IMAGE)
{
@@ -197,6 +236,10 @@ function upload_attachment($forum_id, $filename, $local = false, $local_storage
{
$filedata['error'][] = sprintf($user->lang['ERROR_IMAGESIZE'], $config['img_max_width'], $config['img_max_height']);
$filedata['post_attach'] = false;
+
+ phpbb_unlink($filedata['destination_filename']);
+ phpbb_unlink($filedata['destination_filename'], 'thumbnail');
+
return $filedata;
}
}
@@ -211,6 +254,10 @@ function upload_attachment($forum_id, $filename, $local = false, $local_storage
$filedata['error'][] = sprintf($user->lang['ATTACHMENT_TOO_BIG'], $allowed_filesize, $size_lang);
$filedata['post_attach'] = false;
+
+ phpbb_unlink($filedata['destination_filename']);
+ phpbb_unlink($filedata['destination_filename'], 'thumbnail');
+
return $filedata;
}
@@ -221,54 +268,33 @@ function upload_attachment($forum_id, $filename, $local = false, $local_storage
{
$filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
$filedata['post_attach'] = false;
+
+ phpbb_unlink($filedata['destination_filename']);
+ phpbb_unlink($filedata['destination_filename'], 'thumbnail');
+
return $filedata;
}
}
// TODO - Check Free Disk Space - need testing under windows
- if ($free_space = disk_free_space($config['upload_dir']))
+ if ($free_space = disk_free_space($phpbb_root_path . $config['upload_dir']))
{
if ($free_space <= $filedata['filesize'])
{
$filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
$filedata['post_attach'] = false;
- return $filedata;
- }
- }
-
- $filedata['thumbnail'] = 0;
-
- // Prepare Values
- $filedata['filetime'] = time();
- $filedata['filename'] = stripslashes($r_file);
- $filedata['destination_filename'] = strtolower($filedata['filename']);
- $filedata['destination_filename'] = $user->data['user_id'] . '_' . $filedata['filetime'] . '.' . $filedata['extension'];
-
- $filedata['filename'] = str_replace("'", "\'", $filedata['filename']);
+ phpbb_unlink($filedata['destination_filename']);
+ phpbb_unlink($filedata['destination_filename'], 'thumbnail');
- // Do we have to create a thumbnail ?
- if ($cat_id == ATTACHMENT_CATEGORY_IMAGE && $config['img_create_thumbnail'])
- {
- $filedata['thumbnail'] = 1;
+ return $filedata;
+ }
}
- // Descide the Upload method
- $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode')) ? 'move' : 'copy';
- $upload_mode = ($local) ? 'local' : $upload_mode;
-
- // Ok, upload the File
- $result = move_uploaded_attachment($upload_mode, $file, $filedata);
-
- if ($result)
- {
- $filedata['error'][] = $result;
- $filedata['post_attach'] = false;
- }
return $filedata;
}
-// Move/Upload File - could be used for Avatars too ?
+// Move/Upload File - could be used for Avatars too?
function move_uploaded_attachment($upload_mode, $source_filename, &$filedata)
{
global $user, $config, $phpbb_root_path;
@@ -279,41 +305,41 @@ function move_uploaded_attachment($upload_mode, $source_filename, &$filedata)
switch ($upload_mode)
{
case 'copy':
- if ( !@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
+ if (!@copy($source_filename, $phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename))
{
- if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
+ if (!@move_uploaded_file($source_filename, $phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename))
{
- return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $config['upload_dir'] . '/' . $destination_filename);
+ return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename);
}
}
- @chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
+ @chmod($phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename, 0666);
break;
case 'move':
- if ( !@move_uploaded_file($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
+ if (!@move_uploaded_file($source_filename, $phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename))
{
- if ( !@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename) )
+ if (!@copy($source_filename, $phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename))
{
- return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $config['upload_dir'] . '/' . $destination_filename);
+ return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename);
}
}
- @chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
+ @chmod($phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename, 0666);
break;
case 'local':
- if (!@copy($source_filename, $config['upload_dir'] . '/' . $destination_filename))
+ if (!@copy($source_filename, $phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename))
{
- return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $config['upload_dir'] . '/' . $destination_filename);
+ return sprintf($user->lang['GENERAL_UPLOAD_ERROR'], $phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename);
}
- @chmod($config['upload_dir'] . '/' . $destination_filename, 0666);
+ @chmod($phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename, 0666);
@unlink($source_filename);
break;
}
if ($filedata['thumbnail'])
{
- $source = $config['upload_dir'] . '/' . $destination_filename;
- $destination = $config['upload_dir'] . '/thumb_' . $destination_filename;
+ $source = $phpbb_root_path . $config['upload_dir'] . '/' . $destination_filename;
+ $destination = $phpbb_root_path . $config['upload_dir'] . '/thumb_' . $destination_filename;
if (!create_thumbnail($source, $destination, $filedata['mimetype']))
{
@@ -647,18 +673,18 @@ function posting_gen_attachment_entry(&$attachment_data, &$filename_data)
foreach ($attachment_data as $attach_row)
{
$hidden = '';
- $attach_row['real_filename'] = stripslashes($attach_row['real_filename']);
+ $attach_row['real_filename'] = stripslashes(basename($attach_row['real_filename']));
foreach ($attach_row as $key => $value)
{
$hidden .= '<input type="hidden" name="attachment_data[' . $count . '][' . $key . ']" value="' . $value . '" />';
}
- $download_link = (!$attach_row['attach_id']) ? $config['upload_dir'] . '/' . $attach_row['physical_filename'] : $phpbb_root_path . "download.$phpEx$SID&id=" . intval($attach_row['attach_id']);
+ $download_link = (!$attach_row['attach_id']) ? $phpbb_root_path . $config['upload_dir'] . '/' . basename($attach_row['physical_filename']) : $phpbb_root_path . "download.$phpEx$SID&id=" . intval($attach_row['attach_id']);
$template->assign_block_vars('attach_row', array(
- 'FILENAME' => $attach_row['real_filename'],
- 'ATTACH_FILENAME' => $attach_row['physical_filename'],
+ 'FILENAME' => basename($attach_row['real_filename']),
+ 'ATTACH_FILENAME' => basename($attach_row['physical_filename']),
'FILE_COMMENT' => $attach_row['comment'],
'ATTACH_ID' => $attach_row['attach_id'],
'ASSOC_INDEX' => $count,
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 0284071fa4..b2a43ec1e6 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1278,8 +1278,8 @@ function submit_pm($mode, $subject, &$data, $update_message, $put_in_outbox = tr
'topic_id' => 0,
'in_message' => 1,
'poster_id' => $user->data['user_id'],
- 'physical_filename' => $attach_row['physical_filename'],
- 'real_filename' => $attach_row['real_filename'],
+ 'physical_filename' => basename($attach_row['physical_filename']),
+ 'real_filename' => basename($attach_row['real_filename']),
'comment' => $attach_row['comment'],
'extension' => $attach_row['extension'],
'mimetype' => $attach_row['mimetype'],
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index 44e6b5acd6..743b745f8f 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -869,8 +869,8 @@ function mcp_fork_topic($topic_ids)
'topic_id' => (int) $new_topic_id,
'in_message' => 0,
'poster_id' => (int) $attach_row['poster_id'],
- 'physical_filename' => (string) $attach_row['physical_filename'],
- 'real_filename' => (string) $attach_row['real_filename'],
+ 'physical_filename' => (string) basename($attach_row['physical_filename']),
+ 'real_filename' => (string) basename($attach_row['real_filename']),
'download_count' => (int) $attach_row['download_count'],
'comment' => (string) $attach_row['comment'],
'extension' => (string) $attach_row['extension'],
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php
index 2004e51874..683dd0776e 100644
--- a/phpBB/includes/mcp/mcp_topic.php
+++ b/phpBB/includes/mcp/mcp_topic.php
@@ -358,6 +358,12 @@ function split_topic($mode, $topic_id, $to_forum_id, $subject)
$to_topic_id = $db->sql_nextid();
move_posts($post_id_list, $to_topic_id);
+ // Change topic title of first post
+ $sql = 'UPDATE ' . POSTS_TABLE . "
+ SET post_subject = '" . $db->sql_escape($subject) . "'
+ WHERE post_id = {$post_id_list[0]}";
+ $db->sql_query($sql);
+
$success_msg = 'TOPIC_SPLIT_SUCCESS';
// Link back to both topics