mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 21:38:54 +00:00
[ticket/15276] Fix code and add phpdoc
PHPBB3-15276
This commit is contained in:
parent
28060a8468
commit
da3c9b3de7
4 changed files with 35 additions and 12 deletions
|
@ -30,7 +30,7 @@ if (!isset($config['avatar_salt']))
|
||||||
die('database not up to date');
|
die('database not up to date');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($config['storage\\avatar\\config\\path']) || $config['storage\\avatar\\config\\path'] != 'phpbb\\storage\\provider\\local')
|
if (!isset($config['storage\\avatar\\config\\path']) || $config['storage\\avatar\\config\\path'] !== 'phpbb\\storage\\provider\\local')
|
||||||
{
|
{
|
||||||
die('use local provider');
|
die('use local provider');
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,12 @@ function send_avatar_to_browser($file, $browser)
|
||||||
|
|
||||||
header('Cache-Control: public');
|
header('Cache-Control: public');
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
header('Content-Type: ' . $file_info->mimetype);
|
header('Content-Type: ' . $file_info->mimetype);
|
||||||
} catch (\phpbb\storage\exception\not_implemented $e) {
|
}
|
||||||
|
catch (\phpbb\storage\exception\exception $e)
|
||||||
|
{
|
||||||
// Just dont send this header
|
// Just dont send this header
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,20 +66,26 @@ function send_avatar_to_browser($file, $browser)
|
||||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
|
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
header('Content-Length: ' . $file_info->size);
|
header('Content-Length: ' . $file_info->size);
|
||||||
} catch (\phpbb\storage\exception\not_implemented $e) {
|
}
|
||||||
|
catch (\phpbb\storage\exception\exception $e)
|
||||||
|
{
|
||||||
// Just dont send this header
|
// Just dont send this header
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
$fp = $storage->read_stream($file_path);
|
$fp = $storage->read_stream($file_path);
|
||||||
$output = fopen('php://output', 'w+b');
|
$output = fopen('php://output', 'w+b');
|
||||||
stream_copy_to_stream($fp, $output);
|
stream_copy_to_stream($fp, $output);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
fclose($output);
|
fclose($output);
|
||||||
} catch (\Exception $e) {
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
// Send nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
flush();
|
flush();
|
||||||
|
|
|
@ -141,7 +141,7 @@ class remote_storage extends base
|
||||||
return $this->factory->get('filespec')->set_error($this->language->lang($this->upload->error_prefix . 'WRONG_FILESIZE', $max_filesize['value'], $max_filesize['unit']));
|
return $this->factory->get('filespec')->set_error($this->language->lang($this->upload->error_prefix . 'WRONG_FILESIZE', $max_filesize['value'], $max_filesize['unit']));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($content_length == 0)
|
if ($content_length === 0)
|
||||||
{
|
{
|
||||||
return $this->factory->get('filespec')->set_error($this->upload->error_prefix . 'EMPTY_REMOTE_DATA');
|
return $this->factory->get('filespec')->set_error($this->upload->error_prefix . 'EMPTY_REMOTE_DATA');
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
|
|
||||||
namespace phpbb\storage;
|
namespace phpbb\storage;
|
||||||
|
|
||||||
use phpbb\storage\exception\not_implemented;
|
use phpbb\storage\exception\exception;
|
||||||
|
use phpbb\storage\adapter\adapter_interface;
|
||||||
|
|
||||||
class file_info
|
class file_info
|
||||||
{
|
{
|
||||||
|
@ -23,16 +24,29 @@ class file_info
|
||||||
protected $adapter;
|
protected $adapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Path of the file
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $path;
|
protected $path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Stores the properties of $path file, so dont have to be consulted multiple times.
|
||||||
|
* For example, when you need the width of an image, using getimagesize() you get
|
||||||
|
* both dimensions, so you store both here, and when you get the height, you dont have
|
||||||
|
* to call getimagesize() again.
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $properties;
|
protected $properties;
|
||||||
|
|
||||||
public function __construct($adapter, $path)
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param \Symfony\Component\DependencyInjection\ContainerInterface $adapter
|
||||||
|
* @param string $path
|
||||||
|
*/
|
||||||
|
public function __construct(adapter_interface $adapter, $path)
|
||||||
{
|
{
|
||||||
$this->adapter = $adapter;
|
$this->adapter = $adapter;
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
|
@ -52,7 +66,7 @@ class file_info
|
||||||
{
|
{
|
||||||
if (!method_exists($this->adapter, 'file_' . $name))
|
if (!method_exists($this->adapter, 'file_' . $name))
|
||||||
{
|
{
|
||||||
throw new not_implemented();
|
throw new exception('STORAGE_METHOD_NOT_IMPLEMENTED');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->properties = array_merge($this->properties, call_user_func([$this->adapter, 'file_' . $name], $this->path));
|
$this->properties = array_merge($this->properties, call_user_func([$this->adapter, 'file_' . $name], $this->path));
|
||||||
|
|
Loading…
Add table
Reference in a new issue