function cw_cpanel_install_files() { global $var_dirs; $args = func_get_args(); $installation_path = array_shift($args); $ret = true; if (is_array($args)) { foreach ($args as $file) { $file_path = $var_dirs['repository'] . '/' . $file; $new_path = $installation_path . '/' . $file; if (is_file($file_path) && @copy($file_path, $new_path)) { cw_cpanel_install_show_status('copy', $file, true); } elseif (is_dir($file_path)) { $files = array(); $res = cw_core_copy_dir($file_path, $new_path, $files); cw_cpanel_install_show_status('copy', $file, $res); if (is_array($files)) { foreach ($files as $file) { cw_cpanel_install_show_status('copy', $file, false); } $ret = false; } } else { cw_cpanel_install_show_status('copy', $file, false); $ret = false; } } } return $ret; }
function cw_core_copy_dir($srcdir, $dstdir, &$result) { $status = true; if (!($handle = opendir($srcdir))) { return false; } while ($status && ($file = readdir($handle)) !== false) { if ($file == '.' || $file == '..') { continue; } if (!file_exists($dstdir)) { $status = $status && cw_core_create_dirs(array($dstdir), $result); } if (!$status) { break; } if (is_file($srcdir . DIRECTORY_SEPARATOR . $file)) { if (!@copy($srcdir . DIRECTORY_SEPARATOR . $file, $dstdir . DIRECTORY_SEPARATOR . $file)) { $result[] = $dstdir . DIRECTORY_SEPARATOR . $file; $status = false; } else { @chmod($dstdir . DIRECTORY_SEPARATOR . $file, 0666); } } elseif (is_dir($srcdir . DIRECTORY_SEPARATOR . $file) && $file != "." && $file != "..") { if (!file_exists($dstdir . DIRECTORY_SEPARATOR . $file)) { if (!file_exists($dstdir)) { $status = $status && cw_core_create_dirs(array($dstdir), $result); } $status = $status && cw_core_create_dirs(array($dstdir . DIRECTORY_SEPARATOR . $file), $result); } $status = $status && cw_core_copy_dir($srcdir . DIRECTORY_SEPARATOR . $file, $dstdir . DIRECTORY_SEPARATOR . $file, $result); } } closedir($handle); return $status; }