From 361eb3e8e0b2fd667502704525bc9db8f6b8a795 Mon Sep 17 00:00:00 2001 From: "M@d D3n" Date: Sat, 2 Sep 2017 09:34:58 +0300 Subject: [PATCH] Fixes --- gallery/class.gallery.php | 44 ++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) mode change 100644 => 100755 gallery/class.gallery.php diff --git a/gallery/class.gallery.php b/gallery/class.gallery.php old mode 100644 new mode 100755 index cbc53d7..b044771 --- a/gallery/class.gallery.php +++ b/gallery/class.gallery.php @@ -56,6 +56,36 @@ class Gallery */ var $admin_size = 'c100x100'; + + /** + * Creates directory + * + * @param string $path Path to create + * @param integer $mode Optional permissions + * @return boolean Success + */ + function _mkdir($path, $mode = 0777) + { + $old = umask(0); + $res = @mkdir($path, $mode); + umask($old); + + return $res; + } + + /** + * Creates directories recursively + * + * @param string $path Path to create + * @param integer $mode Optional permissions + * @return boolean Success + */ + function rmkdir($path, $mode = 0777) + { + return is_dir($path) || (mkdir(dirname($path), $mode) && $this->_mkdir($path, $mode)); + } + + /** * ВНЕШНИЕ МЕТОДЫ */ @@ -415,8 +445,9 @@ class Gallery if (!empty($_REQUEST['fromfolder']) && $_REQUEST['fromfolder'] == 1) { - $src_dir = BASE_DIR . '/' . UPLOAD_GALLERY_DIR . '/.temp/'; - if (!file_exists($src_dir . '/') && !rmkdir($src_dir . '/', 0777)) + $src_dir = BASE_DIR . '/' . trim(UPLOAD_GALLERY_DIR, '/') . '/.temp/'; + + if (! file_exists($src_dir) && ! mkdir($src_dir, 0777, true)) { header('Location:index.php?do=modules&action=modedit&mod=gallery&moduleaction=1'); exit; @@ -482,16 +513,19 @@ class Gallery } closedir($handle); } - }else if (!empty($_REQUEST['fromuploader']) && $_REQUEST['fromuploader'] == 1) + } + else if (!empty($_REQUEST['fromuploader']) && $_REQUEST['fromuploader'] == 1) { - $src_dir = BASE_DIR . '/' . UPLOAD_GALLERY_DIR . '/.uploader/'.$_SESSION['user_id']; - if (!file_exists($src_dir . '/') && !rmkdir($src_dir . '/', 0777)) + $src_dir = BASE_DIR . '/' . UPLOAD_GALLERY_DIR . '/.uploader/' . $_SESSION['user_id']; + + if (! file_exists($src_dir . '/') && ! mkdir($src_dir . '/', 0777, true)) { header('Location:index.php?do=modules&action=modedit&mod=gallery&moduleaction=1'); exit; } $htaccess_file = $src_dir . '/' . '.htaccess'; + if (!file_exists($htaccess_file)) { $fp = @fopen($htaccess_file, 'w+');