mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[feature/attach-dl] Use "else if" for precedence in case of multiple arguments.
PHPBB3-11042
This commit is contained in:
parent
155b584a68
commit
3fe8344104
1 changed files with 12 additions and 24 deletions
|
@ -140,18 +140,6 @@ $archive = $request->variable('archive', '.tar');
|
||||||
$mode = request_var('mode', '');
|
$mode = request_var('mode', '');
|
||||||
$thumbnail = request_var('t', false);
|
$thumbnail = request_var('t', false);
|
||||||
|
|
||||||
// Ensure we're only performing one operation
|
|
||||||
if ($download_id)
|
|
||||||
{
|
|
||||||
$topic_id = false;
|
|
||||||
$post_id = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($post_id)
|
|
||||||
{
|
|
||||||
$topic_id = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start session management, do not update session page.
|
// Start session management, do not update session page.
|
||||||
$user->session_begin(false);
|
$user->session_begin(false);
|
||||||
$auth->acl($user->data);
|
$auth->acl($user->data);
|
||||||
|
@ -172,6 +160,8 @@ if (!$config['allow_attachments'] && !$config['allow_pm_attach'])
|
||||||
$attachment = ($download_id) ? array() : false;
|
$attachment = ($download_id) ? array() : false;
|
||||||
$attachments = ($topic_id || $post_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)
|
if ($download_id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT attach_id, in_message, post_msg_id, extension, is_orphan, poster_id, filetime
|
$sql = 'SELECT attach_id, in_message, post_msg_id, extension, is_orphan, poster_id, filetime
|
||||||
|
@ -181,8 +171,17 @@ if ($download_id)
|
||||||
$attachment = $db->sql_fetchrow($result);
|
$attachment = $db->sql_fetchrow($result);
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
else if ($post_id)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT attach_id, in_message, post_msg_id, extension, is_orphan, poster_id, filetime
|
||||||
|
FROM ' . ATTACHMENTS_TABLE . "
|
||||||
|
WHERE post_msg_id = $post_id";
|
||||||
|
|
||||||
if ($topic_id)
|
$result = $db->sql_query($sql);
|
||||||
|
$attachments = $db->sql_fetchrowset($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
else if ($topic_id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT a.attach_id, a.in_message, a.post_msg_id, a.extension, a.is_orphan, a.poster_id, a.filetime
|
$sql = 'SELECT a.attach_id, a.in_message, a.post_msg_id, a.extension, a.is_orphan, a.poster_id, a.filetime
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a
|
FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a
|
||||||
|
@ -195,17 +194,6 @@ if ($topic_id)
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($post_id)
|
|
||||||
{
|
|
||||||
$sql = 'SELECT attach_id, in_message, post_msg_id, extension, is_orphan, poster_id, filetime
|
|
||||||
FROM ' . ATTACHMENTS_TABLE . "
|
|
||||||
WHERE post_msg_id = $post_id";
|
|
||||||
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
$attachments = $db->sql_fetchrowset($result);
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$attachment && !$attachments)
|
if (!$attachment && !$attachments)
|
||||||
{
|
{
|
||||||
send_status_line(404, 'Not Found');
|
send_status_line(404, 'Not Found');
|
||||||
|
|
Loading…
Add table
Reference in a new issue