<html><head></head><body>
<?php

  $d = "/home/abu-jeib/temp2/";
  $time_limit = 2 * 60 * 60;

  $valid_type = array("gif","jpg","jpeg","png","bmp");
  $file = "/home/abu-jeib/temp/images.txt";
  $dir = opendir($d) or exit("Can't open the directory");
  @ $f = fopen('/home/abu-jeib/temp/images.txt','w') or exit("ERROR: file can't be opened.<P>\n");
  
  fwrite($f,"File \t\t\t\t Modification Date\n");
  echo "<center><table border='1'><tr><td><b>File</b></td><td><b>Modification Date</b></td></tr>\n";
  while ($file_name = readdir($dir))
  {
	$file = $d.$file_name;
	$time_diff = time() - filemtime($file);
	if ($time_diff <= $time_limit)
	{

		$wanted = false;
	      	if (is_readable($file))
		{
			// Reverse the file name to get the extension
			$x = strrev($file_name);
			$y = split("\.",$x);
			$ext = strrev($y[0]);
			$lowercase_ext = strtolower($ext);
			// Check if the extension is wanted
			if (in_array($lowercase_ext,$valid_type))
				$wanted = true;
      		}
		if ($wanted)
		{
			$formatted_date = date('l, F j, Y g:i:s A T',filemtime($file));
			fwrite($f,$file."\t". $formatted_date."\n");
			echo "<tr><td>$file</td><td>$formatted_date</td></tr>\n";
		}
	}
}
echo "</table></center>\n";
@closedir($dir);
@fclose($f);
?>

</body>
</html>
