aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/avatar/driver
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-12-29 13:46:42 +0100
committerMarc Alexander <admin@m-a-styles.de>2013-12-29 13:46:42 +0100
commit382317b1352db90605d6555eaf2fbc4238c2d547 (patch)
treebfdf6980f9a19ad54842f5c50d210da5061ebab7 /phpBB/phpbb/avatar/driver
parentac131a51592f5e45e5a555ae0ac04543d02f9c31 (diff)
parentdb94f80c5ba117ca410bb2aafa3ae5c02dcf11c8 (diff)
downloadforums-382317b1352db90605d6555eaf2fbc4238c2d547.tar
forums-382317b1352db90605d6555eaf2fbc4238c2d547.tar.gz
forums-382317b1352db90605d6555eaf2fbc4238c2d547.tar.bz2
forums-382317b1352db90605d6555eaf2fbc4238c2d547.tar.xz
forums-382317b1352db90605d6555eaf2fbc4238c2d547.zip
Merge branch 'develop' of https://github.com/phpbb/phpbb into feature/passwords
Conflicts: phpBB/config/services.yml
Diffstat (limited to 'phpBB/phpbb/avatar/driver')
-rw-r--r--phpBB/phpbb/avatar/driver/driver.php29
-rw-r--r--phpBB/phpbb/avatar/driver/driver_interface.php8
-rw-r--r--phpBB/phpbb/avatar/driver/gravatar.php16
-rw-r--r--phpBB/phpbb/avatar/driver/local.php18
-rw-r--r--phpBB/phpbb/avatar/driver/remote.php47
-rw-r--r--phpBB/phpbb/avatar/driver/upload.php18
6 files changed, 74 insertions, 62 deletions
diff --git a/phpBB/phpbb/avatar/driver/driver.php b/phpBB/phpbb/avatar/driver/driver.php
index 0c54951cbd..dd55f09119 100644
--- a/phpBB/phpbb/avatar/driver/driver.php
+++ b/phpBB/phpbb/avatar/driver/driver.php
@@ -10,14 +10,6 @@
namespace phpbb\avatar\driver;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Base class for avatar drivers
* @package phpBB3
*/
@@ -48,6 +40,12 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
protected $php_ext;
/**
+ * Path Helper
+ * @var \phpbb\path_helper
+ */
+ protected $path_helper;
+
+ /**
* Cache driver
* @var \phpbb\cache\driver\driver_interface
*/
@@ -75,13 +73,15 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
* @param \phpbb\request\request $request Request object
* @param string $phpbb_root_path Path to the phpBB root
* @param string $php_ext PHP file extension
+ * @param \phpbb_path_helper $path_helper phpBB path helper
* @param \phpbb\cache\driver\driver_interface $cache Cache driver
*/
- public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\cache\driver\driver_interface $cache = null)
+ public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface $cache = null)
{
$this->config = $config;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
+ $this->path_helper = $path_helper;
$this->cache = $cache;
}
@@ -112,17 +112,6 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
/**
* @inheritdoc
*/
- public function get_template_name()
- {
- $driver = preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($this));
- $template = "ucp_avatar_options_$driver.html";
-
- return $template;
- }
-
- /**
- * @inheritdoc
- */
public function get_name()
{
return $this->name;
diff --git a/phpBB/phpbb/avatar/driver/driver_interface.php b/phpBB/phpbb/avatar/driver/driver_interface.php
index d9540c19db..7f049469a2 100644
--- a/phpBB/phpbb/avatar/driver/driver_interface.php
+++ b/phpBB/phpbb/avatar/driver/driver_interface.php
@@ -10,14 +10,6 @@
namespace phpbb\avatar\driver;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Interface for avatar drivers
* @package phpBB3
*/
diff --git a/phpBB/phpbb/avatar/driver/gravatar.php b/phpBB/phpbb/avatar/driver/gravatar.php
index 3ad783932e..9f14b7f468 100644
--- a/phpBB/phpbb/avatar/driver/gravatar.php
+++ b/phpBB/phpbb/avatar/driver/gravatar.php
@@ -10,14 +10,6 @@
namespace phpbb\avatar\driver;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Handles avatars hosted at gravatar.com
* @package phpBB3
*/
@@ -155,6 +147,14 @@ class gravatar extends \phpbb\avatar\driver\driver
}
/**
+ * @inheritdoc
+ */
+ public function get_template_name()
+ {
+ return 'ucp_avatar_options_gravatar.html';
+ }
+
+ /**
* Build gravatar URL for output on page
*
* @return string Gravatar URL
diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php
index d779099c46..611a44cb3d 100644
--- a/phpBB/phpbb/avatar/driver/local.php
+++ b/phpBB/phpbb/avatar/driver/local.php
@@ -10,14 +10,6 @@
namespace phpbb\avatar\driver;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Handles avatars selected from the board gallery
* @package phpBB3
*/
@@ -29,7 +21,7 @@ class local extends \phpbb\avatar\driver\driver
public function get_data($row)
{
return array(
- 'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],
+ 'src' => $this->path_helper->get_web_root_path() . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
@@ -143,6 +135,14 @@ class local extends \phpbb\avatar\driver\driver
}
/**
+ * @inheritdoc
+ */
+ public function get_template_name()
+ {
+ return 'ucp_avatar_options_local.html';
+ }
+
+ /**
* Get a list of avatars that are locally available
* Results get cached for 24 hours (86400 seconds)
*
diff --git a/phpBB/phpbb/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php
index 1aa638dfe5..36623942df 100644
--- a/phpBB/phpbb/avatar/driver/remote.php
+++ b/phpBB/phpbb/avatar/driver/remote.php
@@ -10,14 +10,6 @@
namespace phpbb\avatar\driver;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Handles avatars hosted remotely
* @package phpBB3
*/
@@ -125,6 +117,37 @@ class remote extends \phpbb\avatar\driver\driver
$types = \fileupload::image_types();
$extension = strtolower(\filespec::get_extension($url));
+ // Check if this is actually an image
+ if ($file_stream = @fopen($url, 'r'))
+ {
+ // Timeout after 1 second
+ stream_set_timeout($file_stream, 1);
+ $meta = stream_get_meta_data($file_stream);
+ foreach ($meta['wrapper_data'] as $header)
+ {
+ $header = preg_split('/ /', $header, 2);
+ if (strtr(strtolower(trim($header[0], ':')), '_', '-') === 'content-type')
+ {
+ if (strpos($header[1], 'image/') !== 0)
+ {
+ $error[] = 'AVATAR_URL_INVALID';
+ fclose($file_stream);
+ return false;
+ }
+ else
+ {
+ fclose($file_stream);
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ $error[] = 'AVATAR_URL_INVALID';
+ return false;
+ }
+
if (!empty($image_data) && (!isset($types[$image_data[2]]) || !in_array($extension, $types[$image_data[2]])))
{
if (!isset($types[$image_data[2]]))
@@ -163,4 +186,12 @@ class remote extends \phpbb\avatar\driver\driver
'avatar_height' => $height,
);
}
+
+ /**
+ * @inheritdoc
+ */
+ public function get_template_name()
+ {
+ return 'ucp_avatar_options_remote.html';
+ }
}
diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php
index 377c9a0b04..1e50e135e4 100644
--- a/phpBB/phpbb/avatar/driver/upload.php
+++ b/phpBB/phpbb/avatar/driver/upload.php
@@ -10,14 +10,6 @@
namespace phpbb\avatar\driver;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Handles avatars uploaded to the board
* @package phpBB3
*/
@@ -29,7 +21,7 @@ class upload extends \phpbb\avatar\driver\driver
public function get_data($row, $ignore_config = false)
{
return array(
- 'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'],
+ 'src' => $this->path_helper->get_web_root_path() . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
@@ -176,6 +168,14 @@ class upload extends \phpbb\avatar\driver\driver
}
/**
+ * @inheritdoc
+ */
+ public function get_template_name()
+ {
+ return 'ucp_avatar_options_upload.html';
+ }
+
+ /**
* Check if user is able to upload an avatar
*
* @return bool True if user can upload, false if not