<?php
	include 'AdminRedirect.php';
	include 'top.php';
	
	$imageDir = "Pictures/SlideShow/";
	$images = glob($imageDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
	$TargetImage;
	$Error = 0;
	
	if (!empty($_POST['SSsubmit'])) {
		if (empty($_POST['SSPicture'])) {
			echo ("<script>alert('Please select a picture');</script>");
			$Error++;
		}
		else {
			$TargetImage = $_POST['SSPicture'];
		}
		
		if ($Error == 0) {
			if (file_exists($TargetImage)) {
				$img = unlink($TargetImage);
				echo ("<script>location.reload();</script>");
			}
		}
	}
?>
<!DOCTYPE html>
<html>
	<head>
    	<link rel="stylesheet" type="text/css" href="body.css">
        <link rel="stylesheet" type="text/css" href="AdminSideBar.css">
    </head>
    <body class="background">
    	<div class="sidebar">
            <div class="infoContainer"><a href="AccountManager.php">Account Manager</a></div>
            <div class="infoContainer"><a href="APhotoManager.php">Photos</a></div>
            <div class="infoContainer"><a href="AReview.php">Review Manager</a></div>
            <div class="infoContainer"><a href="MarketStats.php">Market Stats</a></div>
            <div class="infoContainer"><a href="ALogOut.php">LogOut</a></div>
        </div>
        <div style="float: left; width: 75%; border: 1px solid grey; background-color: black; line-height: 150%; text-align: center;">
        	<form method="post" name="SlideShowRemove">
            	<input type="submit" style="width: 100px; height: 30px; margin: 0px auto; margin-bottom: 20px; border: 3px groove white; background-color: black; color: white;" name="SSsubmit" value="Remove">	
            	<?php
					echo ("<ul style='margin: auto;'>");
					foreach ($images as $value) {
						echo ("<li style='display: inline-table; padding: 10px; text-align: center;'><input type='radio' name='SSPicture' value='".$value."' /><img class='img' style='position: relative; border: 5px groove grey; border-radius: 15px; height: 200px; ' src='".$value."' alt='Gallery Photo'></img></li>");
					}
				?>
                
            </form>
        </div>
        <div class="sidebarRight">
            <div class="infoContainer"><a href="ASlideShowRemove.php">SlideShow</a></div>
            <div class="infoContainer"><a href="AGalleryRemove.php">Gallery</a></div>
        </div>
    </body>
</html>