aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2012-08-07 01:03:32 +0200
committerAndreas Fischer <bantu@phpbb.com>2012-08-07 01:03:32 +0200
commit56cd7e54756b743e1e2f7587fe574c1a2c395add (patch)
tree76bd43acd37c93c1c331621b43e61294669ada87
parent5986676f4dd59f9b5c69a37ee392575d7f7f0375 (diff)
downloadforums-56cd7e54756b743e1e2f7587fe574c1a2c395add.tar
forums-56cd7e54756b743e1e2f7587fe574c1a2c395add.tar.gz
forums-56cd7e54756b743e1e2f7587fe574c1a2c395add.tar.bz2
forums-56cd7e54756b743e1e2f7587fe574c1a2c395add.tar.xz
forums-56cd7e54756b743e1e2f7587fe574c1a2c395add.zip
[feature/attach-dl] Store query result always in $attachments first.
PHPBB3-11042
-rw-r--r--phpBB/download/file.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index bddd6a27aa..e50c4e18b2 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -151,9 +151,6 @@ if (!$config['allow_attachments'] && !$config['allow_pm_attach'])
trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED');
}
-$attachment = ($download_id) ? array() : false;
-$attachments = ($topic_id || $post_id) ? array() : false;
-
// If multiple arguments are provided, the precedence is as follows:
// $download_id, $post_id, $topic_id
if ($download_id)
@@ -162,7 +159,7 @@ if ($download_id)
FROM ' . ATTACHMENTS_TABLE . " a
WHERE a.attach_id = $download_id";
$result = $db->sql_query($sql);
- $attachment = $db->sql_fetchrow($result);
+ $attachments = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
}
else if ($post_id)
@@ -193,11 +190,15 @@ else
trigger_error('NO_ATTACHMENT_SELECTED');
}
-if (!$attachment && !$attachments)
+if (empty($attachments))
{
send_status_line(404, 'Not Found');
trigger_error('ERROR_NO_ATTACHMENT');
}
+else if ($download_id)
+{
+ $attachment = current($attachments);
+}
if ($attachment && ((!$attachment['in_message'] && !$config['allow_attachments']) || ($attachment['in_message'] && !$config['allow_pm_attach'])))
{