[feature/attach-dl] Consider that post_id can mean private message id as well.

PHPBB3-11042
This commit is contained in:
Andreas Fischer 2012-08-10 03:14:55 +02:00
parent 7bd81cd0cd
commit e5a3bc03b4

View file

@ -342,11 +342,20 @@ else
} }
if ($post_id) if ($post_id)
{
if ($attachment['in_message'])
{
$sql = 'SELECT message_subject
FROM ' . PRIVMSGS_TABLE . "
WHERE msg_id = $post_id";
}
else
{ {
$sql = 'SELECT post_subject $sql = 'SELECT post_subject
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
WHERE post_id = $post_id"; WHERE post_id = $post_id";
} }
}
else else
{ {
$sql = 'SELECT topic_title $sql = 'SELECT topic_title
@ -359,7 +368,7 @@ else
$db->sql_freeresult($result); $db->sql_freeresult($result);
$bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|'); $bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|');
$clean_name = ($post_id) ? $row['post_subject'] : $row['topic_title']; $clean_name = current($row);
$clean_name = rawurlencode(str_replace($bad_chars, '_', strtolower($clean_name))); $clean_name = rawurlencode(str_replace($bad_chars, '_', strtolower($clean_name)));
$clean_name = preg_replace("/%(\w{2})/", '_', $clean_name); $clean_name = preg_replace("/%(\w{2})/", '_', $clean_name);
$suffix = '_' . (($post_id) ? $post_id : $topic_id) . '_' . $clean_name; $suffix = '_' . (($post_id) ? $post_id : $topic_id) . '_' . $clean_name;