<?

/************************************************************************/
/* 4nAlbum Version 0.9                                                  */
/* ==================================================================== */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

function createmedia($pid="") {
        global $prefix, $galleryvar,$bgcolor1, $gallerypath, $adminurl, $font;

        galleryHeader();
        navigationAdmin("<a class=\"".$font['title']."\" href=\"$adminurl\">"._GALCONFIG."</a><font class=\"".$font['title']."\"> &gt; "._GALINSERTNMEDIA."</font>");

          echo "<br>";
          OpenTable();
        $categories = listcategories("$gallerypath");
          if($categories != ""){
                  echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
                        <tr>
                                <td>
                                        <form method=\"POST\" action=\"$adminurl\" enctype=\"multipart/form-data\">
                                        <input type=\"hidden\" name=\"do\" value=\"editmedia\">
                                        <input type=\"hidden\" name=\"type\" value=\"new\">
                                </td>
                          <tr>
                        <td width=\"100%\" bgcolor=\"$bgcolor1\">
                                 <table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" ><tr>
                                   <td align=\"left\" valign=\"top\" >
                                        <font class=\"".$font['title']."\">"._GALSELECTCATEGORY."</font><br>
                                    <select name=\"Category\">";
                $categories = explode(" ", trim($categories));
                while(list($key, $val) = each($categories)) {
                        $result = mysql_query("select gallid, gallname, parent from $prefix"._4nalbum_categories." where gallid=".$val);
                        list($gallid, $gallname, $parent) = mysql_fetch_row($result);
                        $nbtabs = indent($gallid);
                        $tab = "";
                        for($k=0; $k<$nbtabs; $k++)
                                $tab .= "&nbsp;&nbsp;";
                        echo "        <option value=\"$gallid\">$tab$gallname</option>\n";
                }
              echo "                </select><br>
                                        <font class=\"".$font['title']."\">"._GALMEDIANAME."<br></font>
                                        <input type=\"text\" name=\"MediaName\" size=\"14\" value=\"\"><br>
                                        <font class=\"".$font['title']."\">"._GALFILENAME."</font><br>";
               if ($galleryvar['limitSize'])
                        echo "        <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$maxSize\">";
                echo "
                                        <input type=\"file\" name=\"userfile\" size=\"14\"><br>
                                        <font class=\"".$font['title']."\">"._GALSUBMITTER."</font><br>
                                        <input type=\"text\" name=\"Submitter\" size=\"14\" value=\"\"><br>
                                     </td>
                                     <td align=\"left\" valign=\"top\">
                                                <font class=\"".$font['title']."\">"._GALDESCRIPTION."</font><br>
                                                <textarea  name=\"Description\" rows=\"9\" cols=\"25\"></textarea>
                                             </td>
                                </tr>
                                <tr>
                                        <td align=\"center\"><input type=\"submit\" value=\"Insert\" name=\"add\"></td>
                                </tr>
                                  </table>
                              </td>
                        </tr>
                        </form>
                          </table>";
        }
        else {
                  echo "
                        <p align=\"center\">
                        <font class=\"".$font['title']."\">
                                No Categories Found
                        </font>
                        </p>";
          }

        CloseTable();

          print '<br>';
        adminFooter();
}
?>