Location: PHPKode > projects > @1 File Store > moved.php
<?
if(isset($_GET["id"]) && $_GET["id"]!="") {
	$folder_id=$_GET['id'];
} else {
	exit("Bad request");
}

$MustLogin=1|2|4;
require_once("libs/header.php");
require_once(LIBPATH."multipage.php");
require_once("libs/databasetree.php");

$userlevel=$CurUser->getlevel();
/*
if ($userlevel > 0) {
	$sql3 = "SELECT folder_id FROM `".DB_PREFIX."access_list` WHERE group_id='".$userlevel."'";
} else if ($userlevel < 1) {
	$sql3 = "SELECT folder_id FROM `".DB_PREFIX."access_list` WHERE `group_id` > 0";
}

if(!$mysql->query($sql3)) {
	exit($mysql->error);
}
$folid=array();
while(!$mysql->EOF) {
	$folid[]=$mysql->arr;
	$mysql->movenext();
}
$folname=array();
foreach ($folid as $fid) {
	$sql4 = "SELECT folder_name FROM `".DB_PREFIX."folders` WHERE id='".$fid['folder_id']."'";
	if(!$mysql->query($sql4)) {
		exit($mysql->error);
	}
	while(!$mysql->EOF) {
		$folname[]=$mysql->arr;
		$mysql->movenext();
	}
}
$folparent=array();
foreach ($folid as $fp) {
	$sql4 = "SELECT parent FROM `".DB_PREFIX."folders` WHERE id='".$fp['folder_id']."'";
	if(!$mysql->query($sql4)) {
		exit($mysql->error);
	}
	while(!$mysql->EOF) {
		$folparent[]=$mysql->arr;
		$mysql->movenext();
	}
}
$fid = array();
foreach ($folid as $fd) {
	$fid[] = $fd['folder_id'];
}
$fname = array();
foreach ($folname as $fn) {
	$fname[] = $fn['folder_name'];
}
$fparent = array();
foreach ($folparent as $fp) {
	$fparent[] = $fp['parent'];
}
*/


$folisttree=new databasetree($mysql, DB_PREFIX."folders");
$folisttreeresult=$folisttree->get_array("Root Folder", "...&nbsp;&nbsp;");
$test1 = $folisttreeresult;
$flist = $folisttreeresult;
/*
$group=array();
foreach ($folisttreeresult as $key => $value) {
	$sql3 = "SELECT group_id, folder_id FROM `".DB_PREFIX."access_list` WHERE folder_id='".$key."'";
	if(!$mysql->query($sql3)) { exit($mysql->error); }

	while(!$mysql->EOF) {
		$group[$mysql->field("folder_id")]=$mysql->field("group_id");
		$mysql->movenext();
	}
}


foreach ($test1 as $test1key => $test1value) {
	if(!array_key_exists($test1key, $group) and $test1key!=0) {
		unset($flist[$test1key]);
	}
}
*/

/*
$fnameform=$fname;
natsort($fnameform);
*/
$form=array(
	"method"=>"POST",
	"action"=>"",
	"message"=>"",
	"errorcount"=>0,
	"fields"=>array(
		       "choose"=>array("type"=>"select",
		       		"description"=>$lang['move_to'],
		       		"error"=>$lang['select_destination_folder'],
		       		"extra"=>$flist
		       	     )
		      ),
	"submit"=>"Move"
);
$userform=new UserForms($form["fields"]);

$smarty->assign("action", $lang['move_file']);
$form["submit"]=$lang['move'];
if($_SERVER["REQUEST_METHOD"]==$form["method"]) {
	$userform->load($form["fields"], $_POST);
	$form["errorcount"]=$userform->check($form["fields"]);
	$cleanup = $userform->sql($form["fields"]);
	$do = preg_match("/\d+/", $cleanup, $matches);
	if ($do = true) {
		$clean=$matches['0'];
	} else {
		exit("Bad request");
	}
/*	$found = $fname[$clean];
	$foundparent = $fid[$clean];
*/
	$foundparent = $clean;
	if ($foundparent == $folder_id) {
		$form["errorcount"]=1;
		$form["message"]=$lang['not_move_to_own'];
	}

	if($form["errorcount"]==0)

		{
			$SQL="UPDATE `".DB_PREFIX."folders` SET `parent`='".$foundparent."' WHERE id='".$folder_id."'";
			if(!$mysql->query($SQL))
		{
		exit($mysql->error);
		}
	Header("Location:folder.php?id=".$folder_id);
	exit();
	}
}
$smarty->assign("form", $form);
$smarty->display("control/form.tpl");
?>
Return current item: @1 File Store