1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-17 22:11:26 +02:00

[ticket/17361] Rewrite storage

PHPBB-17361
This commit is contained in:
Ruben Calvo
2024-11-24 00:15:10 +01:00
parent 688dbb0837
commit e9c445925b
24 changed files with 407 additions and 762 deletions

View File

@@ -293,11 +293,11 @@ class attachment extends controller
/**
* Remove non valid characters https://github.com/symfony/http-foundation/commit/c7df9082ee7205548a97031683bc6550b5dc9551
*/
protected function filenameFallback($filename)
protected function filenameFallback($filename): string
{
$filename = preg_replace(['/[^\x20-\x7e]/', '/%/', '/\//', '/\\\\/'], '', $filename);
$filename = (string) preg_replace(['/[^\x20-\x7e]/', '/%/', '/\//', '/\\\\/'], '', $filename);
return (!empty($filename)) ?: 'File';
return !empty($filename) ? $filename : 'File';
}
/**
@@ -305,7 +305,7 @@ class attachment extends controller
*/
protected function prepare(StreamedResponse $response, string $file): void
{
$response->setPrivate(); // By default should be private, but make sure of it
$response->setPrivate(); // By default, should be private, but make sure of it
parent::prepare($response, $file);
}
@@ -445,7 +445,7 @@ class attachment extends controller
if (!$url)
{
return ($this->config['secure_allow_empty_referer']) ? true : false;
return (bool) $this->config['secure_allow_empty_referer'];
}
// Split URL into domain and script part
@@ -453,13 +453,13 @@ class attachment extends controller
if ($url === false)
{
return ($this->config['secure_allow_empty_referer']) ? true : false;
return (bool) $this->config['secure_allow_empty_referer'];
}
$hostname = $url['host'];
unset($url);
$allowed = ($this->config['secure_allow_deny']) ? false : true;
$allowed = !$this->config['secure_allow_deny'];
$iplist = array();
if (($ip_ary = @gethostbynamel($hostname)) !== false)

View File

@@ -90,7 +90,7 @@ class avatar extends controller
}
$ext = substr(strrchr($file, '.'), 1);
$file = (int) $file;
$file = (int) $file; // This removes the timestamp leaving only the user id
return $this->config['avatar_salt'] . '_' . ($avatar_group ? 'g' : '') . $file . '.' . $ext;
}

View File

@@ -159,7 +159,7 @@ class controller
@set_time_limit(0);
$fp = $this->storage->read_stream($file);
$fp = $this->storage->read($file);
// Close db connection
$this->file_gc();
@@ -173,7 +173,7 @@ class controller
flush();
// Terminate script to avoid the execution of terminate events
// This avoid possible errors with db connection closed
// This avoids possible errors with db connection closed
exit;
});