<?php
   @require_once("functions.php");
   authenticate();
   $config = getConfig();
?>
<html>
   <head>
      <meta http-equiv="Content-type" content="text/html; charset=utf-8">
      <title><?php echo $config['galleryName'];?> | upload</title>
      <link rel="stylesheet" href="admin.css" type="text/css"/>
      <link rel="stylesheet" href="uploader.css" type="text/css"/>
      <script type="text/javascript" src="functions.js"></script>
   </head>
   <body>
     <div id="page">
         <span class="homeLink"><a href="admin.php">&lt;&lt; admin</a></span>
      <hgroup><h1><?php echo $config['galleryName'];?></h1><h2> | upload-o-matic</h2></hgroup>
      <form name="uploader_page1" action="uploader_page2.php?timestamp=<?php echo date('Ymd') . '_' . date('Hi');?>" onsubmit="return uploadToAlbum_validateForm()" method="post">
         <ul id="radioButtons">
         <li><input type="radio" name="albumname" id="createnewalbum" value="createnewalbum" checked="checked"/>
         <label for="createnewalbum">Create a new album titled: </label><input class="textbox" type="text" name="newalbumname" size="100"/></li>
         <input class="bigbutton" type="submit" value="Proceed to upload"/>
<?php
   $albums = array();
   if (file_exists('albums')) {
      foreach (new DirectoryIterator('albums') as $file) {
         if (!$file->isDot() && $file->isDir()) {
            $albums[] = $file->getFilename();
         }
      }
   }
   if (!empty($albums)) {
      echo '         <div class="textTitle">Or add images to existing album:</div>';
      rsort($albums);
      foreach ($albums as $album) {
         echo '<li><input type="radio" name="albumname" id="' . $album.'" value="' . $album.'" /><label for="'.$album.'">'.$album.'</label></li>';
      }
      echo '      <input class="bigbutton" type="submit" value="Proceed to upload"/>';
   }
?>
      </ul>
      </form>
      </div>
   </body>
</html>
