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