mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
[feature/attach-dl] Move logic for passworded forums to a function.
PHPBB3-11042
This commit is contained in:
parent
9b7b794beb
commit
7bd81cd0cd
2 changed files with 27 additions and 47 deletions
|
@ -230,29 +230,7 @@ else if ($download_id)
|
||||||
{
|
{
|
||||||
if (!$attachment['in_message'])
|
if (!$attachment['in_message'])
|
||||||
{
|
{
|
||||||
$sql = 'SELECT p.forum_id, f.forum_password, f.parent_id
|
phpbb_download_handle_passworded_forum($db, $auth, $attachment['topic_id']);
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
|
|
||||||
WHERE p.post_id = ' . $attachment['post_msg_id'] . '
|
|
||||||
AND p.forum_id = f.forum_id';
|
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
|
||||||
$row = $db->sql_fetchrow($result);
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
$f_download = $auth->acl_get('f_download', $row['forum_id']);
|
|
||||||
|
|
||||||
if ($auth->acl_get('u_download') && $f_download)
|
|
||||||
{
|
|
||||||
if ($row && $row['forum_password'])
|
|
||||||
{
|
|
||||||
// Do something else ... ?
|
|
||||||
login_forum_box($row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
send_status_line(403, 'Forbidden');
|
|
||||||
trigger_error('SORRY_AUTH_VIEW_ATTACH');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -350,30 +328,7 @@ else
|
||||||
{
|
{
|
||||||
// sizeof($attachments) >= 1
|
// sizeof($attachments) >= 1
|
||||||
|
|
||||||
$sql = 'SELECT t.forum_id, f.forum_password, f.parent_id
|
phpbb_download_handle_passworded_forum($db, $auth, $attachment['topic_id']);
|
||||||
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
|
||||||
WHERE t.topic_id = " . (int) $attachment['topic_id'] . "
|
|
||||||
AND t.forum_id = f.forum_id";
|
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
|
||||||
$row = $db->sql_fetchrow($result);
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
$f_download = $auth->acl_get('f_download', $row['forum_id']);
|
|
||||||
|
|
||||||
if ($auth->acl_get('u_download') && $f_download)
|
|
||||||
{
|
|
||||||
if ($row && $row['forum_password'])
|
|
||||||
{
|
|
||||||
// Do something else ... ?
|
|
||||||
login_forum_box($row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
send_status_line(403, 'Forbidden');
|
|
||||||
trigger_error('SORRY_AUTH_VIEW_ATTACH');
|
|
||||||
}
|
|
||||||
|
|
||||||
phpbb_increment_downloads($db, $attachment_ids);
|
phpbb_increment_downloads($db, $attachment_ids);
|
||||||
|
|
||||||
if (!class_exists('compress'))
|
if (!class_exists('compress'))
|
||||||
|
|
|
@ -613,3 +613,28 @@ function phpbb_increment_downloads($db, $ids)
|
||||||
WHERE ' . $db->sql_in_set('attach_id', $ids);
|
WHERE ' . $db->sql_in_set('attach_id', $ids);
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function phpbb_download_handle_passworded_forum($db, $auth, $topic_id)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT t.forum_id, f.forum_password, f.parent_id
|
||||||
|
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
||||||
|
WHERE t.topic_id = " . (int) $topic_id . "
|
||||||
|
AND t.forum_id = f.forum_id";
|
||||||
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
$row = $db->sql_fetchrow($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']))
|
||||||
|
{
|
||||||
|
if ($row && $row['forum_password'])
|
||||||
|
{
|
||||||
|
// Do something else ... ?
|
||||||
|
login_forum_box($row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
send_status_line(403, 'Forbidden');
|
||||||
|
trigger_error('SORRY_AUTH_VIEW_ATTACH');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue