[-] Classes : fix bug PSCFI-3367 - incorrect admin rights for created image folders

This commit is contained in:
tDidierjean
2011-09-20 16:58:58 +00:00
parent daff11df6b
commit 41e5a8d64e
+9 -6
View File
@@ -56,6 +56,9 @@ class ImageCore extends ObjectModel
/** @var string image path without extension */ /** @var string image path without extension */
protected $existing_path; protected $existing_path;
/** @var int access rights of created folders (octal) */
protected $access_rights = 0775;
protected $tables = array ('image', 'image_lang'); protected $tables = array ('image', 'image_lang');
protected $fieldsRequired = array('id_product'); protected $fieldsRequired = array('id_product');
@@ -511,8 +514,8 @@ class ImageCore extends ObjectModel
if (!file_exists(_PS_PROD_IMG_DIR_.$this->getImgFolder())) if (!file_exists(_PS_PROD_IMG_DIR_.$this->getImgFolder()))
{ {
// Apparently sometimes mkdir cannot set the rights, and sometimes chmod can't. Trying both. // Apparently sometimes mkdir cannot set the rights, and sometimes chmod can't. Trying both.
$success = @mkdir(_PS_PROD_IMG_DIR_.$this->getImgFolder(), 0755, true) $success = @mkdir(_PS_PROD_IMG_DIR_.$this->getImgFolder(), $access_rights, true)
|| @chmod(_PS_PROD_IMG_DIR_.$this->getImgFolder(), 0755); || @chmod(_PS_PROD_IMG_DIR_.$this->getImgFolder(), $access_rights);
// Create an index.php file in the new folder // Create an index.php file in the new folder
if ($success if ($success
@@ -586,8 +589,8 @@ class ImageCore extends ObjectModel
{ {
if(!file_exists(_PS_PROD_IMG_DIR_.$tmp_folder)) if(!file_exists(_PS_PROD_IMG_DIR_.$tmp_folder))
{ {
@mkdir(_PS_PROD_IMG_DIR_.$tmp_folder, 0755); @mkdir(_PS_PROD_IMG_DIR_.$tmp_folder, $access_rights);
@chmod(_PS_PROD_IMG_DIR_.$tmp_folder, 0755); @chmod(_PS_PROD_IMG_DIR_.$tmp_folder, $access_rights);
} }
$tmp_path = _PS_PROD_IMG_DIR_.$tmp_folder.basename($file); $tmp_path = _PS_PROD_IMG_DIR_.$tmp_folder.basename($file);
if (!@rename($new_path, $tmp_path) || !file_exists($tmp_path)) if (!@rename($new_path, $tmp_path) || !file_exists($tmp_path))
@@ -618,8 +621,8 @@ class ImageCore extends ObjectModel
} }
if (file_exists($test_folder)) if (file_exists($test_folder))
return false; return false;
@mkdir($test_folder, 0755, true); @mkdir($test_folder, $access_rights, true);
@chmod($test_folder, 0755); @chmod($test_folder, $access_rights);
if (!is_writeable($test_folder)) if (!is_writeable($test_folder))
return false; return false;
@rmdir($test_folder); @rmdir($test_folder);