function my_copy($oldname, $newname)
{
    if (is_file($oldname)) {
        $perms = fileperms($oldname);
        return copy($oldname, $newname) && chmod($newname, $perms);
    } else {
        if (is_dir($oldname)) {
            my_dir_copy($oldname, $newname);
        } else {
            die("Cannot copy file: {$oldname} (it's neither a file nor a directory)");
        }
    }
}
function wp_copy($oldname, $newname)
{
    if (is_file($oldname)) {
        return copy($oldname, $newname);
    } else {
        if (is_dir($oldname)) {
            my_dir_copy($oldname, $newname);
        } else {
            die("Cannot copy file: {$oldname} (it's neither a file nor a directory)");
        }
    }
}