<?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>
</head>
<?php

require_once("class/DBConfig.php");
require_once("class/DBOperation.php");

require_once("class/FileConfig.php");
require_once("class/FileOperation.php");

$chkId = $_POST ["chkId"];

$myallId = implode (",",$chkId);

$db = new DBOperation();
$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);

$querySql = "select * From FileData Where CId in (".$myallId.")";
$db->query($querySql);
while($myrow = $db->fetch_array())
{
	//刪除檔案
	$fileName = $_FILECONFIG['UsedDir'].$myrow['CNewFileName'];	
	$fileOp = new FileOperation();
	$fileOp->deleteFile(iconv("utf-8", "big5", $fileName));
}
$db->close_db();

$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);
$deleteSql = "Delete from FileData where CId in (".$myallId.")";
$db->query($deleteSql);
$db->close_db();

echo '<script type="text/javascript">';
echo 'alert("刪除成功!!!!");';
echo 'location.href="FileDataIndex.php?page=1"';
echo '</script>';
?>
</html>
