<?php
include("../../config.inc.php");
include($CommonPath."/admin/func/adm.inc.php");
include($CommonPath."/admin/func/db.inc.php");
$msql=new SHARP_SQL;
NeedAuth(0);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<SCRIPT>
function cm(nn){
	if (confirm("确实要删除文件吗？")){
		window.location='<?php echo $PHP_SELF;?>?step=del&ifile='+nn;
	}
}

function ImgFile (file) {
	window.returnValue = file;
	window.close();
}
</SCRIPT>
<title>无标题文档</title>
</head>

<body leftmargin="0" topmargin="0">
<center>
  <table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
<?php
$imagefold = "../../pic/gif/";

if ($step == "del"){
  if($ifile != "." && $ifile != ".." && $ifile != "_notes" && !is_dir ($ifile)){
	  if(file_exists($imagefold.$ifile)){
	    unlink($imagefold.$ifile);
		echo "<script>parent.location.reload()</script>";
	  }
  }else{
	echo "<script>alert('删除失败！文件路径错误或文件不存在！')</script>";
  }
}

$handle = opendir ($imagefold);
$kk = 1;
$tt = 0;
while ($ImgFile = readdir($handle)) {
	$nowfile = $imagefold . $ImgFile;

	$img_size = @GetImageSize ( $nowfile );
	($img_size[0] > 75) ? $width = 75 : $width = $img_size[0];
	($img_size[1] > 75) ? $height = 75 : $height = $img_size[1];
    if($ImgFile != "." && $ImgFile != ".." && $ImgFile != "_notes" && !strstr ($ImgFile,"/") && !is_dir ($nowfile)){
?>
      <td align="center" bgcolor="#F0f0f0" style="border-top: 1 solid #ffffff;border-right:1 solid #ffffff;" onDblclick="ImgFile ('<?php echo str_replace ("../../", $SiteUrl, $nowfile);?>')"> 
        <table border="0" cellspacing="0" cellpadding="2">
          <tr align="center"> 
            <td height="75"><img src="<?php echo $nowfile;?>" width="<?php echo $width;?>" height="<?php echo $height;?>" onDblclick="ImgFile ('<?php echo str_replace ("../../", $SiteUrl, $nowfile);?>')"></td>
        </tr>
        <tr> 
          <td height="22" align="center" valign="bottom"> 
            <input type="button" name="Submit" value="选中" style="background:#f0f0f0;border:1 solid #dddddd;font-size:12px" onClick="ImgFile ('<?php echo str_replace ("../../", $SiteUrl, $nowfile);?>')">&nbsp;<input type="button" name="Submit2" value="删除" style="background:#f0f0f0;border:1 solid #dddddd;font-size:12px;text-align:center" onClick="cm('<?php echo $ImgFile;?>')"> </td>
        </tr>
      </table> 
      </td>
		<?
		if($kk >= 5){
			echo "</tr>";
			$kk = 0;
		}
		$kk++;
		$tt++;
	}
}
		?>
  </tr>
</table>
</center>
</body>
</html>
