<?php
@ require ('writable/set/set_area.php');
@ require ('readonly/function/confirm_power.php');
define('POWER', confirm_power());

if (POWER != 5) {
  err('该命令必须以基本管理员身份登陆！请重登陆');
}

if ($_GET['act'] == 'del') {

  if (file_exists('index.html')) {
    @unlink('index.html');
    echo '<span class="grayword">首页：<b>静态首页</b> - index.html 删除成功！</span><br />';
    @ob_flush();
    @flush();
  }

  foreach ((array)$web['area'] as $column_id => $column) {
    $column = (array)$column;
    $column_py = $column['name'][1];
    if (file_exists($column_py.'.html')) {
      @unlink($column_py.'.html');
      echo '<span class="grayword">频道：<b>'.$column['name'][0].'</b> - '.$column_py.'.html 删除成功！</span><br />';
      @ob_flush();
      @flush();
    }
    unset($column['name']);
    foreach ($column as $class_id => $class) {
      if (file_exists($column_py.'_'.$class[1].'.html')) {
        @unlink($column_py.'_'.$class[1].'.html');
	    echo '<span class="grayword">&nbsp;&nbsp;&nbsp;&nbsp;栏目：<b>'.$class[0].'</b> - '.$column_py.'_'.$class[1].'.html 删除成功！</span><br />';
        @ob_flush();
        @flush();
      }
    }
  }
/*
  $all_html = @glob('./{column_*,class_*_*,detail_*_*}.html', GLOB_BRACE);

  if (count($all_html) > 0) {
    foreach ($all_html as $v) {
      @unlink($v);
    }
  }
*/


  //专题
  $priority_arr = array();
  if (!isset($sql['db_err'])) {
    db_conn();
  }
  if ($sql['db_err'] == '') {

    $result = @mysql_query('SELECT * FROM `'.$sql['pref'].''.$sql['data']['承载网址数据的表名'].'` WHERE detail_title<>"" GROUP BY detail_title', $db);
    if (@mysql_num_rows($result) > 0) {
      while ($row = @mysql_fetch_assoc($result)) {
        $priority_arr[$row['column_id'].'_'.$row['class_id'].'_'.$row['detail_title']] = 1;
        unset($row);
      }
    }
    @mysql_free_result($result);

  }/* else {
    $err .= $sql['db_err'];
  }*/
  @mysql_close();

  unset($_GET);
  if (count($priority_arr) > 0) {
    foreach ($priority_arr as $priority_key => $priority_val) {
      list($_GET['column_id'], $_GET['class_id'], $detail_title) = @explode('_', $priority_key);
      list($_GET['detail_title'], $detail_py, ) = @explode('|', $detail_title);
      @unlink($detail_py.'.html');
	  echo '<span class="grayword">专题：<b>'.$_GET['detail_title'].'</b> - '.$detail_py.'.html 删除成功！</span><br />';
      @ob_flush();
      @flush();
    }
  }

  echo '<script>
function scrollToBottom() {
  //window.scrollTo(0, document.body.offsetHeight);
  location.href="#htmlend";
}
if(document.all){
  window.attachEvent("onload",scrollToBottom);
}else{
  window.addEventListener("load",scrollToBottom,false);
}
</script>';
  alert('<a name="htmlend" id="htmlend"></a>各分类静态页面也删除成功', 'webmaster_central.php');
} else {
  @ require ('readonly/function/write_file.php');
  write_file('writable/set/set_html.php', '<?php $web[\'html\'] = false; ?>');
  $web['html'] = false;
  reset_indexhtml('index.php', 'index.html');

  err('已关闭静态（请刷新一下首页）。以首页为起始，再次进入各分类页面时为动态分类页面<br /><br /><ul style="width:50%;text-align:left;">对于各分类静态页面的处理：<li>仍然保留</li><li><a href="?post=manager_html_close&act=del">我想全部删除它们</a></li></ul><br /><br />', 'ok');

}



?>