<?php
include("CheckSession.php");
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="馬戲團" />
<title>馬戲團</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>

<script language="JavaScript" type="text/JavaScript"> 
<!-- 
function MM_openBrWindow(theURL,winName,win_width,win_height) { 
  var PosX = ((screen.width-win_width)/2); 
  var PosY = ((screen.height-win_height)/2);
  features = "status=no,toolbar=no,scrollbars=yes,resizable=yes,width="+win_width+",Height="+win_height+",top="+PosY+",left="+PosX;; 
  var urlStr = theURL;
  var newwin = window.open(urlStr,winName,features); 
}
//--> 
</script>
<?php
require_once("class/FileConfig.php");
$dirs = "";
$nextdir = $_GET['nextdir'];
if($nextdir != null && $nextdir != "")
{
$nextdir = str_replace(';','/',$nextdir);
$dirs = glob($nextdir."/"."*");
}
else
{
$dirs = glob($_FILECONFIG['DownDir']."*");
}
?>
<SCRIPT language="JavaScript">
function checkDelete(id)
{
	if(confirm("確定要刪除嗎????"))
	{
     location.href = "FileOpDeleteDeal.php?fileName=" + id;
	}
}
</SCRIPT>
<body>
<form name="form1" method="post" action="FileDataInput.php?actionOp=Insert">
<table border="0" cellspacing="1" cellspadding="1" width="95%">
<!--
<tr>
<td align="center" colspan="2">
<span class="title"><b>開寶箱</b></span>
</td>
</tr>
-->
<tr>
<td align="center" colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td align="left" colspan="2" width="100%">
  <table width="100%" border="1" cellspacing="2" cellpadding="2">     
  <tr>   
  <td width="10%" bgcolor="#E1E9FB" align="center"><span class="t12r">序號</span></td>     
  <td width="30%" bgcolor="#E1E9FB" align="center"><span class="t12r">目錄/檔名</span></td> 
  <td width="10%" bgcolor="#E1E9FB" align="center"><span class="t12r">開啟/下載</span></td>  
  <td width="10%" bgcolor="#E1E9FB" align="center"><span class="t12r">刪除</span></td>
  </tr>     
  <?php
  $index = 0;
  for ( $i=0 ; $i<count($dirs) ; $i++ ) {
  ?>     
	  <tr>	  
	  <td bgcolor="#E6F2FF"><?php echo $i+1;?></td>     
	  <td bgcolor="#E6F2FF">
	  <span class="t12">
	  <?php echo mb_convert_encoding(str_replace($_FILECONFIG['DownDir'],'',$dirs[$i]),"utf-8","big5,utf-8"); ?></span></td>	  
	  <td bgcolor="#E6F2FF" align="center">	   
	  <span class="t12">
	  <?php
	  if(is_dir(mb_convert_encoding($dirs[$i],"utf-8","big5,utf-8"))) 
	  {
	  ?>
	  <a href="FileOpIndex.php?nextdir=<?php echo mb_convert_encoding(str_replace('/',';',$dirs[$i]),"utf-8","big5,utf-8");?>">
	  <b>開啟</b></a></span>	
	  <?php	  	
	  }
	  else
	  {
	  ?>
	  <a href="javascript:void(0);" onclick="MM_openBrWindow('FileOpDownload.php?fileName=<?php echo mb_convert_encoding(str_replace('/',';',$dirs[$i]),"utf-8","big5,utf-8");?>','DownloadOpWin',100,100)")">
	  <b>下載</b></a></span>
	  <?php	  	
	  }
	  ?>	 
	  </td>
	  <?php
	  if(is_dir(mb_convert_encoding($dirs[$i],"utf-8","big5,utf-8"))) 
	  {
	  ?>
	  <td bgcolor="#E6F2FF" align="center">	 
	  <span class="t12">	  
	  &nbsp;</span>	   
	  </td>
	  <?php	  	
	  }
	  else
	  {
	  ?>
	  <td bgcolor="#E6F2FF" align="center">	 
	  <span class="t12">	  
	  <a href="javascript:void(0);" onclick="checkDelete('<?php echo mb_convert_encoding(str_replace($_FILECONFIG['DownDir'],'',$dirs[$i]),"utf-8","big5,utf-8");?>');">
	  <b>刪除</b></a></span>	   
	  </td>
	  <?php	  	
	  }
	  ?>
	  </tr>     
  <?php     
  }
  echo "</table>"   ;
?>
</td>
</tr>
</table>
</form>
</body>
</html>
