<?php
require ('authentication_manager.php');
?>
<style type="text/css">
<!--
.column__ { margin-bottom:10px; line-height:39px; text-align:left; clear:both; background-color:#ECECEC; }
-->
</style>
<form method="post" id="manageform" action="?post=unity_run&dataname=reset_area_statistics">
<?php

/* 重置版区数据 */
/* 162100源码 - 162100.com */


$text = $text__ = $err = '';
if (isset($_GET['mode']) && $_GET['mode'] && file_exists('inc/css/'.$_GET['mode'])) { 
?>
<div class="list_title"><a href="?get=reset_area_statistics">&lt;&lt;返回</a><a class="list_title_in">栏目分类<span>（<?php echo $n; ?>）</span></a></div>
  <div class="manager_menu">所属模板：<?php echo substr($_GET['mode'], 0, 1).''.str_pad('', strlen($_GET['mode'])-1, '*').' ['.file_get_contents('inc/css/'.$_GET['mode'].'/title.txt').'] '.($web['sitemode']==$_GET['mode']?'<span class="redword">√系统当前选择</span>':''); ?><br />
<a href="javascript:void(0)" onclick="allChoose(true,true);return false;">全选</a> - <a href="javascript:void(0)" onclick="allChoose(true,false);return false;">反选</a> - <a href="javascript:void(0)" onclick="allChoose(false,false);return false;">不选</a> &nbsp;&nbsp;
      <button type="button" name="act2" onclick="if(confirm('确定执行么？该命令可能需要较长时间')){chk(this.form,this,'reset')}"><b>一键重置</b></button> | 
      <input type="checkbox" class="checkbox" name="area_mark_reset" value="1" /> 同时重置各栏目权限参数
  </div>
  <input type="hidden" name="limit" />
<?php
if (!isset($sql['db_err'])) {
  db_conn();
}

if ($sql['db_err'] == '') {

  $result = @mysql_query('SELECT * FROM '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' WHERE area_id REGEXP "^[0-9]+\-[0-9]+$" AND area_index LIKE "%'.$_GET['mode'].'%" ORDER BY area_id ASC', $db);
  $n = @mysql_num_rows($result);
  if ($n > 0) {
    $date = gmdate('md', time() + (floatval($web['time_pos']) * 3600));
    $text .= '
<div class="list_title_">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th>栏目名</th>
    <th width="100">总文章数</th>
    <th width="100">今日数</th>
  </tr>
</table>
</div>
';
    while ($row = @mysql_fetch_assoc($result)) {
      $text .= '
<div class="li">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr valign="top">
    <td style="text-align:left;"><input name="id[]" id="id[]" type="checkbox" class="checkbox" value="'.$row['area_id'].'" /> '.$row['area_name'].'</td>
    <td width="100" style="text-align:center;">'.$row['area_total'].'&nbsp;</td>
    <td width="100" style="text-align:center;">'.(substr($row['area_today'], 0, 4) == $date ? substr($row['area_today'], 4) : 0).'&nbsp;</td>
  </tr>
</table>
</div>';

      unset($row);
    }
  } else {
    $err .= '没有栏目分类记录！请先进行栏目分类';
  }
  @mysql_free_result($result);


} else {
  $err .= $sql['db_err'];
}

@mysql_close();

} else {
  $_GET['mode'] = $web['sitemode'];
  if ($m_arr = @glob('./inc/css/*', GLOB_ONLYDIR)) {
    foreach ($m_arr as $m_f) {
      $base_index_mode = basename($m_f);
	  $title = @file_get_contents($m_f.'/title.txt');
      if (file_exists('./inc/css/'.$base_index_mode.'/index.php') && file_exists('./inc/css/'.$base_index_mode.'/list.php') && file_exists('./inc/css/'.$base_index_mode.'/article.php')) {
       $text .= '<div class="column__"><a href="?mode='.$base_index_mode.'&get=reset_area_statistics">'.substr($base_index_mode, 0, 1).'*** ['.$title.'] 下的栏目一键重置各栏目记录数</a></div>';
      } else {
        $text__ .= '<div class="column__">'.substr($base_index_mode, 0, 1).'*** ['.$title.'] 该风格尚未安装，请<a href="http://wpa.qq.com/msgrd?v=3&uin=184830962&site=qq&menu=yes" target="_blank">QQ联系程序作者</a>定制</div>';
      }
      unset($base_index_mode, $title);
    }
  } else {
    $err .= '没有任何模板，也无法进行栏目分类管理！';
  }
  $mode_text = '';
}


?>
  <?php echo $text, $text__, $err; ?>
</form>
