function sl_copyr($source, $dest)
{
    // Check for symlinks
    if (is_link($source)) {
        return symlink(readlink($source), $dest);
    }
    // Simple copy for a file
    if (is_file($source)) {
        return copy($source, $dest);
    }
    // Make destination directory
    if (!is_dir($dest)) {
        mkdir($dest, 0755);
    }
    // Loop through the folder
    $dir = dir($source);
    while (false !== ($entry = $dir->read())) {
        // Skip pointers
        if ($entry == '.' || $entry == '..') {
            continue;
        }
        // Deep copy directories
        sl_copyr("{$source}/{$entry}", "{$dest}/{$entry}");
    }
    // Clean up
    $dir->close();
    return true;
}
function sl_move_upload_directories()
{
    global $sl_uploads_path, $sl_path;
    $sl_uploads_arr = wp_upload_dir();
    if (!is_dir($sl_uploads_arr['baseurl'])) {
        mkdir($sl_uploads_arr['baseurl'], 0755, true);
    }
    if (!is_dir(SL_UPLOADS_PATH)) {
        mkdir(SL_UPLOADS_PATH, 0755, true);
    }
    if (is_dir(SL_ADDONS_PATH_ORIGINAL) && !is_dir(SL_ADDONS_PATH)) {
        sl_copyr(SL_ADDONS_PATH_ORIGINAL, SL_ADDONS_PATH);
        chmod(SL_ADDONS_PATH, 0755);
    }
    if (is_dir(SL_THEMES_PATH_ORIGINAL) && !is_dir(SL_THEMES_PATH)) {
        sl_copyr(SL_THEMES_PATH_ORIGINAL, SL_THEMES_PATH);
        chmod(SL_THEMES_PATH, 0755);
    }
    if (is_dir(SL_LANGUAGES_PATH_ORIGINAL) && !is_dir(SL_LANGUAGES_PATH)) {
        sl_copyr(SL_LANGUAGES_PATH_ORIGINAL, SL_LANGUAGES_PATH);
        chmod(SL_LANGUAGES_PATH, 0755);
    }
    if (is_dir(SL_IMAGES_PATH_ORIGINAL) && !is_dir(SL_IMAGES_PATH)) {
        sl_copyr(SL_IMAGES_PATH_ORIGINAL, SL_IMAGES_PATH);
        chmod(SL_IMAGES_PATH, 0755);
    }
    if (!is_dir(SL_CUSTOM_ICONS_PATH)) {
        mkdir(SL_CUSTOM_ICONS_PATH, 0755, true);
    }
    if (!is_dir(SL_CUSTOM_CSS_PATH)) {
        mkdir(SL_CUSTOM_CSS_PATH, 0755, true);
    }
    if (!is_dir(SL_CACHE_PATH)) {
        mkdir(SL_CACHE_PATH, 0755, true);
    }
    sl_ht(SL_CACHE_PATH, 'ht');
    sl_ht(SL_ADDONS_PATH);
    sl_ht(SL_UPLOADS_PATH);
}
Exemple #3
0
/**
 * Copy a file, or recursively copy a folder and its contents
 *
 * @author      Aidan Lister <*****@*****.**>
 * @version     1.0.1
 * @param       string   $source    Source path
 * @param       string   $dest      Destination path
 * @return      bool     Returns TRUE on success, FALSE on failure
 */
function sl_copyr($source, $dest)
{
    // Simple copy for a file
    if (is_file($GLOBALS['where_files_relative'] . $source)) {
        return sl_copy($source, $dest);
    }
    // Make destination directory
    if (!is_dir($GLOBALS['where_files_relative'] . $dest)) {
        sl_mkdir($dest);
    }
    // Loop through the folder
    $dir = dir($GLOBALS['where_files_relative'] . $source);
    while (false !== ($entry = $dir->read())) {
        // Skip pointers
        if ($entry == '.' || $entry == '..') {
            continue;
        }
        // Deep copy directories
        if ($dest !== "{$source}/{$entry}") {
            sl_copyr("{$source}/{$entry}", "{$dest}/{$entry}");
        }
    }
    // Clean up
    $dir->close();
    return true;
}