<?php
session_start();
if(!isset($_SESSION["username"]) || $_SESSION["username"] == '' ){
header("Location: login.php");
exit();
}
else {

include('functions.php');


?>
<!DOCTYPE html>
<html>
<head>

  <style>
    @import url(http://weloveiconfonts.com/api/?family=iconicfill);[class*="iconicfill-"]::before{font-family:'IconicFill',sans-serif;font-size:1.2rem}
    *{box-sizing:border-box}
    html,body,.dashboard{margin:0;padding:0}
    ul,ul li{padding:0}
    html,body,input,textarea{font:300 1rem sans-serif}
    h1,h2{color:#333}
    h1{font:700 1.75rem sans-serif;border-bottom:.5rem solid #2c3e50;margin:0 0 2rem 0}
    h2{font:700 1.5rem sans-serif;margin:0 0 1rem 0}
    h3{font-weight:500}
    p{margin:0 0 1rem 0}
    .dashboard{font:300 1rem sans-serif;display:flex;flex-flow:row wrap;height:auto}
    aside{background:#2c3e50;flex:2 1 0%;order:1}
    aside li a,aside .search{display:block;color:#ecf0f1;text-decoration:none;padding:1rem;border-bottom:1px solid #34495e;transition:background 0.15s ease}
    aside li a:hover,aside li a:active,aside li a:focus,aside .search:hover,aside .search:active,aside .search:focus{background:#34495e}
    aside li a::before,aside .search::before{display:inline-block;width:1.5rem}
    aside .search input{width:80%}
    main{background:#ecf0f1;flex:6 1 0%;order:2;padding:1rem 0 1rem 1rem}
    main .overview{min-height:100vh}
    main .overview .widget-container{display:flex;flex-flow:row wrap}
    main .overview .widget-container .widget{background:#bdc3c7;flex:6 1 0%;margin:0 1rem 1rem 0;min-width:15rem}
    main .overview .widget-container .widget header{background:#2c3e50;color:#ecf0f1;padding:3px 0 3px 30px}
    main .overview .widget-container .widget header h3::before{display:inline-block;width:1.5rem}
    main .overview .widget-container .widget .content{padding:1rem}
    main .overview .widget-container .widget .content li{list-style-type:square;margin:0 0 0 1rem}
    main .overview .widget-container .widget .content .ok::before{content:'';display:inline-block;width:1rem;height:1rem;background:#27ae60;border-radius:50%;margin:0 1rem 0 0}
    main .overview .widget-container .widget .content .no::before{content:'';display:inline-block;width:1rem;height:1rem;background:red;border-radius:50%;margin:0 1rem 0 0}
    main footer p{text-align:right;font-size:.85rem}
    .col {width:50%;float:left;}
    .addbutton {text-decoration:none;color:green;margin-top:-45px;margin-right:10px;float:right;padding:5px 10px;background:#fff;border-radius:5px;}
    table.tg {width:100%}
    table th {padding:5px;background:#b4b8bb;border-bottom:1px solid #dbe1e4;}
    table td {padding:5px;border-bottom:1px solid #dbe1e4;text-align:center;}
    .imagesbox {width:100%;display:block;position:relative;overflow:hidden;}
    .oneimage {width:31%;height:300px;float:left;overflow:hidden;margin:10px 1%;padding:0;}
    .oneimage img {width:100%;height:auto;}
    .oneimage input {width:100%;background:#333;color:#eee;padding:3px;border:0;}
  </style>

</head>
<body>


  <div class="dashboard">
    <main>
      <div class="overview">
        <h1>Images</h1>

        <div class="imagesbox">
        <?php
        if ($handle = opendir('./uploads')) {

            while (false !== ($entry = readdir($handle))) {

                if ($entry != "." && $entry != "..") {
        ?>
        <div class="oneimage">

          <input type=text value="admin/uploads/<?php echo $entry; ?>">
          <img src="uploads/<?php echo $entry; ?>">

        </div>
        <?php        }
            }

            closedir($handle);
        }
        ?>
        </div>

      </div>
      <footer>
        <p>@sabry</p>
      </footer>
    </main>
    <aside>
      <ul>
        <li><a class="iconicfill-home" href="index.php">Overview</a></li>
        <li><a class="iconicfill-document-alt-fill" href="images.php">Images</a></li>
        <li><a class="iconicfill-user" href="logout.php?logout=1">Logout</a></li>
      </ul>
    </aside>
  </div>

</body>
</html>
<?php
}
?>
