<?php
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
if (!defined('MOD')) die("access die");
$dirs = array();
getRecursiveDir($rootdir ,0,$dirs);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base target="_self">
<meta http-equiv='Content-Type' content='text/html; charset=<?php echo $_SET['def_charset']; ?>'>
<style>
*{padding:0;margin:0;}
body{FONT-SIZE: 12px; LINE-HEIGHT: 120%;}
input.file{FONT-SIZE: 12px;BORDER: 1 solid #666666;PADDING-TOP: 1;WIDTH: 100%;}
input.button{FONT-SIZE: 12px;PADDING-TOP: 2px;}
Div, TD{LINE-HEIGHT: 120%;FONT-SIZE: 12px;}
</style>
<link rel="StyleSheet" href="<?php echo AW_P; ?>images/dtree.css" type="text/css">
<script  type='text/javascript'>
var config = {charset:'<?php echo $_SET['def_charset'];?>',channelid : '<?php echo $channelid;?>',channeldir : '<?php echo $channeldir;?>',url : "<?php echo W_P;?>",web_path : "<?php echo $_SET[webpath];?>", awp:'<?php echo AW_P;?>', wwp:'<?php echo WW_P;?>'};
</script>
<script type="text/javascript" src="<?php echo WW_P; ?>images/js/qmecms.js"></script>
<script type="text/javascript" src="<?php echo AW_P; ?>images/js/admin.js"></script>
<script type="text/javascript" src="<?php echo AW_P; ?>images/js/explorer.js"></script>
<script type="text/javascript" src="<?php echo AW_P; ?>images/js/dtree.js"></Script>
</head>
<body bgcolor="#F5F5F5">

<div id="beforelistdiv" style="padding: 3px; width:300px; height: 210px; overflow: auto; border-style: inset; border-width:1px; background-color: window">正在载入...</div>
<br>要查看任何子文件夹，请单击上面的 + 号。
<p align=right>
	<input id=aimdir type=hidden value="">
</p>

<div id="divaa" style="text-align: center; position: absolute; top: 122px; width:300px; z-index: 100" align=center>
	<img id="aa" border="0" src="<?php echo AW_P; ?>images/find.gif">
</div>

<script language="javaScript">
var icon = "<?php echo AW_P; ?>images/folder/folder.gif" ;
d = new dTree("d", "../images/");

<?php
echo "d.add(0,-1, '根目录', 'javascript:u(\\'.\\')','".$stype."');\n";

foreach($dirs as $od){
//id, pid, name, url, title, target, icon, iconOpen, open
$od->urlpath = str_replace("\\","|", $od->urlpath); // Javascript 无法识别 "\";
echo "d.add($od->id , {$od->pid}, '$od->dirname', 'javascript:u(\\'$od->urlpath\\')', '','', icon);\n";
}
?>
</Script>
<Script langauge=javascript>
var sDtree = d;
(function(){
	findObj('beforelistdiv').innerHTML=sDtree;
	findObj('divaa').innerHTML='';
})();
function u(url){
	url = url.replace(/\|/g, '/');
	findObj('aimdir').value = url;
	parent.qmeCms.dialogView.setSubmit(true, "移动", function(){
		ok();
	});
}

function ok(){
	var s = findObj('aimdir').value;
	if(s){
		parent.location.replace("system.php?sys=explorer&action=remove&path=<?=$_GET[path]?>&channelid=<?=$channelid?>&ext=<?=$_GET[ext]?>&file=<?=$_GET[file]?>&aimdir="+s);
	}
}

(function(){
	setInterval(function(){
		parent.qmeCms.dialogView.iframeOnload();
	},500);
})();
-->
</Script>
</body>
</html>
<?php
//////////////////////////////////////////
class oDTree{
var $id;
var $pid;
var $dirname;
var $urlpath;
function oDTree($id, $pid, $dirname,$urlpath){
$this->id = $id;
$this->pid = $pid;
$this->dirname = $dirname;
$this->urlpath = $urlpath;
}
}


function getRecursiveDir($path, $parentid){
global $dirs;
static $numid = 0;
$data = glob( $path.'/*' , GLOB_ONLYDIR );
if(!is_array($data)) $data = array();
foreach($data as $dir_name){
$numid++;
$basename = basename($dir_name);
$realpath = getPath( realpath($dir_name) );
$urlpath  = getRelativePath($dir_name);
$dirs[$numid] = new oDTree($numid, $parentid, $basename, $urlpath) ;

getRecursiveDir( $realpath, $numid);

}
}
exit();
?>
