diff --git a/phpBB/develop/adjust_avatars.php b/phpBB/develop/adjust_avatars.php
index dc4ae88f37..7313967c94 100644
--- a/phpBB/develop/adjust_avatars.php
+++ b/phpBB/develop/adjust_avatars.php
@@ -19,7 +19,7 @@ $auth->acl($user->data);
$user->setup();
$echos = 0;
-
+
if (!isset($config['avatar_salt']))
{
$cache->purge();
@@ -30,6 +30,11 @@ if (!isset($config['avatar_salt']))
die('database not up to date');
}
+if (!isset($config['storage\\avatar\\config\\path']) || $config['storage\\avatar\\config\\path'] != 'phpbb\\storage\\provider\\local')
+{
+ die('use local provider');
+}
+
// let's start with the users using a group_avatar.
$sql = 'SELECT group_id, group_avatar
FROM ' . GROUPS_TABLE . '
@@ -46,16 +51,16 @@ while ($row = $db->sql_fetchrow($result))
{
$new_avatar_name = adjust_avatar($row['group_avatar'], 'g' . $row['group_id']);
$group_avatars[] = $new_avatar_name;
-
+
// failure is probably due to the avatar name already being adjusted
if ($new_avatar_name !== false)
{
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_avatar = '" . $db->sql_escape($new_avatar_name) . "'
- WHERE user_avatar = '" . $db->sql_escape($row['group_avatar']) . "'
+ WHERE user_avatar = '" . $db->sql_escape($row['group_avatar']) . "'
AND user_avatar_type = " . AVATAR_UPLOAD;
$db->sql_query($sql);
-
+
$sql = 'UPDATE ' . GROUPS_TABLE . "
SET group_avatar = '" . $db->sql_escape($new_avatar_name) . "'
WHERE group_id = {$row['group_id']}";
@@ -80,8 +85,8 @@ while ($row = $db->sql_fetchrow($result))
$db->sql_freeresult($result);
$sql = 'SELECT user_id, username, user_avatar, user_avatar_type
- FROM ' . USERS_TABLE . '
- WHERE user_avatar_type = ' . AVATAR_UPLOAD . '
+ FROM ' . USERS_TABLE . '
+ WHERE user_avatar_type = ' . AVATAR_UPLOAD . '
AND ' . $db->sql_in_set('user_avatar', $group_avatars, true, true);
$result = $db->sql_query($sql);
@@ -108,7 +113,7 @@ while ($row = $db->sql_fetchrow($result))
$db->sql_query($sql);
echo '
Failed updating user ' . $row['user_id'] . "\n";
}
-
+
if ($echos > 200)
{
echo '
' . "\n";
@@ -131,8 +136,8 @@ $db->sql_close();
function adjust_avatar($old_name, $midfix)
{
global $config, $phpbb_root_path;
-
- $avatar_path = $phpbb_root_path . $config['avatar_path'];
+
+ $avatar_path = $phpbb_root_path . $config['storage\\avatar\\config\\path'];
$extension = strtolower(substr(strrchr($old_name, '.'), 1));
$new_name = $config['avatar_salt'] . '_' . $midfix . '.' . $extension;
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index 3e6919c88a..97feea71ec 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -264,7 +264,6 @@ PHPBB_QA (Set board to QA-Mode, which means the updater also c
{T_SUPER_TEMPLATE_PATH} - styles/xxx/template
{T_IMAGES_PATH} - images/
{T_SMILIES_PATH} - $config['smilies_path']/
- {T_AVATAR_PATH} - $config['avatar_path']/
{T_AVATAR_GALLERY_PATH} - $config['avatar_gallery_path']/
{T_ICONS_PATH} - $config['icons_path']/
{T_RANKS_PATH} - $config['ranks_path']/
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php
index 4efa8c70b3..86ce84a4a1 100644
--- a/phpBB/includes/acp/acp_main.php
+++ b/phpBB/includes/acp/acp_main.php
@@ -502,26 +502,8 @@ class acp_main
$upload_dir_size = get_formatted_filesize($config['upload_dir_size']);
- $avatar_dir_size = 0;
-
- if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path']))
- {
- while (($file = readdir($avatar_dir)) !== false)
- {
- if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false)
- {
- $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
- }
- }
- closedir($avatar_dir);
-
- $avatar_dir_size = get_formatted_filesize($avatar_dir_size);
- }
- else
- {
- // Couldn't open Avatar dir.
- $avatar_dir_size = $user->lang['NOT_AVAILABLE'];
- }
+ // Couldn't open Avatar dir.
+ $avatar_dir_size = $user->lang['NOT_AVAILABLE'];
if ($posts_per_day > $total_posts)
{
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 5bf86276c8..9f7d4f02e2 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -4434,7 +4434,6 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'T_SUPER_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template',
'T_IMAGES_PATH' => "{$web_path}images/",
'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/",
- 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/",
'T_AVATAR_GALLERY_PATH' => "{$web_path}{$config['avatar_gallery_path']}/",
'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/",
'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/",
@@ -4452,7 +4451,6 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'T_SUPER_TEMPLATE_NAME' => rawurlencode((isset($user->style['style_parent_tree']) && $user->style['style_parent_tree']) ? $user->style['style_parent_tree'] : $user->style['style_path']),
'T_IMAGES' => 'images',
'T_SMILIES' => $config['smilies_path'],
- 'T_AVATAR' => $config['avatar_path'],
'T_AVATAR_GALLERY' => $config['avatar_gallery_path'],
'T_ICONS' => $config['icons_path'],
'T_RANKS' => $config['ranks_path'],
diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php
index c79a84f8d4..b3bde79339 100644
--- a/phpBB/includes/functions_acp.php
+++ b/phpBB/includes/functions_acp.php
@@ -88,7 +88,6 @@ function adm_page_header($page_title)
'T_IMAGES_PATH' => "{$phpbb_root_path}images/",
'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/",
- 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/",
'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/",
'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/",
'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/",
diff --git a/phpBB/includes/functions_download.php b/phpBB/includes/functions_download.php
index b15b28ced8..eea64c3ab2 100644
--- a/phpBB/includes/functions_download.php
+++ b/phpBB/includes/functions_download.php
@@ -30,20 +30,7 @@ function send_avatar_to_browser($file, $browser)
$storage = $phpbb_container->get('storage.avatar');
$prefix = $config['avatar_salt'] . '_';
- $image_dir = $config['avatar_path'];
-
- // Adjust image_dir path (no trailing slash)
- if (substr($image_dir, -1, 1) == '/' || substr($image_dir, -1, 1) == '\\')
- {
- $image_dir = substr($image_dir, 0, -1) . '/';
- }
- $image_dir = str_replace(array('../', '..\\', './', '.\\'), '', $image_dir);
-
- if ($image_dir && ($image_dir[0] == '/' || $image_dir[0] == '\\'))
- {
- $image_dir = '';
- }
- $file_path = $image_dir . '/' . $prefix . $file;
+ $file_path = $prefix . $file;
if ($storage->exists($file_path) && !headers_sent())
{
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index f1e03869b4..75fb301c01 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -2164,7 +2164,9 @@ function phpbb_style_is_active($style_id)
*/
function avatar_delete($mode, $row, $clean_db = false)
{
- global $phpbb_root_path, $config;
+ global $config, $phpbb_container;
+
+ $storage = $phpbb_container->get('storage.avatar');
// Check if the users avatar is actually *not* a group avatar
if ($mode == 'user')
@@ -2181,13 +2183,16 @@ function avatar_delete($mode, $row, $clean_db = false)
}
$filename = get_avatar_filename($row[$mode . '_avatar']);
- if (file_exists($phpbb_root_path . $config['avatar_path'] . '/' . $filename))
+ try
{
- @unlink($phpbb_root_path . $config['avatar_path'] . '/' . $filename);
+ $storage->delete($filename);
+
return true;
}
-
- return false;
+ catch (\phpbb\storage\exception\exception $e)
+ {
+ return false;
+ }
}
/**
@@ -2505,7 +2510,9 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
*/
function group_correct_avatar($group_id, $old_entry)
{
- global $config, $db, $phpbb_root_path;
+ global $config, $db, $phpbb_container;
+
+ $storage = $phpbb_container->get('storage.avatar');
$group_id = (int) $group_id;
$ext = substr(strrchr($old_entry, '.'), 1);
@@ -2513,14 +2520,19 @@ function group_correct_avatar($group_id, $old_entry)
$new_filename = $config['avatar_salt'] . "_g$group_id.$ext";
$new_entry = 'g' . $group_id . '_' . substr(time(), -5) . ".$ext";
- $avatar_path = $phpbb_root_path . $config['avatar_path'];
- if (@rename($avatar_path . '/'. $old_filename, $avatar_path . '/' . $new_filename))
+ try
{
+ $this->storage->rename($old_filename, $new_filename);
+
$sql = 'UPDATE ' . GROUPS_TABLE . '
SET group_avatar = \'' . $db->sql_escape($new_entry) . "'
WHERE group_id = $group_id";
$db->sql_query($sql);
}
+ catch (\phpbb\storage\exception\exception $e)
+ {
+
+ }
}
diff --git a/phpBB/install/convert/convertor.php b/phpBB/install/convert/convertor.php
index 5118651b71..619fc73275 100644
--- a/phpBB/install/convert/convertor.php
+++ b/phpBB/install/convert/convertor.php
@@ -281,7 +281,7 @@ class convertor
$bad_folders = array();
$local_paths = array(
- 'avatar_path' => path($config['avatar_path']),
+ 'avatar_path' => path($config['storage\\avatar\\config\\path']),
'avatar_gallery_path' => path($config['avatar_gallery_path']),
'icons_path' => path($config['icons_path']),
'ranks_path' => path($config['ranks_path']),
diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php
index d0885dc620..6476fe0f3a 100644
--- a/phpBB/install/convertors/convert_phpbb20.php
+++ b/phpBB/install/convertors/convert_phpbb20.php
@@ -311,7 +311,7 @@ if (!$get_info)
$convertor = array(
'test_file' => 'viewtopic.php',
- 'avatar_path' => get_config_value('avatar_path') . '/',
+ 'avatar_path' => get_config_value('storage\\avatar\\config\\path') . '/',
'avatar_gallery_path' => get_config_value('avatar_gallery_path') . '/',
'smilies_path' => get_config_value('smilies_path') . '/',
'upload_path' => (defined('MOD_ATTACHMENT')) ? phpbb_get_files_dir() . '/' : '',