<?php
if (!defined('ADMIN_FILE')) die("Illegal File Access");

function validnew() {
	global $prefix, $gallerypath, $temppath, $db, $admin_file;
	$storynum = 5;
	$num = isset($_GET['num']) ? intval($_GET['num']) : "1";
	$offset = ($num-1) * $storynum;
	$offset = intval($offset);
	$storynum = intval($storynum);
	$nresult = $db->sql_query("SELECT pid, gid, img, submitter, date, name, description, width, height FROM ".$prefix."_album_pictures_newpicture LIMIT $offset, $storynum");
	head();
	navigationAdmin("<b><a href=\"".$admin_file.".php?op=album\">"._GALCONFIG."</a></b> &gt;&gt; <b>"._GALVALIDNEWMEDIA."</b>");
	OpenTable();
	echo "<form method=\"post\" action=\"".$admin_file.".php?op=album\"><input type=\"hidden\" name=\"op\" value=\"album\"><input type=\"hidden\" name=\"do\" value=\"validnew\"><input type=\"hidden\" name=\"type\" value=\"validate\">"
	."<center><font class=\"option\"><b>"._GALPOSTEDMEDIA."</b></font></center><br />"
	."<table border=\"0\" align=\"center\">";
	$i = 0;
	while (list($pid, $gid, $img, $submitter, $date, $name, $description, $width, $height) = $db->sql_fetchrow($nresult)) {
		echo "<tr><td><table border=\"0\" class=\"bodyline\"><tr><td><a href=\"$temppath/$img\" target=\"_blank\"><img src=\"$temppath/$img\" border=\"0\" height=\"250\" width=\"250\"></a></td></tr></table>"
		."</td><td><table border=\"0\"><tr><td>"._GALFILENAME.":</td><td><input type=\"hidden\" name=\"OldFileName$i\" value=\"$img\"><input type=\"hidden\" name=\"FileId$i\" value=\"$pid\"><input type=\"text\" name=\"FileName$i\" size=\"50\" value=\"$img\" style=\"width:300px\"></td></tr><tr><td>"._GALVALIDNEW.":</td><td><input type=\"radio\" name=\"Task$i\" value=\"Validate\" checked></td></tr><tr><td>"._GALDELETE.":</td><td><input type=\"radio\" name=\"Task$i\" value=\"Delete\"></td></tr><tr><td>"._GALSELECTCATEGORY.":</td><td><select name=\"Category$i\" style=\"width:300px\">";
		$categories = listcategories("$gallerypath");
		$categories = explode(" ", trim($categories));
		while(list($key, $val) = each($categories)) {
			$result = $db->sql_query("SELECT gallid, gallname, parent FROM ".$prefix."_album_categories WHERE gallid=".$val);
			list($gallid, $gallname, $parent) = $db->sql_fetchrow($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></td></tr><tr><td>"._GALWIDTHXHEIGHT.":</td><td><input type=\"text\" name=\"Width$i\" size=\"4\" value=\"$width\"> x <input type=\"text\" name=\"Height$i\" size=\"4\" value=\"$height\"></td></tr><tr><td>"._GALMEDIANAME.":</td><td><input type=\"text\" name=\"MediaName$i\" size=\"50\" value=\"$name\" style=\"width:300px\"></td></tr><tr><td>"._GALDATEADDED.":</td><td><input type=\"text\" name=\"Date$i\" size=\"50\" value=\"$date\" style=\"width:300px\"></td></tr><tr><td>"._GALSUBMITTER.":</td><td><input type=\"text\" name=\"Submitter$i\" size=\"50\" value=\"$submitter\" style=\"width:300px\"></td></tr><tr><td>"._GALDESCRIPTION.":</td><td><textarea  name=\"Description$i\" rows=\"5\" cols=\"50\" style=\"width:300px\">$description</textarea></td></tr></table></td></tr>";
		$i++;
	}
	echo "<tr><td colspan=\"2\" align=\"center\"><br><input type=\"submit\" value=\""._SAVECHANGES."\" name=\"add\"></td></tr></form></table>";
	CloseTable();
	list($numstories) = $db->sql_fetchrow($db->sql_query("SELECT Count(pid) FROM ".$prefix."_album_pictures_newpicture"));
	$numpages = ceil($numstories / $storynum);
	num_page($module_name, $numstories, $numpages, $storynum, "op=album&do=validnew&type=checknew&");
	foot();
}
?>