<?

error_reporting(0);
require_once('data.php');
include('../inc/config.php');
if($_COOKIE['x_Cookie']!=$adminname or $_COOKIE['y_Cookie']!=md5($password)){
	echo"<script>location.href='index.php';</script>";
	exit;
}
 
?>
<!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=gb2312">
<link rel="stylesheet" type="text/css" href="css/admin.css">
<link href="css/jquery.css" rel="stylesheet" type="text/css">
<link href="css/base.css" rel="stylesheet" type="text/css">

</head>
<body>
<? 
// 说明： PHP删除非空目录的自定义函数
// 来源：网络
function removedir($dirName) 
{ 
    if(!is_dir($dirName)) 
    { 
        return false; 
    } 
    $handle = @opendir($dirName); 
    while(($file = @readdir($handle)) !== false) 
    { 
        if($file != '.' && $file != '..') 
        { 
            $dir = $dirName . '/' . $file; 
            is_dir($dir) ? removeDir($dir) : @unlink($dir); 
        } 
    } 
    closedir($handle); 
     
    return rmdir($dirName) ; 
} 
?> 
<?
if($_GET['id']=='del'){
	?>
<div class="right">
   <? include "welcome.php";?>
  <div class="right_main">

      <table width="98%" border="0" cellpadding="4" cellspacing="1" class="tableoutline">
        <tr class="tb_head">
          <td colspan="5"><h2>清除缓存：</h2></td>
        </tr>
        <tr align=center class="firstalt">
          <td width="30%" >缓存说明</td>
          <td width="30%" >缓存目录</td>
          <td width="20%" nowrap>缓存文件个数</td>
          <td width="20%" nowrap>操作</td>
        </tr>
        <tr align=center class="firstalt">
          <td > 首页缓存</td>
          <td >index<?php echo $houzhui;?></td>
          <td style="color: #FF0000;"><? if(file_exists("../index'.$houzhui.'")){echo "1";}else{echo "空";}?></td>
          <td style="text-align:center"><input type="button" class="bginput" style="height:19px; font-size:12px" value="清除" onClick="javascript:location.href='?action=delfile&del=index';" name="Input"></td>
        </tr>
        <tr align=center class="firstalt">
          <td > 列表页缓存</td>
          <td >/<?php echo $mulu?></td>
          <td style="color: #FF0000;"><? $l=count(scandir("../".$mulu))-2; if ($l < 0){echo "空";}else{echo $l;}?></td>
          <td style="text-align:center"><input type="button" class="bginput" style="height:19px; font-size:12px" value="清除" onClick="javascript:location.href='?action=delfile&del=list';" name="Input"></td>
        </tr>
        <tr align=center class="firstalt">
          <td > 内容页缓存</td>
          <td >/<?php echo $news?></td>
          <td style="color: #FF0000;"><? $nr=count(scandir("../".$news))-2; if ($nr < 0){echo "空";}else{echo $nr;}?></td>
          <td style="text-align:center"><input type="button" class="bginput" style="height:19px; font-size:12px" value="清除" onClick="javascript:location.href='?action=delfile&del=html';" name="Input"></td>
        </tr>
		<tr align=center class="firstalt">
          <td >一键清除全部缓存</td>
          <td ></td>
          <td style="color: #FF0000;"><? $n=($l+$nr); if ($n < 0){echo "空";}else{echo $n;}?></td>
          <td style="text-align:center"><input type="button" class="bginput" style="height:19px; font-size:12px" value="清除" onClick="javascript:location.href='?action=delfile&del=all';" name="Input"></td>
        </tr>
      </table>
<?
}elseif ($_GET['action']=='delfile'){
	echo "请稍候，正在更新缓存……<br />";

 if($_GET['del']=='index')
 {
@unlink("../index$houzhui");
}
 elseif($_GET['del']=='list')
 {
@removedir("../$mulu");
}
 elseif($_GET['del']=='html')
 {
@removedir("../$news");
}

 elseif($_GET['del']=='all')
 {
@unlink("../index$houzhui");
@removedir("../$mulu");
@removedir("../$news");
}
echo"<script>alert('更新缓存成功！');location.href='?id=del';</script>";
}
?>
  </div>
</div>
<? include "footer.php"; ?>
</body>
</html>
