diff --git a/modules/comment/comment.item.php b/modules/comment/comment.item.php index d4acad199..1af663786 100644 --- a/modules/comment/comment.item.php +++ b/modules/comment/comment.item.php @@ -924,28 +924,34 @@ class CommentItem extends BaseObject $target_src = Context::getRequestUri().$target_src; } - $tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111, 999999) . $this->comment_srl)); - if(!is_dir('./files/cache/tmp')) + $tmp_file = sprintf('./files/cache/tmp/%s', Rhymix\Framework\Security::getRandom(32)); + if (!Rhymix\Framework\Storage::exists(\RX_BASEDIR . 'files/cache/tmp')) { - FileHandler::makeDir('./files/cache/tmp'); + Rhymix\Framework\Storage::createDirectory(\RX_BASEDIR . 'files/cache/tmp'); + } + if (!Rhymix\Framework\Storage::exists(\RX_BASEDIR . 'files/cache/tmp/.htaccess')) + { + Rhymix\Framework\Storage::protectDirectory(\RX_BASEDIR . 'files/cache/tmp'); } FileHandler::getRemoteFile($target_src, $tmp_file); - if(!file_exists($tmp_file)) + if (!Rhymix\Framework\Storage::exists($tmp_file)) { continue; } else { - if($is_img = @getimagesize($tmp_file)) + if ($is_img = @getimagesize($tmp_file)) { list($_w, $_h, $_t, $_a) = $is_img; if($_w < ($external_image_min_width) && ($height === 'auto' || $_h < ($external_image_min_height))) { + Rhymix\Framework\Storage::delete($tmp_file); continue; } } else { + Rhymix\Framework\Storage::delete($tmp_file); continue; } $source_file = $tmp_file; diff --git a/modules/document/document.item.php b/modules/document/document.item.php index 7daa75828..38718714d 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -1257,28 +1257,34 @@ class DocumentItem extends BaseObject $target_src = Context::getRequestUri().$target_src; } - $tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111,999999).$this->document_srl)); - if(!is_dir('./files/cache/tmp')) + $tmp_file = sprintf('./files/cache/tmp/%s', Rhymix\Framework\Security::getRandom(32)); + if (!Rhymix\Framework\Storage::exists(\RX_BASEDIR . 'files/cache/tmp')) { - FileHandler::makeDir('./files/cache/tmp'); + Rhymix\Framework\Storage::createDirectory(\RX_BASEDIR . 'files/cache/tmp'); + } + if (!Rhymix\Framework\Storage::exists(\RX_BASEDIR . 'files/cache/tmp/.htaccess')) + { + Rhymix\Framework\Storage::protectDirectory(\RX_BASEDIR . 'files/cache/tmp'); } FileHandler::getRemoteFile($target_src, $tmp_file); - if(!file_exists($tmp_file)) + if (!Rhymix\Framework\Storage::exists($tmp_file)) { continue; } else { - if($is_img = @getimagesize($tmp_file)) + if ($is_img = @getimagesize($tmp_file)) { list($_w, $_h, $_t, $_a) = $is_img; if($_w < ($external_image_min_width) && ($height === 'auto' || $_h < ($external_image_min_height))) { + Rhymix\Framework\Storage::delete($tmp_file); continue; } } else { + Rhymix\Framework\Storage::delete($tmp_file); continue; } $source_file = $tmp_file;