<?php 
	
	$dir= getcwd();
		
	$comparedate= date('d-m-Y');  
	//$comparedate= "19-01-2014";  
	
	$str.= directory_tree($dir,$comparedate,1);

	if($str != "")
	{
		$table ="<table border='1px'  align='center'><tr style='text-align:center;font-weight:bold;background-color:#AFBDD1'><td>Folder Name</td><td>File Name</td><td>Modified Date&Time </td><td>Size</td><td>Level</td></tr>";	
		echo $body = $table.$str."</table>";
		
		$from = $_SERVER['HTTP_HOST'];
		$subject = "Last Modified Files : - ".$from;
		
		$headers = "From: ".$from."\r\n"; 
				
		$headers .= "MIME-Version: 1.0\r\n";
		$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
		
	
		$to 		= 'phpfounder@gmail.com';
		$to_admin1 	= 'hemen@auminfosys.com';
		$to_admin2 	= 'jatin@auminfosys.com';
		$to_1 = 'nirav@auminfosys.com';
		@mail($to_1, $subject, $body, $headers);
		@mail($to, $subject, $body, $headers);
		@mail($to_admin1, $subject, $body, $headers);
		@mail($to_admin2, $subject, $body, $headers);
	}
	
	
	function directory_tree($address,$comparedate,$folderLevel)
	{
		$string= "";
		
		$folderLevel ++;
		@$dir = opendir($address);
		if(!$dir){ return 0; }
		
		$array = array("menu","report");
		
		while($entry = readdir($dir))
		{
			
			if(is_dir("$address/$entry") && ($entry != ".." && $entry != "." &&  in_array($entry,$array) != true))
			{   
				$string.=directory_tree("$address/$entry",$comparedate,$folderLevel);
			}
			else
			{
				if($entry != ".." && $entry != "." && in_array($entry,$array) != true)
				{
					$fulldir=$address."/".$entry;
					$last_modified = filemtime($fulldir);
					//$parent = basename(dirname($_SERVER['PHP_SELF']));
					$main= realpath(dirname(__DIR__));
					$folder = str_replace($main,'',realpath(dirname($fulldir)));
					
					//$folder=basename(dirname($fulldir));
					$size=filesize($fulldir);
					$last_modified_str= date("d-m-Y", $last_modified);
					$file= basename($fulldir);
					if($last_modified_str == $comparedate)
					{
						$string.= "<tr><td>".$folder."</td>";
						$string.= "<td>".$file."</td>";
						$string.= "<td>".date("d-m-Y h:i:s a", $last_modified)."</td>";
						$string.= "<td align='center'>".$size."</td>";
						$string.= "<td align='center'>".($folderLevel-1)."</td>";
						$string.= "</tr>";
					}
				}
			}
		}
		return $string;
	}
	?>
