function cw_cpanel_install_dirs()
{
    $args = func_get_args();
    $installation_path = array_shift($args);
    $ret = true;
    if (is_array($args)) {
        foreach ($args as $dir) {
            $new_path = $installation_path . '/' . $dir;
            if (cw_core_create_dirs(array($new_path), $tmp)) {
                cw_cpanel_install_show_status('create_dir', $dir, true);
            } else {
                cw_cpanel_install_show_status('create_dir', $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;
}