Esempio n. 1
0
 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;
     }
 }
Esempio n. 2
0
/**
 * Copy a file, or a folder and its contents
 *
 * @author      Aidan Lister <*****@*****.**>
 * @version     1.0.0
 * @param  string $source The source
 * @param  string $dest   The destination
 * @return bool   Returns true on success, false on failure
 */
function publisherCopyr($source, $dest)
{
    // Simple copy for a file
    if (is_file($source)) {
        return copy($source, $dest);
    }
    // Make destination directory
    if (!is_dir($dest)) {
        mkdir($dest);
    }
    // Loop through the folder
    $dir = dir($source);
    while (false !== ($entry = $dir->read())) {
        // Skip pointers
        if ($entry === '.' || $entry === '..') {
            continue;
        }
        // Deep copy directories
        if ($dest !== "{$source}/{$entry}" && is_dir("{$source}/{$entry}")) {
            publisherCopyr("{$source}/{$entry}", "{$dest}/{$entry}");
        } else {
            copy("{$source}/{$entry}", "{$dest}/{$entry}");
        }
    }
    // Clean up
    $dir->close();
    return true;
}