aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/avatar
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/avatar')
-rw-r--r--phpBB/phpbb/avatar/driver/local.php4
-rw-r--r--phpBB/phpbb/avatar/driver/remote.php18
-rw-r--r--phpBB/phpbb/avatar/manager.php40
3 files changed, 51 insertions, 11 deletions
diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php
index 07b3ed59de..8888686b2d 100644
--- a/phpBB/phpbb/avatar/driver/local.php
+++ b/phpBB/phpbb/avatar/driver/local.php
@@ -154,7 +154,7 @@ class local extends \phpbb\avatar\driver\driver
*/
protected function get_avatar_list($user)
{
- $avatar_list = ($this->cache == null) ? false : $this->cache->get('avatar_local_list');
+ $avatar_list = ($this->cache == null) ? false : $this->cache->get('_avatar_local_list');
if ($avatar_list === false)
{
@@ -192,7 +192,7 @@ class local extends \phpbb\avatar\driver\driver
if ($this->cache != null)
{
- $this->cache->put('avatar_local_list', $avatar_list, 86400);
+ $this->cache->put('_avatar_local_list', $avatar_list, 86400);
}
}
diff --git a/phpBB/phpbb/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php
index 1bd7f6c927..4b0ee3f06f 100644
--- a/phpBB/phpbb/avatar/driver/remote.php
+++ b/phpBB/phpbb/avatar/driver/remote.php
@@ -130,8 +130,24 @@ class remote extends \phpbb\avatar\driver\driver
{
// Timeout after 1 second
stream_set_timeout($file_stream, 1);
+ // read some data to ensure headers are present
+ fread($file_stream, 1024);
$meta = stream_get_meta_data($file_stream);
- foreach ($meta['wrapper_data'] as $header)
+
+ if (isset($meta['wrapper_data']['headers']) && is_array($meta['wrapper_data']['headers']))
+ {
+ $headers = $meta['wrapper_data']['headers'];
+ }
+ else if (isset($meta['wrapper_data']) && is_array($meta['wrapper_data']))
+ {
+ $headers = $meta['wrapper_data'];
+ }
+ else
+ {
+ $headers = array();
+ }
+
+ foreach ($headers as $header)
{
$header = preg_split('/ /', $header, 2);
if (strtr(strtolower(trim($header[0], ':')), '_', '-') === 'content-type')
diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php
index 42ae61a9a2..8d83152ed6 100644
--- a/phpBB/phpbb/avatar/manager.php
+++ b/phpBB/phpbb/avatar/manager.php
@@ -326,17 +326,41 @@ class manager
$driver->delete($avatar_data);
}
- $result = self::$default_row;
+ $result = $this->prefix_avatar_columns($prefix, self::$default_row);
- foreach ($result as $key => $value)
+ $sql = 'UPDATE ' . $table . '
+ SET ' . $db->sql_build_array('UPDATE', $result) . '
+ WHERE ' . $prefix . 'id = ' . (int) $avatar_data['id'];
+ $db->sql_query($sql);
+
+ // Make sure we also delete this avatar from the users
+ if ($prefix === 'group_')
{
- $result[$prefix . $key] = $value;
- unset($result[$key]);
+ $result = $this->prefix_avatar_columns('user_', self::$default_row);
+
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $result) . "
+ WHERE user_avatar = '" . $db->sql_escape($avatar_data['avatar']) . "'";
+ $db->sql_query($sql);
}
+ }
- $sql = 'UPDATE ' . $table . '
- SET ' . $db->sql_build_array('UPDATE', $result) . '
- WHERE ' . $prefix . 'id = ' . (int) $avatar_data['id'];
- $db->sql_query($sql);
+ /**
+ * Prefix avatar columns
+ *
+ * @param string $prefix Column prefix
+ * @param array $data Column data
+ *
+ * @return array Column data with prefixed column names
+ */
+ public function prefix_avatar_columns($prefix, $data)
+ {
+ foreach ($data as $key => $value)
+ {
+ $data[$prefix . $key] = $value;
+ unset($data[$key]);
+ }
+
+ return $data;
}
}