<?php

//统计
function add_total($area_id, $db, $n = 0) {
  global $sql;
  if ($n == 0) {
    $result = @mysql_query('SELECT COUNT(id) AS total FROM `'.$sql['pref'].''.$sql['data']['承载主题文章的表名'].'` WHERE area_id="'.$area_id.'" OR area_id LIKE "'.$area_id.'\_%" AND `area_check`="0"', $db);
    $row = @mysql_fetch_assoc($result);
    $total = abs($row['total']);
    unset($row);
    @mysql_free_result($result);
    @mysql_query('UPDATE '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' SET area_total="'.$total.'" WHERE area_id="'.$area_id.'"', $db);
  } else {
    @mysql_query('UPDATE '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' SET area_total=IF(area_total'.$n.'>0,area_total'.$n.',0) WHERE area_id="'.$area_id.'"', $db);
  }
}


function add_today($area_id, $db, $n = 0) {
  global $web, $sql;
  $year = gmdate('Y', time() + (floatval($web['time_pos']) * 3600));
  $date = gmdate('md', time() + (floatval($web['time_pos']) * 3600));
  if ($n == 0) {
    $result = @mysql_query('SELECT COUNT(id) AS total FROM `'.$sql['pref'].''.$sql['data']['承载主题文章的表名'].'` WHERE `area_id` LIKE "'.$area_id.'\_%" AND `date`="'.$year.$date.'" AND `area_check`="0"', $db);
    $row = @mysql_fetch_assoc($result);
    $total = abs($row['total']);
    unset($row);
    @mysql_free_result($result);
    @mysql_query('UPDATE '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' SET area_today="'.$date.''.$total.'" WHERE area_id="'.$area_id.'"', $db);
  } else {
    @mysql_query('UPDATE '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' SET area_today=IF(SUBSTRING(area_today,1,4)="'.$date.'",CONCAT("'.$date.'",SUBSTRING(area_today,5)'.$n.'),"'.$date.'1") WHERE area_id="'.$area_id.'"', $db);
  }
}


//栏目权限
function get_area_mark() {
  return '
  CONCAT(

  CONCAT("<del class=\"area_mark",
    IF(area_power_write="-1",
      " area_mark_\" title=\"本版发表：限注册用户发表",
      IF(area_power_write>0,CONCAT(" area_mark_\" title=\"本版发表：受限，要求积分达到",area_power_write),"\" title=\"可匿名发表")),
    "\"><span>匿</span></del>"),

  CONCAT("<del class=\"area_mark",
    IF(area_check="1",
      "\" title=\"本版发表审核：开启",
      " area_mark_\" title=\"本版发表审核：关闭"),
    "\"><span>审</span></del>"),

  CONCAT("<del class=\"area_mark",
    IF(area_expires>0,
      CONCAT("\" title=\"本版信息时效：",area_expires,"天"),
      " area_mark_\" title=\"本版未设信息时效期"),
    "\"><span>效</span></del>"),

  CONCAT("<del id=\"read_mark\" class=\"area_mark",
    IF(area_power_read="-1",
      " area_mark_\" title=\"本版阅览：限注册用户",
      IF(area_power_read>0,CONCAT(" area_mark_\" title=\"本版阅览：受限，要求积分达到",area_power_write),"\" title=\"阅览公开")),
    "\"><span>阅</span></del>"),

  CONCAT("<del class=\"area_mark",
    IF(area_power_reply="-1",
      " area_mark_\" title=\"本版评论回复：限注册用户",
      IF(area_power_reply>0,CONCAT(" area_mark_\" title=\"本版评论回复：受限，要求积分达到",area_power_write),"\" title=\"本版评论回复：过客可评论回复")),
    "\"><span>评</span></del>"),

  CONCAT("<del class=\"area_mark\" title=\"",
    IF(area_admin<>"",
      CONCAT("本版栏目版主为",area_admin),
      "本版栏目未设版主，管理员直接管理"),
    "\"><span>管</span></del>")
  )
';

}


?>