<?

/************************************************************************/
/* 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 validnew() {
        global $prefix, $offset, $gallerypath, $adminurl, $basepath, $font, $temppath;

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

          echo "<br>";
          OpenTable();


        echo "
        <form method=\"POST\" action=\"admin.php\">
        <input type=\"hidden\" name=\"op\" value=\"4nalbum\">
        <input type=\"hidden\" name=\"do\" value=\"validnew\">
        <input type=\"hidden\" name=\"type\" value=\"validate\">

        <table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
          <tr>";
        //$sql = "SELECT gallname FROM $prefix"._4nalbum_categories." WHERE gallid=$gid";
        //list ($gallname) = mysql_fetch_row(mysql_query($sql));

        $sql = "SELECT count(*) FROM $prefix"._4nalbum_pictures_newpicture."";
        $result = mysql_query($sql);

        $limit = 5;
        echo "<input type=\"hidden\" name=\"limit\" value=\"$limit\">";
        list($numrows) = mysql_fetch_row($result);

        if ($numrows>0) {

                if (!isset($offset) || $offset=="") {
                        $offset=0;
                }
                $pages = intval($numrows/$limit);

                $sql = "SELECT pid, gid, img, submitter, date, name, description, width, height FROM $prefix"._4nalbum_pictures_newpicture." limit $offset, $limit";
                //echo $sql;
                $res = mysql_query($sql);



                if ($numrows%$limit) {
                        $pages++;
                }

                for ($i=1;$i<=$pages; $i++) {
                        $newoffset=$limit*($i-1);
                        if ($newoffset==$offset) {
                                $nav .= "[$i]";
                                $end = $limit*$i;
                                if ($end>$numrows)
                                        $end = $numrows;
                        }
                        else {
                                $nav .= "[<a class=\"".$font['normal']."\" href=\"$adminurl&amp;do=validnew&amp;type=checknew&amp;offset=$newoffset\">$i</a>]";
                        }
                }
                $deb = $offset+1;

                 echo "
                    <td width=\"100%\" align=\"center\"><font class=\"".$font['title']."\">
                        "._GALNOWDISPLAYFILES." $deb - $end of $numrows<br>
                        "._GALJUMP2PAGE." $nav</font></td></tr>";
                $i=0;
                while (list($pid, $gid, $img, $submitter, $date, $name, $description, $width, $height) = mysql_fetch_array($res)) {

                        $thumb = getThumbnail($img, $temppath);

                        echo "
                          <tr><td width=\"100%\">
                                  <table border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr>
                          <td>
                                <p align=\"left\">
                                        <a href=\"$temppath/$img\" target=\"_new\"><img src=\"$thumb\" border=\"1\"></a><br>
                                        <font class=\"".$font['title']."\">"._GALFILENAME."</font><br>
                                        <input type=\"hidden\" name=\"OldFileName$i\" size=\"14\" value=\"$img\">
                                        <input type=\"text\" name=\"FileName$i\" size=\"14\" value=\"$img\"><br>
                                        <input type=\"hidden\" name=\"FileId$i\" size=\"14\" value=\"$pid\">
                                        <font class=\"".$font['title']."\">
                                        <INPUT TYPE=\"radio\" NAME=\"Task$i\" VALUE=\"Validate\" checked><font class=\"tiny\">"._GALVALIDNEW."</font><br>
                                        <INPUT TYPE=\"radio\" NAME=\"Task$i\" VALUE=\"Delete\"><font class=\"tiny\">"._GALDELETE."</font>
                                        </td>
                                            <td align=\"left\" valign=\"top\">
                                        <font class=\"".$font['title']."\">"._GALSELECTCATEGORY."</font><br>
                                            <select name=\"Category$i\">";

                                        $categories = listcategories("$gallerypath");
                                        $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 ($j=0; $j<$nbtabs; $j++)
                                                        $tab .= "&nbsp;&nbsp;";
                                                if ($gallid==$gid)
                                                        echo "<option selected value=\"$gallid\">$tab$gallname</option> ";
                                                else
                                                        echo "<option value=\"$gallid\">$tab$gallname</option> ";
                                         }
                            echo "</select><br>
                                 <font class=\"".$font['title']."\">"._GALWIDTHXHEIGHT."</font><br>
                                <input type=\"text\" name=\"Width$i\" size=\"4\" value=\"$width\"> x <input type=\"text\" name=\"Height$i\" size=\"4\" value=\"$height\"><br>
                                <font class=\"".$font['title']."\">"._GALMEDIANAME."</font><br>
                                <input type=\"text\" name=\"MediaName$i\" size=\"14\" value=\"$name\"><br>
                                <font class=\"".$font['title']."\">"._GALDATEADDED."<br></font>
                                        <input type=\"text\" name=\"Date$i\" size=\"14\" value=\"$date\"><br>
                                <font class=\"".$font['title']."\">"._GALSUBMITTER."</font><br>
                                        <input type=\"text\" name=\"Submitter$i\" size=\"14\" value=\"$submitter\"></td>
                                        <td align=\"left\" valign=\"top\" width=\"609\">
                                <font class=\"".$font['title']."\">"._GALDESCRIPTION."</font><br>
                                <textarea  name=\"Description$i\" rows=\"9\" cols=\"25\">$description</textarea>
                                  </td></tr>
                          </table>
                              </td>
                                  </tr>";
                        $i++;
                } //while
                echo "
                <tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" value=\""._SAVECHANGES."\" name=\"add\"></form>";
        }
        else
                echo "<tr><td align=\"center\" colspan=\"2\"><br><font class=\"".$font['normal']."\">미디어가 발견되지 않습니다.</font><br>";

        echo "</td></tr></table></form>";
        CloseTable();
        print '<br>';
        adminFooter();
}


?>