<?php
$selectedImage = (isset($_POST['selectedImage'])) ? trim($_POST['selectedImage']) : "";
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8" />
<title>EventImages</title>
<meta name="robots" content="noindex,nofollow" />
<style>
.rnd {font-size:large;box-shadow: 3px 4px 5px #888888;color:#333;border-top-left-radius: 8px;border-top-right-radius: 8px;border-bottom-right-radius: 8px;border-bottom-left-radius: 8px;border-width:1px;border-style: solid;border-color:silver;text-align: left;margin:4px 4px 4px 4px;padding:4px 4px 4px 4px;}
</style>
</head>
<body style="margin:0px;padding:0px;background-image:url('0.jpg');background-repeat:no-repeat;background-attachment:fixed;background-size:cover">

<div style="width:100%;float:left;background-color:black;color:white;text-align:center;height:50px">
<span style="font-size:x-large;text-align;center;width:100%"><strong>Our Event Pictures</strong></span>
</div>

<div style="margin:12px;float:left">
<br />
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="selectedImage" id="selectedImage" class="rnd">
<option value="">- Select a Shower Image - </option>
<?php 
$files = scandir('./'); 
 
$c1 = count($files);
$c2 = 0;
 
for($i=0; $i<$c1; $i++)
{
  if(strlen($files[$i]) > 3)
  {
	if ($files[$i] !="0.jpg")
	{
	    $extension = strtolower(substr($files[$i], -4));
	    if(($extension == ".gif") OR ($extension == ".jpg") OR ($extension == ".png"))
	    {
	      echo "<option value=\"".trim($files[$i])."\"";
	      if($selectedImage == $files[$i]) echo " selected=\"selected\"";
	      echo ">".$files[$i]."</option>\n";
	     $c2++;
	    }
	}
  }
}
 
?>
</select>
<input type="submit" value="Select" class="rnd"/>
</form>
<br />
<?php echo "<span style=\"color:white;float:left\">Total images = ".$c2."</span>"; ?>
<br /><br />
<?php
if(!empty($selectedImage))
{
  ?>
<a href="<?php echo $selectedImage ?>" title="<?php echo $selectedImage ?>">
  <img src="<?php echo $selectedImage ?>" alt="" class="rnd" style="width:50%;float:left;margin:8px"/></a>
  <br /><br />
<div class="rnd" style="position:absolute;right:5px;top:5px;background-color:white;padding:8px">
  <?php
  list($width, $height) = getimagesize("$selectedImage");
  echo "width = ".$width."<br />";
  echo "height = ".$height."<br />";
}
?></div></div>
</body>
</html>