From 33683738e979925295c19356c9a5a483ea3d341d Mon Sep 17 00:00:00 2001 From: lonalore Date: Mon, 7 Aug 2017 09:49:19 +0200 Subject: [PATCH] Move file-realted methods to file_class.php. --- e107_handlers/e107_class.php | 110 ----------------------------------- 1 file changed, 110 deletions(-) diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 463192ac8..c77047971 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -585,116 +585,6 @@ class e107 return $ret; } - /** - * FIXME - move this to a file-related class? But must be available before any includes (e107 init). - * - * Checks that the directory exists and is writable. - * - * @param string $directory - * A string containing the name of a directory path. A trailing slash will be trimmed from a path. - * @param int $options - * A bitmask to indicate if the directory should be created if it does not exist (e107::FILE_CREATE_DIRECTORY) or - * made writable if it is read-only (e107::FILE_MODIFY_PERMISSIONS). - * - * @return bool - * TRUE if the directory exists (or was created) and is writable. FALSE otherwise. - */ - function prepareDirectory($directory, $options = self::FILE_MODIFY_PERMISSIONS) - { - $directory = rtrim($directory, '/\\'); - - // Check if directory exists. - if(!is_dir($directory)) - { - // Let mkdir() recursively create directories and use the default directory permissions. - if(($options & self::FILE_CREATE_DIRECTORY) && @$this->mkDir($directory, null, true)) - { - return $this->chMod($directory); - } - - return false; - } - - // The directory exists, so check to see if it is writable. - $writable = is_writable($directory); - - if(!$writable && ($options & self::FILE_MODIFY_PERMISSIONS)) - { - return $this->chMod($directory); - } - - return $writable; - } - - /** - * FIXME - move this to a file-related class? But must be available before any includes (e107 init). - * - * Sets the permissions on a file or directory. - * - * @param string $path - * A string containing a file, or directory path. - * @param int $mode - * Integer value for the permissions. Consult PHP chmod() documentation for more information. - * - * @return bool - * TRUE for success, FALSE in the event of an error. - */ - function chMod($path, $mode = null) - { - if(!isset($mode)) - { - if(is_dir($path)) - { - $mode = 0775; - } - else - { - $mode = 0664; - } - } - - if(@chmod($path, $mode)) - { - return true; - } - - return false; - } - - /** - * FIXME - move this to a file-related class? But must be available before any includes (e107 init). - * - * Creates a directory. - * - * @param string $path - * A string containing a file path. - * @param int $mode - * Mode is used. - * @param bool $recursive - * Default to FALSE. - * @param null $context - * Refer to http://php.net/manual/ref.stream.php - * - * @return bool - * Boolean TRUE on success, or FALSE on failure. - */ - function mkDir($path, $mode = null, $recursive = false, $context = null) - { - if(!isset($mode)) - { - $mode = 0775; - } - - if(!isset($context)) - { - return mkdir($path, $mode, $recursive); - } - else - { - return mkdir($path, $mode, $recursive, $context); - } - } - /** * Set mysql data *