<?php
/**************************************************************************************************
|
| iDocScript - Document Sharing Script
| http://www.idocscript.com
| webmaster@idocscript.com
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License 
| Agreement available at http://www.idocscript.com/eula.html and to be bound by it.
|
| Copyright (c) 2011 iDocScript.com. All rights reserved.
|**************************************************************************************************/

include("../include/config.php");
include_once("../include/functions/import.php");
include_once("../include/functions/admin.php");
verify_login_admin();

function insert_get_all_members()
{
    global $config,$conn;
	$query = "select USERID,username from members order by username asc"; 
	$results = $conn->execute($query);
	$returnthis = $results->getrows();
	return $returnthis;
}

function insert_get_all_cats()
{
    global $config,$conn;
	$query = "select CATID,name from categories_docs order by name asc"; 
	$results = $conn->execute($query);
	$returnthis = $results->getrows();
	return $returnthis;
}

$DID = intval($_REQUEST['DID']);

if($_POST['submitform'] == "1")
{
	if($DID > 0)
	{
		$arr = array("USERID", "title", "tags", "categories", "public", "viewcount", "downloadcount", "featured", "ratingcount", "rating", "allowcomments", "allowratings", "allowembeds", "allowdownloads", "active");
		foreach ($arr as $value)
		{
			$sql = "update docs set $value='".mysql_real_escape_string($_POST[$value])."' where DID='".mysql_real_escape_string($DID)."'";
			$conn->execute($sql);
		}
		
		$sql = "update docs set description='".mysql_real_escape_string($_POST[vdescription])."' where DID='".mysql_real_escape_string($DID)."'";
		$conn->execute($sql);

		$message = "Document Successfully Edited.";
		Stemplate::assign('message',$message);
	}
}

if($DID > 0)
{
	$query = $conn->execute("select * from docs where DID='".mysql_real_escape_string($DID)."' limit 1");
	$doc = $query->getrows();
	Stemplate::assign('doc', $doc[0]);
}

$mainmenu = "4";
$submenu = "1";
Stemplate::assign('mainmenu',$mainmenu);
Stemplate::assign('submenu',$submenu);
STemplate::display("administrator/global_header.tpl");
STemplate::display("administrator/docs_edit.tpl");
STemplate::display("administrator/global_footer.tpl");
?>