Location: PHPKode > projects > @1 File Store > control/files/edit.php
<?
if(!isset($_GET["id"]) || $_GET["id"]=="")
{
 exit("Bad request");
}
require_once("const.php");

$smarty->assign("action", $lang['edit_file_2']);
$form["submit"]=$lang['edit'];
$form["hidden_fields"]=array("id"=>$_GET["id"], "folder"=>$_GET["folder"]);

if($_SERVER["REQUEST_METHOD"]==$form["method"])
{	
 $userform->load($form["fields"], $_POST);
 $form["errorcount"]=$userform->check($form["fields"]);
 if($form["errorcount"]==0)
 {
  $SQL="UPDATE `".DB_PREFIX."file_list` SET ".$userform->sql($form["fields"])." WHERE `id`='".$_POST["id"]."'";
  if(!$mysql->query($SQL))
  {
   exit($mysql->error);
  }
  if($_POST["old_confirm"]=="N" && $form["fields"]["confirm"]["value"]=="Y")
  {
   $SQL="SELECT * FROM `".DB_PREFIX."users` WHERE `id`='".$_POST["id"]."'";
   if(!$mysql->query($SQL))
   {
    exit($mysql->error);
   }
   if($mysql->num>0)
   {
    $MAIL=sprintf($APP_FILE, $form["fields"]["filename"]["value"], $form["fields"]["descript"]["value"]);
    mail($mysql->field("email"), "File accept", $MAIL, "From:".ADMIN_EMAIL);
    }
  }
	if (isset($_GET['frm']) and $_GET['frm']=='pending') {
		Header("Location:../../pf.php");
		exit();
	} else {
		Header("Location:../../folder.php?id=".$_POST["folder"]);
		exit();
	}
 }
 $form["hidden_fields"]["old_confirm"]=$_POST["old_confirm"];
}else
 {
  $SQL="SELECT * FROM `".DB_PREFIX."file_list` WHERE `id`='".$_GET["id"]."'";
  if(!$mysql->query($SQL))
  {
   exit($mysql->error);
  }else
   {
    $userform->load($form["fields"], $mysql->arr);
    $form["hidden_fields"]["old_confirm"]=$mysql->field("confirm");
   }
 }

$smarty->assign("form", $form);
$smarty->display("control/form.tpl");
?>
Return current item: @1 File Store