mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/15311] Move get_temp_dir to another service
PHPBB3-15311
This commit is contained in:
@@ -42,25 +42,14 @@ class filesystem implements filesystem_interface
|
||||
*/
|
||||
protected $symfony_filesystem;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $cache_temp_dir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $temp_dir;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($cache_temp_dir)
|
||||
public function __construct()
|
||||
{
|
||||
$this->chmod_info = array();
|
||||
$this->symfony_filesystem = new \Symfony\Component\Filesystem\Filesystem();
|
||||
$this->working_directory = null;
|
||||
$this->cache_temp_dir = $cache_temp_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -753,33 +742,4 @@ class filesystem implements filesystem_interface
|
||||
{
|
||||
return helper::resolve_path($path, $prefix, $absolute, $return_array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a temporary directory to write files
|
||||
*
|
||||
* @return string returns the directory
|
||||
*/
|
||||
public function get_temp_dir()
|
||||
{
|
||||
if (!isset($this->temp_dir))
|
||||
{
|
||||
$tmp_dir = (function_exists('sys_get_temp_dir')) ? sys_get_temp_dir() : '';
|
||||
|
||||
// Prevent trying to write to system temp dir in case of open_basedir
|
||||
// restrictions being in effect
|
||||
if (empty($tmp_dir) || !@file_exists($tmp_dir) || !@is_writable($tmp_dir))
|
||||
{
|
||||
$tmp_dir = $this->cache_temp_dir;
|
||||
|
||||
if (!is_dir($tmp_dir))
|
||||
{
|
||||
$this->mkdir($tmp_dir, 0777);
|
||||
}
|
||||
}
|
||||
|
||||
$this->temp_dir = helper::realpath($tmp_dir);
|
||||
}
|
||||
|
||||
return $this->temp_dir;
|
||||
}
|
||||
}
|
||||
|
54
phpBB/phpbb/filesystem/temp.php
Normal file
54
phpBB/phpbb/filesystem/temp.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\filesystem;
|
||||
|
||||
class temp
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $temp_dir;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($filesystem, $cache_temp_dir)
|
||||
{
|
||||
$tmp_dir = (function_exists('sys_get_temp_dir')) ? sys_get_temp_dir() : '';
|
||||
|
||||
// Prevent trying to write to system temp dir in case of open_basedir
|
||||
// restrictions being in effect
|
||||
if (empty($tmp_dir) || !@file_exists($tmp_dir) || !@is_writable($tmp_dir))
|
||||
{
|
||||
$tmp_dir = $cache_temp_dir;
|
||||
|
||||
if (!is_dir($tmp_dir))
|
||||
{
|
||||
$filesystem->mkdir($tmp_dir, 0777);
|
||||
}
|
||||
}
|
||||
|
||||
$this->temp_dir = helper::realpath($tmp_dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a temporary directory to write files
|
||||
*
|
||||
* @return string returns the directory
|
||||
*/
|
||||
public function get_temp_dir()
|
||||
{
|
||||
return $this->temp_dir;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user