<?php

/*
Dealing with directories is similar to dealing with files. You have to 
open them, process their contents with a loop 
and using a read function, and close them. 
*/
  $d = "/home/abu-jeib/temp/";
  $dir = opendir($d) or exit("Can't open the directory"); // similar to fopen()
  echo "<p>Files in directory $d:</p><ol>";
  while ($file = readdir($dir))
  {
      	echo "<li>$file:<BR>";
	$file = $d.$file;
	echo "Path: $file<br>";
	echo 'File last accessed: ', date('M d, y H:i:s',fileatime($file)), '.<br>';
	//echo date(fileatime($file)), "<br>";
	echo fileatime($file), "<br>";
  	echo 'File last modified: ', date('M d, y H:i:s',filemtime($file)), '.<br>';

  	$user = posix_getpwuid(fileowner($file));
  	echo 'File owner: ', $user['name'], '.<br>';
  	$group = posix_getgrgid(filegroup($file));  
  	echo 'File group: ', $group['name'], '.<br>';
  	echo 'File permissions: ', decoct(fileperms($file)), '.<br>';
  	echo 'File type: ', filetype($file), '.<br>';
  	echo 'File size: ', filesize($file), ' bytes.<br>';

  	echo 'Is executable? ', (is_executable($file)? 'true' : 'false').'<br>';
	echo 'Is readable? ', (is_readable($file)? 'true' : 'false').'<br>';
        echo 'Is writable? ', (is_writable($file)? 'true' : 'false').'<br>';
	echo 'Is dir? ', (is_dir($file)? 'true' : 'false').'<br>';
  	echo 'Is file? ', (is_file($file)? 'true' : 'false').'<br>';
 	echo 'Is link? ', (is_link($file)? 'true' : 'false').'<br>';
  }
  echo '</ol>';
  closedir($dir); // similar to fclose()

	// exec("mkdir /home/abu-jeib/temp/new"); // You can do that
					   // If exists, warning.
	 // mkdir("/home/abu-jeib/temp/new",0755); // You can do that
	// rmdir("/home/abu-jeib/temp/new"); You can do that for Unix
	// rmdir("c:\\temp\\new"); // You can do that for Windows


?>

