<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: validnewmedia.php,v 1.7.2.2 2004/04/18 12:46:51 ajvwaay Exp $



function validnew()
{
    global $modulepath, $version, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1;
    global $offset, $gallerypath, $adminurl, $basepath, $mpnTables;

    OpenTable();
    echo "<center><font size=\"4\"><b>"._GALADMIN."</b></font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();
    echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td>";

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

          <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
      <tr><td width=\"50%\" align=\"left\">
      <font face=\"Verdana, Arial\" size=\"1\">
      <a href=\"admin.php?fct=gallery\"><b>"._GALCONFIG."</b></a> &gt;
      <b>"._GALVALIDNEWMEDIA."</b>
      </font>
      </td>
      </tr>
      </table>
      </td>
      </tr>
      <tr>";

    $sql = "SELECT count(*) FROM ".$mpnTables['gallery_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 ".$mpnTables['gallery_pictures_newpicture']." limit $offset, $limit";
        $res = mysql_query($sql);

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

        $nav = null;

        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 href=\"admin.php?fct=gallery&amp;op=validnew&amp;type=checknew&amp;offset=$newoffset\">$i</a>]";
            }
        }

        $deb = $offset+1;

        echo "<td width=\"100%\" align=\"center\"><br>
         "._GALNOWDISPLAYFILES." $deb - $end of $numrows<br>
         "._GALJUMP2PAGE." $nav</td></tr>";

        $i=0;
    while (list($pid, $gid, $img, $submitter, $date, $name, $description, $width, $height) = mysql_fetch_array($res))
        {
            echo "<tr><td width=\"100%\">
          <table border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr>
          <td>
          <p align=\"left\">
          <a href=\"$basepath/temp/$img\" target=\"_new\"><img src=\"$basepath/temp/$img\" width=\"75\" border=\"1\"></a><br>
          <font size=\"1\" face=\"Verdana, Arial\">"._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 size=\"1\" face=\"Verdana, Arial\">
          <INPUT TYPE=\"radio\" NAME=\"Task$i\" checked VALUE=\"Validate\" ><small>"._GALVALIDNEW."</small><br>
          <INPUT TYPE=\"radio\" NAME=\"Task$i\" VALUE=\"Delete\"><small>"._GALDELETE."</small>
          </td>
          <td align=\"left\" valign=\"top\">
          <font size=\"1\" face=\"Verdana, Arial\">"._GALSELECTCATEGORY."</font><br>
          <select size=\"1\" name=\"Category$i\">";

            $categories = listcategories("$gallerypath");
        $categories = explode(" ", trim($categories));
        while(list($key, $val) = each($categories))
            {
            $result = mysql_query("select gallid, gallname, parent from ".$mpnTables['gallery_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 size=\"1\" face=\"Verdana, Arial\">"._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 size=\"1\" face=\"Verdana, Arial\">"._GALMEDIANAME."<br></font>
          <input type=\"text\" name=\"MediaName$i\" size=\"14\" value=\"$name\"><br>
          <font size=\"1\" face=\"Verdana, Arial\">"._GALDATEADDED."<br></font>
          <input type=\"text\" name=\"Date$i\" size=\"14\" value=\"$date\"><br>
          <font size=\"1\" face=\"Verdana, Arial\">"._GALSUBMITTER."</font><br>
          <input type=\"text\" name=\"Submitter$i\" size=\"14\" value=\"$submitter\"></td>
          <td align=\"left\" valign=\"top\" width=\"609\"><font size=\"1\" face=\"Verdana, Arial\">"._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 class=\"button\" type=\"submit\" value=\""._SAVECHANGES."\" name=\"add\"></form>";
    }
    else
    {
        echo "<tr><td align=\"center\" colspan=\"2\"></form><br>"._GALNOMEDIAFOUND."<br>";
    }

    echo "</td></tr></table>";
    CloseTable();
    print '<br>';
    // Start Of Footer
    OpenTable();
    print '<table><tr><td>'
         ."<font face=\"Verdana,Arial\" color=\"$textcolor1\">mpn eGallery Version - $version<br>"._GALVISITUPDATE.'</font>
       </td>
       </tr></table>';
    CloseTable();
}

?>
