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

function createmedia($pid="") {
	global $prefix, $galleryvar, $gallerypath, $db, $admin_file;
	include("header.php");
	navigationAdmin("<b><a href=\"".$admin_file.".php?op=album&do=showoptions\">"._GALCONFIG."</a></b> &gt;&gt; <b>"._GALINSERTNMEDIA."</b>");
	OpenTable();
	echo "<center><font class=\"option\"><b>"._GALINSERTNMEDIA."</b></font><br>";
	if ($galleryvar['limitSize']) {
		$album_max = $galleryvar['maxSize'];
		$mb = 1024*1024;
		$kb = 1024;
		if ( $album_max >= $mb ) { 
			$album_mysize = sprintf("%01.2f",$album_max/$mb)." MB"; 
		} elseif ( $album_max >= $kb ) { 
			$album_mysize = sprintf("%01.2f",$album_max/$kb)." KB"; 
		} else { 
			$album_mysize = $album_max." Bytes"; 
		}
		echo ""._GALMAXSIZEPOST." ".$album_mysize."";
	}

	$categories = listcategories("$gallerypath");
	if($categories != "") {
		echo "<form method=\"POST\" action=\"".$admin_file.".php?op=album\" enctype=\"multipart/form-data\">"
		."<input type=\"hidden\" name=\"do\" value=\"editmedia\">"
		."<input type=\"hidden\" name=\"type\" value=\"new\">";
		echo "<table border=\"0\" align=\"center\"><tr><td><tr><td>"._GALSELECTCATEGORY.":</td><td><select name=\"Category\" style=\"width=300px\">";
		$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($k=0; $k<$nbtabs; $k++) $tab .= "&nbsp;&nbsp;";
			echo "<option value=\"$gallid\">$tab$gallname</option>\n";
		}
		echo "</select></td></tr>";
		echo "<tr><td>"._GALMEDIANAME.":</td><td><input type=\"text\" name=\"MediaName\" size=\"25\" value=\"\" style=\"width=300px\"></td></tr>";
		if ($galleryvar['limitSize']) echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$maxSize\">";
		echo "<tr><td>"._GALFILENAME.":</td><td><input type=\"file\" name=\"userfile\" size=\"25\" style=\"width=300px\"></td></tr><tr><td>"._GALSUBMITTER.":</td><td><input type=\"text\" name=\"Submitter\" size=\"25\" value=\"\" style=\"width=300px\"></td></tr><tr><td>"._GALDESCRIPTION.":</td><td><textarea name=\"Description\" rows=\"10\" cols=\"25\" style=\"width=300px\"></textarea></td></tr></table><br><center><input type=\"hidden\" value=\"Insert\" name=\"add\"><input type=\"submit\" value=\""._GALADDNEWMEDIA."\"></center></form>";
	}
	CloseTable();
	include("footer.php");
}
?>