diff --git a/phpBB/cache/.htaccess b/phpBB/cache/.htaccess
new file mode 100644
index 0000000000..aa5afc1640
--- /dev/null
+++ b/phpBB/cache/.htaccess
@@ -0,0 +1,4 @@
+
+ Order Allow,Deny
+ Deny from All
+
\ No newline at end of file
diff --git a/phpBB/cache/index.htm b/phpBB/cache/index.htm
new file mode 100644
index 0000000000..ee1f723a7d
--- /dev/null
+++ b/phpBB/cache/index.htm
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/phpBB/config/default/container/services_storage.yml b/phpBB/config/default/container/services_storage.yml
index 6cb0aa20cf..4e37ffbce0 100644
--- a/phpBB/config/default/container/services_storage.yml
+++ b/phpBB/config/default/container/services_storage.yml
@@ -38,6 +38,7 @@ services:
shared: false
arguments:
- '@filesystem'
+ - '@upload_imagesize'
- '%core.root_path%'
tags:
- { name: storage.adapter }
diff --git a/phpBB/phpbb/storage/adapter/adapter_interface.php b/phpBB/phpbb/storage/adapter/adapter_interface.php
index f9fb2438b6..b2f6043741 100644
--- a/phpBB/phpbb/storage/adapter/adapter_interface.php
+++ b/phpBB/phpbb/storage/adapter/adapter_interface.php
@@ -85,15 +85,4 @@ interface adapter_interface
* When the file cannot be copied
*/
public function copy($path_orig, $path_dest);
-
- /**
- * Get file info.
- *
- * @param string $path The file
- *
- * @throws \phpbb\storage\exception\not_implemented When the adapter doesnt implement the method
- *
- * @return \phpbb\storage\file_info Returns file_info object
- */
- public function file_properties($path);
}
diff --git a/phpBB/phpbb/storage/adapter/local.php b/phpBB/phpbb/storage/adapter/local.php
index 2855dcf7d1..4004669e44 100644
--- a/phpBB/phpbb/storage/adapter/local.php
+++ b/phpBB/phpbb/storage/adapter/local.php
@@ -18,6 +18,7 @@ use phpbb\storage\exception\exception;
use phpbb\filesystem\exception\filesystem_exception;
use phpbb\filesystem\filesystem;
use phpbb\filesystem\helper as filesystem_helper;
+use FastImageSize\FastImageSize;
/**
* @internal Experimental
@@ -31,6 +32,13 @@ class local implements adapter_interface, stream_interface
*/
protected $filesystem;
+ /**
+ * Filesystem component
+ *
+ * @var \FastImageSize\FastImageSize
+ */
+ protected $imagesize;
+
/**
* @var string path
*/
@@ -44,9 +52,10 @@ class local implements adapter_interface, stream_interface
/**
* Constructor
*/
- public function __construct(filesystem $filesystem, $phpbb_root_path)
+ public function __construct(filesystem $filesystem, FastImageSize $imagesize, $phpbb_root_path)
{
$this->filesystem = $filesystem;
+ $this->imagesize = $imagesize;
$this->phpbb_root_path = $phpbb_root_path;
}
@@ -236,14 +245,6 @@ class local implements adapter_interface, stream_interface
}
}
- /**
- * {@inheritdoc}
- */
- public function file_properties($path)
- {
- return [];
- }
-
/**
* Get file size.
*
@@ -251,7 +252,7 @@ class local implements adapter_interface, stream_interface
*
* @throws \phpbb\storage\exception\exception When cannot get size
*
- * @return int File size in bytes
+ * @return array Properties
*/
public function file_size($path)
{
@@ -262,16 +263,15 @@ class local implements adapter_interface, stream_interface
throw new exception('STORAGE_CANNOT_GET_FILESIZE');
}
- return $size;
+ return ['size' => $size];
}
-
/**
* Get file mimetype.
*
* @param string $path The file
*
- * @return string Mime type
+ * @return array Properties
*/
public function file_mimetype($path)
{
@@ -285,6 +285,51 @@ class local implements adapter_interface, stream_interface
$mimetype = mime_content_type($this->root_path . $path);
}
- return $mimetype;
+ return ['mimetype' => $mimetype];
+ }
+
+ /**
+ * Get image dimensions.
+ *
+ * @param string $path The file
+ *
+ * @return array Properties
+ */
+ protected function image_dimensions($path)
+ {
+ $size = $this->imagesize->getImageSize($this->root_path . $path);
+
+ // For not supported types like swf
+ if ($size === false)
+ {
+ $imsize = getimagesize($this->root_path . $path);
+ $size = ['width' => $imsize[0], 'height' => $imsize[1]];
+ }
+
+ return ['image_width' => $size['width'], 'image_height' => $size['height']];
+ }
+
+ /**
+ * Get image width.
+ *
+ * @param string $path The file
+ *
+ * @return array Properties
+ */
+ public function file_image_width($path)
+ {
+ return $this->image_dimensions($path);
+ }
+
+ /**
+ * Get image height.
+ *
+ * @param string $path The file
+ *
+ * @return array Properties
+ */
+ public function file_image_height($path)
+ {
+ return $this->image_dimensions($path);
}
}
diff --git a/phpBB/phpbb/storage/file_info.php b/phpBB/phpbb/storage/file_info.php
index ec80eb3ccf..3e0a1b1b5b 100644
--- a/phpBB/phpbb/storage/file_info.php
+++ b/phpBB/phpbb/storage/file_info.php
@@ -36,24 +36,7 @@ class file_info
{
$this->adapter = $adapter;
$this->path = $path;
- }
-
- /**
- * Load propertys lazily.
- *
- * @param string path The file path.
- */
- protected function fill_properties($path)
- {
- if ($this->properties === null)
- {
- $this->properties = [];
-
- foreach ($this->adapter->file_properties($this->path) as $name => $value)
- {
- $this->properties[$name] = $value;
- }
- }
+ $this->properties = [];
}
/**
@@ -65,8 +48,6 @@ class file_info
*/
public function get($name)
{
- $this->fill_properties($this->path);
-
if (!isset($this->properties[$name]))
{
if (!method_exists($this->adapter, 'file_' . $name))
@@ -74,7 +55,7 @@ class file_info
throw new not_implemented();
}
- $this->properties[$name] = call_user_func([$this->adapter, 'file_' . $name], $this->path);
+ $this->properties = array_merge($this->properties, call_user_func([$this->adapter, 'file_' . $name], $this->path));
}
return $this->properties[$name];
diff --git a/phpBB/phpbb/storage/storage.php b/phpBB/phpbb/storage/storage.php
index 59181d2623..089ccce737 100644
--- a/phpBB/phpbb/storage/storage.php
+++ b/phpBB/phpbb/storage/storage.php
@@ -193,6 +193,15 @@ class storage
}
}
+ /**
+ * Get file info.
+ *
+ * @param string $path The file
+ *
+ * @throws \phpbb\storage\exception\not_implemented When the adapter doesnt implement the method
+ *
+ * @return \phpbb\storage\file_info Returns file_info object
+ */
public function file_info($path)
{
return new file_info($this->adapter, $path);
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index 2360a48d8b..d0ff67b6e1 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -36,7 +36,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
->will($this->returnArgument(0));
$filesystem = new \phpbb\filesystem\filesystem();
- $adapter = new \phpbb\storage\adapter\local($filesystem, $phpbb_root_path);
+ $adapter = new \phpbb\storage\adapter\local($filesystem, new \FastImageSize\FastImageSize(), $phpbb_root_path);
$adapter->configure(['path' => 'images/avatars/upload']);
$adapter_factory_mock = $this->createMock('\phpbb\storage\adapter_factory');
$adapter_factory_mock->expects($this->any())
diff --git a/tests/storage/adapter/local_test.php b/tests/storage/adapter/local_test.php
index 6d3ba10bca..09b4568cd6 100644
--- a/tests/storage/adapter/local_test.php
+++ b/tests/storage/adapter/local_test.php
@@ -24,7 +24,7 @@
$filesystem = new \phpbb\filesystem\filesystem();
$phpbb_root_path = getcwd() . DIRECTORY_SEPARATOR;
- $this->adapter = new \phpbb\storage\adapter\local($filesystem, $phpbb_root_path);
+ $this->adapter = new \phpbb\storage\adapter\local($filesystem, new \FastImageSize\FastImageSize(), $phpbb_root_path);
$this->adapter->configure(['path' => 'test_path']);
$this->path = $phpbb_root_path . 'test_path/';