<?php
	function copydir($source, $destination, $chmod = 0755)
	{
		if(!is_dir($destination))
		{
			$oldumask = umask(0); 
			mkdir($destination, $chmod); // so you get the sticky bit set 
			umask($oldumask);
		}
		$dir_handle = opendir($source) or die("Unable to open");
		while ($file = readdir($dir_handle)) 
		{
			if($file!="." && $file!=".." && !is_dir("$source/$file"))
				copy("$source/$file", "$destination/$file");
		}
		closedir($dir_handle);
	}
?>