Exemplo n.º 1
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;
}
Exemplo n.º 2
0
 function privDirCheck($p_dir, $p_is_dir = false)
 {
     $v_result = 1;
     // ----- Remove the final '/'
     if ($p_is_dir && substr($p_dir, -1) == '/') {
         $p_dir = substr($p_dir, 0, strlen($p_dir) - 1);
     }
     // ----- Check the directory availability
     if (sl_is_dir($p_dir) || $p_dir == "") {
         return 1;
     }
     // ----- Extract parent directory
     $p_parent_dir = dirname($p_dir);
     // ----- Just a check
     if ($p_parent_dir != $p_dir) {
         // ----- Look for parent directory
         if ($p_parent_dir != "") {
             if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) {
                 return $v_result;
             }
         }
     }
     // ----- Create the directory
     if (!@sl_mkdir($p_dir, 0777)) {
         // ----- Error log
         PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '{$p_dir}'");
         // ----- Return
         return PclZip::errorCode();
     }
     // ----- Return
     return $v_result;
 }