Esempio n. 1
0
function createDir()
{
    // auto crate folders
    $thePath = smartsection_getUploadDir();
    if (smartsection_admin_getPathStatus('root', true) < 0) {
        $thePath = smartsection_getUploadDir();
        $res = smartsection_admin_mkdir($thePath);
        $msg = $res ? _AM_SSECTION_DIRCREATED : _AM_SSECTION_DIRNOTCREATED;
    }
    if (smartsection_admin_getPathStatus('images', true) < 0) {
        $thePath = smartsection_getImageDir();
        $res = smartsection_admin_mkdir($thePath);
        if ($res) {
            $source = SMARTSECTION_ROOT_PATH . "images/blank.png";
            $dest = $thePath . "blank.png";
            smartsection_copyr($source, $dest);
        }
        $msg = $res ? _AM_SSECTION_DIRCREATED : _AM_SSECTION_DIRNOTCREATED;
    }
    if (smartsection_admin_getPathStatus('images/category', true) < 0) {
        $thePath = smartsection_getImageDir('category');
        $res = smartsection_admin_mkdir($thePath);
        if ($res) {
            $source = SMARTSECTION_ROOT_PATH . "images/blank.png";
            $dest = $thePath . "blank.png";
            smartsection_copyr($source, $dest);
        }
        $msg = $res ? _AM_SSECTION_DIRCREATED : _AM_SSECTION_DIRNOTCREATED;
    }
    if (smartsection_admin_getPathStatus('images/item', true) < 0) {
        $thePath = smartsection_getImageDir('item');
        $res = smartsection_admin_mkdir($thePath);
        if ($res) {
            $source = SMARTSECTION_ROOT_PATH . "images/blank.png";
            $dest = $thePath . "blank.png";
            smartsection_copyr($source, $dest);
        }
        $msg = $res ? _AM_SSECTION_DIRCREATED : _AM_SSECTION_DIRNOTCREATED;
    }
    if (smartsection_admin_getPathStatus('content', true) < 0) {
        $thePath = smartsection_getUploadDir(true, 'content');
        $res = smartsection_admin_mkdir($thePath);
        $msg = $res ? _AM_SSECTION_DIRCREATED : _AM_SSECTION_DIRNOTCREATED;
    }
}
Esempio n. 2
0
/**
* Thanks to the NewBB2 Development Team
*/
function smartsection_admin_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 (smartsection_admin_mkdir(substr($target, 0, strrpos($target, '/')))) {
        if (!file_exists($target)) {
            $res = mkdir($target, 0777);
            // crawl back up & create dir tree
            smartsection_admin_chmod($target);
            return $res;
        }
    }
    $res = is_dir($target);
    return $res;
}