<?php
require("../../class/connect.php");
include("../../class/config.php");
include("../../class/db_sql.php");
include("../../class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
//验证用户
$logininid=getcvar('loginuserid');
$loginin=getcvar('loginusername');
$loginrnd=getcvar('loginrnd');
$loginlevel=getcvar('loginlevel');
$editor=1;
is_login($logininid,$loginin,$loginrnd);
//基目录
$basepath="../../../d/file";
$filepath=$_GET['filepath'];
if(strstr($filepath,".."))
{
	$filepath="";
}
$openpath=$basepath."/".$filepath;
$hand=@opendir($openpath);
db_close();
$empire=null;
//风格
$loginadminstyleid=(int)getcvar('loginadminstyleid');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>插入文件</title>
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
<script>
function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
    }
  }
</script>
</head>

<body>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr> 
    <td>位置：<a href="FilePath.php">管理附件(目录式)</a>&nbsp;&nbsp;(<a href="ListFile.php?type=9">管理附件(数据式)</a>)</td>
  </tr>
</table>
<form name="form1" method="post" action="../enews.php">
  <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1">
    <tr class="header"> 
      <td height="25"> 
        <div align="center">选择</div></td>
      <td height="25">文件名 
        <input name="enews" type="hidden" id="enews" value="DelPathFile">
        (当前目录：<strong>/ 
        <?=$filepath?>
        </strong>) [<a href="#ecms" onclick="javascript:history.go(-1);">返回</a>]</td>
    </tr>
	<?php
	while($file=@readdir($hand))
	{
		if(empty($filepath))
		{
			$truefile=$file;
		}
		else
		{
			$truefile=$filepath."/".$file;
		}
		if($file=="."||$file=="..")
		{
			continue;
		}
		//目录
		if(is_dir($openpath."/".$file))
		{
			$filelink="'FilePath.php?filepath=".$truefile."'";
			$filename=$file;
			$img="folder.gif";
			$checkbox="";
			$target="";
		}
		//文件
		else
		{
			$filelink="'../../../d/file/".$truefile."'";
			$filename=$file;
			$filetype=GetFiletype($file);
			$img=substr($filetype,1,strlen($filetype))."_icon.gif";
			$checkbox="<input name='filename[]' type='checkbox' value='".$truefile."'>";
			$target=" target='_blank'";
		}
	 ?>
	 <tr> 
      <td width="9%" height="25"> <div align="center"> 
          <?=$checkbox?>
        </div></td>
      <td width="91%" height="25"><img src="../../data/images/dir/<?=$img?>" width="23" height="22"><a href=<?=$filelink?><?=$target?>><?=$filename?></a></td>
    </tr>
	<?
	}
	@closedir($hand);
	?>
    <tr> 
      <td height="25"><div align="center"><input type="checkbox" name="chkall" value="on" onclick="CheckAll(this.form)"></div></td>
      <td height="25"><input type="submit" name="Submit" value="删除文件"></td>
    </tr>
  </table>
</form>
</body>
</html>