GrViewer: Graphics Files Viewer

<?php
  ////////////////////////////////////////////////////////////////////////////
  // grviewer.php
  //
  // utility to display in a single Web page all graphical images in the 
  //   directory in which this utility resides as a Web page; intended to 
  //   provide a quick reference to all available graphical images, 
  //   particularly those with less-than-descriptive file names
  //
  // Written 4/14/2012, L.Pritchett, Cliffson Solutions, LLC
  // Revised 4/14/2012, L.Pritchett, Cliffson Solutions, LLC
  ////////////////////////////////////////////////////////////////////////////

  $aGRAPHICS_EXTENSIONS = array ("gif", "png", "jpg", "jpeg");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >

<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <title>Graphics Viewer</title>
</head>

<body>
  <center>

<?php
  printf("  <h3>Graphics in %s%s</h3>\n", $_SERVER['DOCUMENT_ROOT'],
    pathinfo($_SERVER['REQUEST_URI'], PATHINFO_DIRNAME));

  $hDir = opendir(".");
  while ($sFile = readdir($hDir))
  {
    if (in_array(pathinfo($sFile, PATHINFO_EXTENSION), $aGRAPHICS_EXTENSIONS))
    {
      printf("  <div style=\"border:3px solid #00cccc;margin:20px;" .
        "padding:15px;\">\n");
      printf("    <img src=\"%s\" alt=\"%s\" />\n", $sFile, $sFile);
      printf("    <br />\n");
      printf("    <br />\n");
      printf("    <span style=\"font-weight:bold;color:#770077;\">%s" .
        "</span>\n", $sFile);
      printf("  </div>\n");
    }
  }
  closedir($hDir);
?>

  </center>
</body>
</html>