<?php
print "<title>Welcome To Ashfaq Ahmed Script Copier Or Directory Cloner</title>";





class CloneOrCopy
{

			var $des;
			var $src;

  			function CreateCopy()
  			{
      			$des = $this->des;
      			$src = $this->src;
  				$stylestart = "<br><br><br><br><br><br><br><br><br><br><br><br><center><span style='font-family: verdana; font-size: 20px;'>";
  				//$styleend = "</span></center>";
				if($src != "" and $des != "")
  				{

                    if(is_dir($src))
                    {
                    	if(!file_exists($des))
  						{
                			 mkdir($des);
  						}
		                	$hns = opendir($src);
							$dir = $src;
								while($file = readdir($hns))
								{
		                 				if($file != "." and $file != "..")
		                 				{
		                        			$GetCorrect = $dir."/".$file;
		                        			$GetsIn = $des."/".$file;
		                 						if(filetype($GetCorrect) == "dir")
		                 						{
		        	         							if(!file_exists($des."/".$file))
		    	             							{
		 	            	        					mkdir($des."/".$file);
		            	         						}
		                     					}
		                     					else
		                     					{
			                     					if(!file_exists($des."/".$file))
			                 						{
			                     						$f = fopen($des."/".$file, "w");
				                     					$GetRight = $des."/".$file;
														copy($GetCorrect, $GetRight);

			                     					}

		                     					}

			                       				if(filetype($GetCorrect) == "dir")
			                       				{
			                        				CreateCopy($des."/".$file, $src."/".$file);
			                        			}
		                 				}

								}

					}
					else
					{
                     	if(file_exists($src))
                     	{
                     	copy($src, $des);
                     	print $stylestart."File Copied";
						}
                     	else
                     	{
                     	print $stylestart."Ashfaq's Function Error! <br>  Sorry Source File Not Found";
                     	}
					}
				}
				else
				{
				print $stylestart."Ashfaq's Function Error! <br> Please Enter Correct Source And Correct Detination For Copying.";
				}


  			}
}

  ////////////////// Destination        ////////// source ///////

  ////////////// Both Can Be File Or Can Be Folder But Cant Be Empty /////////


/// run the function
//CreateCopy("New", "test");



?>