<?php
session_start();
if($_SESSION['name']){
 echo"<br>" . "Bienvenue sur la gestion de documents de l'application SSR Marc Sautelet!" ."<br>". "Username: " . $_SESSION['name'] ."<p>";
 if($_SESSION['name'] == "Administrateur")
 {
	 echo "<a href='register.php'>Click here to register a new member</a>" ."<p>";
	 echo "<a href='deleteMember.php'>Click here to delete a member</a>" ."<p>";
 }
 echo "<a href='logout.php'>Click here to logout</a>";
}else header('Location: index.php');
?>
<html>
<table>
    <tr>
 <form action="create_file.php" method="post">
 <P><FONT face="Verdana" color="black" size="4">Create new HTML File</FONT>
  <br><br>File name: <input type="text" name="name" required>
  <input type="submit" value="Create File">
  </form>
    </tr>
    <tr>
        <td>
        <form action="upload.php" method="POST"enctype="multipart/form-data">
        <P><FONT face="Verdana" color="black" size="4">Upload new file (.html, .jpg, .png...)</FONT>
         <br><br><input type="file" name="upload" required>
        <input type="submit" value="Save">
        </form>
        </td>
    </tr>
</table>
<br><P><FONT face="Verdana" color="blue" size="3">List of files</FONT><br>
<P><FONT face="Verdana" color="#FF3300" size="2">HTML Files:</FONT><br>
<?php
  foreach (glob("*.html") as $file){ 
  echo "<a href='$file'target='_blank'>$file</a> ---> <a href='edit.php?name=$file'>Edit</a> ---> <a href='delete.php?name=$file'>Delete</a>" . "<br>";
 }
?>
<P><FONT face="Verdana" color="#FF3300" size="2">Images Files:</FONT><br>
<?php
  foreach (glob("*.{jpg,jpeg,gif,png,PNG,GIF,JPG,JPEG}", GLOB_BRACE) as $file){ 
  echo "<a href='$file' target='_blank'>$file</a> ---> <a href='delete.php?name=$file'>Delete</a>" . "<br>";
 }
?>
</html>
