mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-05 08:17:47 +02:00
[ticket/14285] Use route service for download routes
PHPBB3-14285
This commit is contained in:
@@ -14,6 +14,16 @@
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
use phpbb\attachment\manager;
|
||||
use phpbb\config\config;
|
||||
use phpbb\controller\helper;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\filesystem\filesystem_interface;
|
||||
use phpbb\language\language;
|
||||
use phpbb\template\template;
|
||||
use phpbb\user;
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
@@ -21,30 +31,33 @@ if (!defined('IN_PHPBB'))
|
||||
|
||||
class acp_attachments
|
||||
{
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
/** @var driver_interface */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\config\config */
|
||||
/** @var config */
|
||||
protected $config;
|
||||
|
||||
/** @var \phpbb\language\language */
|
||||
/** @var language */
|
||||
protected $language;
|
||||
|
||||
/** @var ContainerBuilder */
|
||||
protected $phpbb_container;
|
||||
|
||||
/** @var \phpbb\template\template */
|
||||
/** @var template */
|
||||
protected $template;
|
||||
|
||||
/** @var \phpbb\user */
|
||||
/** @var user */
|
||||
protected $user;
|
||||
|
||||
/** @var \phpbb\filesystem\filesystem_interface */
|
||||
/** @var filesystem_interface */
|
||||
protected $filesystem;
|
||||
|
||||
/** @var \phpbb\attachment\manager */
|
||||
/** @var manager */
|
||||
protected $attachment_manager;
|
||||
|
||||
/** @var helper */
|
||||
protected $controller_helper;
|
||||
|
||||
public $id;
|
||||
public $u_action;
|
||||
protected $new_config;
|
||||
@@ -63,6 +76,7 @@ class acp_attachments
|
||||
$this->phpbb_container = $phpbb_container;
|
||||
$this->filesystem = $phpbb_filesystem;
|
||||
$this->attachment_manager = $phpbb_container->get('attachment.manager');
|
||||
$this->controller_helper = $phpbb_container->get('controller.helper');
|
||||
|
||||
$user->add_lang(array('posting', 'viewtopic', 'acp/attachments'));
|
||||
|
||||
@@ -1082,8 +1096,8 @@ class acp_attachments
|
||||
'PHYSICAL_FILENAME' => utf8_basename($row['physical_filename']),
|
||||
'ATTACH_ID' => $row['attach_id'],
|
||||
'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? $post_ids[$row['attach_id']] : '',
|
||||
'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id']))
|
||||
);
|
||||
'U_FILE' => $this->controller_helper->route('phpbb_storage_attachment', ['id' => (int) $row['attach_id']])
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
@@ -1270,8 +1284,8 @@ class acp_attachments
|
||||
'S_IN_MESSAGE' => (bool) $row['in_message'],
|
||||
|
||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}",
|
||||
'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'mode=view&id=' . $row['attach_id']))
|
||||
);
|
||||
'U_FILE' => $this->controller_helper->route('phpbb_storage_attachment', ['id' => $row['attach_id']])
|
||||
));
|
||||
}
|
||||
|
||||
break;
|
||||
|
@@ -14,6 +14,9 @@
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
use phpbb\controller\helper;
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
@@ -36,6 +39,9 @@ class acp_users
|
||||
global $phpbb_dispatcher, $request;
|
||||
global $phpbb_container, $phpbb_log;
|
||||
|
||||
/** @var helper $controller_helper */
|
||||
$controller_helper = $phpbb_container->get('controller.helper');
|
||||
|
||||
$user->add_lang(array('posting', 'ucp', 'acp/users'));
|
||||
$this->tpl_name = 'acp_users';
|
||||
|
||||
@@ -2123,9 +2129,6 @@ class acp_users
|
||||
$decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_flags);
|
||||
}
|
||||
|
||||
/** @var \phpbb\controller\helper $controller_helper */
|
||||
$controller_helper = $phpbb_container->get('controller.helper');
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_SIGNATURE' => true,
|
||||
|
||||
@@ -2295,7 +2298,7 @@ class acp_users
|
||||
|
||||
'S_IN_MESSAGE' => $row['in_message'],
|
||||
|
||||
'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . $row['attach_id']),
|
||||
'U_DOWNLOAD' => $controller_helper->route('phpbb_storage_attachment', ['id' => (int) $row['attach_id']]),
|
||||
'U_VIEW_TOPIC' => $view_topic)
|
||||
);
|
||||
}
|
||||
|
@@ -894,11 +894,13 @@ function parse_cfg_file($filename, $lines = false)
|
||||
{
|
||||
$parsed_items = array();
|
||||
|
||||
if ($lines === false) {
|
||||
if ($lines === false)
|
||||
{
|
||||
$lines = file($filename);
|
||||
}
|
||||
|
||||
foreach ($lines as $line) {
|
||||
foreach ($lines as $line)
|
||||
{
|
||||
$line = trim($line);
|
||||
|
||||
if (!$line || $line[0] == '#' || ($delim_pos = strpos($line, '=')) === false)
|
||||
@@ -927,14 +929,15 @@ function parse_cfg_file($filename, $lines = false)
|
||||
$value = htmlspecialchars(substr($value, 1, strlen($value) - 2), ENT_COMPAT);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$value = htmlspecialchars($value, ENT_COMPAT);
|
||||
}
|
||||
|
||||
$parsed_items[$key] = $value;
|
||||
}
|
||||
|
||||
if (isset($parsed_items['parent']) && isset($parsed_items['name']) && $parsed_items['parent'] == $parsed_items['name']) {
|
||||
if (isset($parsed_items['parent']) && isset($parsed_items['name']) && $parsed_items['parent'] == $parsed_items['name'])
|
||||
{
|
||||
unset($parsed_items['parent']);
|
||||
}
|
||||
|
||||
|
@@ -1124,6 +1124,9 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
|
||||
|
||||
$storage_attachment = $phpbb_container->get('storage.attachment');
|
||||
|
||||
/** @var \phpbb\controller\helper */
|
||||
$controller_helper = $phpbb_container->get('controller.helper');
|
||||
|
||||
//
|
||||
$compiled_attachments = array();
|
||||
|
||||
@@ -1283,15 +1286,14 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
|
||||
$display_cat = ATTACHMENT_CATEGORY_NONE;
|
||||
}
|
||||
|
||||
$download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id']);
|
||||
$download_link = $controller_helper->route('phpbb_storage_attachment', ['id' => (int) $attachment['attach_id']]);
|
||||
$l_downloaded_viewed = 'VIEWED_COUNTS';
|
||||
|
||||
switch ($display_cat)
|
||||
{
|
||||
// Images
|
||||
case ATTACHMENT_CATEGORY_IMAGE:
|
||||
$inline_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id']);
|
||||
$download_link .= '&mode=view';
|
||||
$inline_link = $controller_helper->route('phpbb_storage_attachment', ['id' => (int) $attachment['attach_id']]);
|
||||
|
||||
$block_array += array(
|
||||
'S_IMAGE' => true,
|
||||
@@ -1303,8 +1305,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a
|
||||
|
||||
// Images, but display Thumbnail
|
||||
case ATTACHMENT_CATEGORY_THUMB:
|
||||
$thumbnail_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id'] . '&t=1');
|
||||
$download_link .= '&mode=view';
|
||||
$thumbnail_link = $controller_helper->route('phpbb_storage_attachment', ['id' => (int) $attachment['attach_id'], 't' => 1]);
|
||||
|
||||
$block_array += array(
|
||||
'S_THUMBNAIL' => true,
|
||||
|
@@ -779,7 +779,7 @@ function posting_gen_inline_attachments(&$attachment_data)
|
||||
*/
|
||||
function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true)
|
||||
{
|
||||
global $template, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher;
|
||||
global $template, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher, $phpbb_container;
|
||||
|
||||
// Some default template variables
|
||||
$template->assign_vars(array(
|
||||
@@ -807,7 +807,7 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a
|
||||
$hidden .= '<input type="hidden" name="attachment_data[' . $count . '][' . $key . ']" value="' . $value . '" />';
|
||||
}
|
||||
|
||||
$download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . (int) $attach_row['attach_id'], true, ($attach_row['is_orphan']) ? $user->session_id : false);
|
||||
$download_link = $phpbb_container->get('controller.helper')->route('phpbb_storage_attachment', ['id' => (int) $attach_row['attach_id']]);
|
||||
|
||||
$attachrow_template_vars[(int) $attach_row['attach_id']] = array(
|
||||
'FILENAME' => utf8_basename($attach_row['real_filename']),
|
||||
|
@@ -1073,6 +1073,7 @@ class bbcode_firstpass extends bbcode
|
||||
if ($pos_domain !== false && $pos_path >= $pos_domain && $pos_ext >= $pos_path)
|
||||
{
|
||||
// Ok, actually we allow linking to some files (this may be able to be extended in some way later...)
|
||||
// @deprecated
|
||||
if (strpos($url, '/' . $check_path . '/download/file.' . $phpEx) !== 0)
|
||||
{
|
||||
return false;
|
||||
@@ -1534,6 +1535,8 @@ class parse_message extends bbcode_firstpass
|
||||
global $config, $auth, $user, $phpbb_root_path, $phpEx, $db, $request;
|
||||
global $phpbb_container, $phpbb_dispatcher;
|
||||
|
||||
$controller_helper = $phpbb_container->get('controller.helper');
|
||||
|
||||
$error = array();
|
||||
|
||||
$num_attachments = count($this->attachment_data);
|
||||
@@ -1776,7 +1779,7 @@ class parse_message extends bbcode_firstpass
|
||||
|
||||
if (isset($this->plupload) && $this->plupload->is_active())
|
||||
{
|
||||
$download_url = append_sid("{$phpbb_root_path}download/file.{$phpEx}", 'mode=view&id=' . $new_entry['attach_id']);
|
||||
$download_url = $controller_helper->route('phpbb_storage_attachment', ['id' => (int) $new_entry['attach_id']]);
|
||||
|
||||
// Send the client the attachment data to maintain state
|
||||
$json_response->send(array('data' => $this->attachment_data, 'download_url' => $download_url));
|
||||
|
@@ -14,6 +14,9 @@
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
use phpbb\controller\helper;
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
@@ -31,6 +34,9 @@ class ucp_attachments
|
||||
{
|
||||
global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container, $request, $auth;
|
||||
|
||||
/** @var helper $controller_helper */
|
||||
$controller_helper = $phpbb_container->get('controller.helper');
|
||||
|
||||
$start = $request->variable('start', 0);
|
||||
$sort_key = $request->variable('sk', 'a');
|
||||
$sort_dir = $request->variable('sd', 'a');
|
||||
@@ -179,7 +185,7 @@ class ucp_attachments
|
||||
'S_IN_MESSAGE' => $row['in_message'],
|
||||
'S_LOCKED' => !$row['in_message'] && !$auth->acl_get('m_edit', $row['forum_id']) && ($row['forum_status'] == ITEM_LOCKED || $row['topic_status'] == ITEM_LOCKED || $row['post_edit_locked']),
|
||||
|
||||
'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $row['attach_id']),
|
||||
'U_VIEW_ATTACHMENT' => $controller_helper->route('phpbb_storage_attachment', ['id' => (int) $row['attach_id']]),
|
||||
'U_VIEW_TOPIC' => $view_topic)
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user