/** * Copy file taking into account accessibility via php/ftp * * @param string $source source file * @param string $dest destination file/directory * @return boolean true if directory copied correctly, false - otherwise */ function fn_copy($source, $dest) { $result = false; $file_name = basename($source); if (!file_exists($dest)) { if (basename($dest) == $file_name) { // if we're copying the file, create parent directory fn_uc_mkdir(dirname($dest)); } else { fn_uc_mkdir($dest); } } fn_echo(' .'); if (is_writable($dest) || is_writable(dirname($dest)) && !file_exists($dest)) { if (is_dir($dest)) { $dest .= '/' . basename($source); } $result = copy($source, $dest); fn_uc_chmod_file($dest); } if (!$result) { // try ftp $result = fn_uc_ftp_copy($source, $dest); } return $result; }
/** * Copy file taking into account accessibility via php/ftp * * @param string $source source file * @param string $dest destination file/directory * @return boolean true if directory copied correctly, false - otherwise */ function fn_uc_copy($source, $dest) { $result = false; $file_name = fn_basename($source); if (!file_exists($dest)) { if (fn_basename($dest) == $file_name) { // if we're copying the file, create parent directory fn_uc_mkdir(dirname($dest)); } else { fn_uc_mkdir($dest); } } fn_echo(' .'); if (is_writable($dest) || is_writable(dirname($dest)) && !file_exists($dest)) { if (is_dir($dest)) { $dest .= '/' . fn_basename($source); } $result = copy($source, $dest); fn_uc_chmod_file($dest); } if (!$result && is_resource(Registry::get('ftp_connection'))) { // try ftp $result = fn_uc_ftp_copy($source, $dest); } if (!$result) { fn_set_notification('E', __('error'), __('cannot_write_file', array('[file]' => $dest))); } return $result; }
public static function checkUpgradePermissions($upgrade_dirs, $is_writable = true) { foreach ($upgrade_dirs as $upgrade_dir) { if (is_array($upgrade_dir)) { $is_writable = self::checkUpgradePermissions($upgrade_dir, $is_writable); } elseif (!is_dir($upgrade_dir)) { fn_uc_mkdir($upgrade_dir); self::checkUpgradePermissions(array($upgrade_dir), $is_writable); } elseif (!self::isWritableDest($upgrade_dir)) { return false; } if (!is_array($upgrade_dir)) { $check_result = array(); fn_uc_check_files($upgrade_dir, array(), $check_result, '', ''); $is_writable = empty($check_result); } if (!$is_writable) { break; } } return $is_writable; }
/** * Copy file taking into account accessibility via php/ftp * * @param string $source source file * @param string $dest destination file/directory * @return boolean true if directory copied correctly, false - otherwise */ function fn_uc_copy($source, $dest) { $result = false; $file_name = basename($source); if (!file_exists($dest)) { if (basename($dest) == $file_name) { // if we're copying the file, create parent directory fn_uc_mkdir(dirname($dest)); } else { fn_uc_mkdir($dest); } } fn_echo(' .'); if (fn_uc_is_writable_dest($dest) || fn_uc_is_writable_dest(dirname($dest)) && !file_exists($dest)) { if (is_dir($dest)) { $dest .= '/' . basename($source); } $result = copy($source, $dest); @chmod($dest, DEFAULT_FILE_PERMISSIONS); } else { // try ftp $result = fn_uc_ftp_copy($source, $dest); } return $result; }