public static function createDir() { // auto crate folders // $thePath = publisherGetUploadDir(); if (publisherGetPathStatus('root', true) < 0) { $thePath = publisherGetUploadDir(); $res = publisherMkdir($thePath); $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED; } if (publisherGetPathStatus('images', true) < 0) { $thePath = publisherGetImageDir(); $res = publisherMkdir($thePath); if ($res) { $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; $dest = $thePath . 'blank.png'; publisherCopyr($source, $dest); } $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED; } if (publisherGetPathStatus('images/category', true) < 0) { $thePath = publisherGetImageDir('category'); $res = publisherMkdir($thePath); if ($res) { $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; $dest = $thePath . 'blank.png'; publisherCopyr($source, $dest); } $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED; } if (publisherGetPathStatus('images/item', true) < 0) { $thePath = publisherGetImageDir('item'); $res = publisherMkdir($thePath); if ($res) { $source = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; $dest = $thePath . 'blank.png'; publisherCopyr($source, $dest); } $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED; } if (publisherGetPathStatus('content', true) < 0) { $thePath = publisherGetUploadDir(true, 'content'); $res = publisherMkdir($thePath); $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED; } }
/** * @credits Thanks to the NewBB2 Development Team * @param string $target * @return bool */ function publisherMkdir($target) { // http://www.php.net/manual/en/function.mkdir.php // saint at corenova.com // bart at cdasites dot com if (empty($target) || is_dir($target)) { return true; // best case check first } if (file_exists($target) && !is_dir($target)) { return false; } if (publisherMkdir(substr($target, 0, strrpos($target, '/')))) { if (!file_exists($target)) { $res = mkdir($target, 0777); // crawl back up & create dir tree publisherChmod($target); return $res; } } $res = is_dir($target); return $res; }