<?php
require ('authentication_manager.php');
?>
<?php
$n = 0;
$root_count = array();
$text = $text__ = $err = $root_pre = '';
if (isset($_GET['mode']) && $_GET['mode'] && file_exists('inc/css/'.$_GET['mode'])) { 
  $aarr = array();
  if (!isset($sql['db_err'])) {
    db_conn();
  }
  if ($sql['db_err'] == '') {
    $area_power = array();
    //栏目属性
    $result = @mysql_query('SELECT * FROM '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' WHERE area_id REGEXP "^[0-9]+\-[0-9]+$" AND (area_index="" OR area_index="0" OR area_index LIKE "%'.$_GET['mode'].'%")', $db);
    if (mysql_num_rows($result) > 0) {
      while ($row = @mysql_fetch_assoc($result)) {
        $area_power[$row['area_id']] = $row;
        $result_area = @mysql_query('SELECT * FROM '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' WHERE area_id="'.$row['area_id'].'" OR area_id LIKE "'.$row['area_id'].'\_%"', $db);
        $area_n = @mysql_num_rows($result_area);
        if ($area_n > 0) {
          $n += $area_n;
          while ($row_area = @mysql_fetch_assoc($result_area)) {
            $aarr[$row_area['area_id']] = $row_area;
            unset($row_area);
          }
        }
        @mysql_free_result($result_area);
        unset($row);
      }
    }
    @mysql_free_result($result);

    $result_root = @mysql_query('SELECT area_id FROM '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' GROUP BY ABS(area_id)', $db);
    $root_n = @mysql_num_rows($result_root);
    if ($root_n > 0) {
      while ($row_root = @mysql_fetch_assoc($result_root)) {
        $root_pre .= preg_replace('/\-.*$/', '-', $row_root['area_id']).' ';
        unset($row_root);
      }
    }
    @mysql_free_result($result_root);

    @mysql_close();

      $text .= '
<div class="column__"><b>提示：</b>以下信息必须认真填写，尽量不要用特殊符号，如 \ : ; * ? \' &lt; &gt; | ，必免导致错误。</div>
<div class="list_title"><a href="?get=area">&lt;&lt;返回</a><a href="?get=area" class="list_title_in">栏目分类<span>（'.$n.'）</span></a></div>
<ul class="manager_menu">'.open_citys($_GET['mode']).'所属模板：'.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>':'').'
<form class="column_in" name="root_form">
<button type="button" onclick="if(get_checkbox(\'root_pre\')==0){alert(\'请点选根目前缀！\');return false;}areaADD(\'root_\'+document.root_form.root_pre.value)"><b>增加新的根目</b></button> 在弹出的对话框中填写栏目名（IE8可能会屏蔽弹窗，请注意）<br />';
      $text .= '根目前缀：';
      $mode_n = count(@glob('./inc/css/*', GLOB_ONLYDIR));
      for ($i = 1; $i <= $mode_n; $i++) {
        $text .= '<input type="radio" class="radio" name="root_pre" id="root_pre_'.$i.'" value="'.$i.'-">'.$i.'- ';
      }
      $text .= '
当前'.$mode_n.'套模板，可启用'.$mode_n.'个根目前缀，当前已启用的根目前缀有'.$root_n.'个，分别为：'.$root_pre.'<br />

妙招注释：f模式及s模式下，如2-101、2-110、2-156 …等，当后面≥3位数时，同级三位数栏目排列在同组；2-201、2-208、2-215 …等，就属于另一组了

</form>
</ul>
';
    if (count($aarr) > 0) {
      @uksort($aarr, 'strnatcmp');

      $text .= '<div>';
      $base_mark = -1;
      foreach ($aarr as $row['area_id'] => $row) {
        $area_id_root = get_arearoot($row['area_id']);
        if ($area_id_root == $row['area_id']) {
          @ $root_count[abs($row['area_id'])]++;
        }
        if ($base_mark != $area_id_root) {
          $base_mark_b = '</div><div id="editbase_'.$area_id_root.'" class="arealili">';
        }
        $text .= $base_mark_b.'<div id="area_'.$row['area_id'].'" class="'.get_a_class($row['area_id']).'">'.($area_id_root==$row['area_id']?get_area_power($row['area_id']):'').get_br($row['area_id']).$row['area_id'].' <b id="area_name_'.$row['area_id'].'"'.$row['area_style'].'>'.$row['area_name'].'</b> <span style="color:#CCCCCC">（'.get_area_edit($row['area_id']).' '.get_area_seo($row['area_id'], $row['area_keywords'], $row['area_description']).'）</span></div>';
        $base_mark = $area_id_root;
        $base_mark_b = '';
        unset($area_id_root);
        @ob_flush();
        @flush();
      }
      $text .= '</div>';
$root_count = array_flip($root_count);
ksort($root_count);
$text .= '<script> try { $("root_pre_'.end($root_count).'").checked=true;}catch(e){} </script>';
    } else {
      $err .= '该模板下的栏目分类为空！';
    }
  } 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__">'.open_citys($base_index_mode).'<a href="?mode='.$base_index_mode.'&get=area">'.substr($base_index_mode, 0, 1).'*** ['.$title.'] 下的栏目分类管理 '.($web['sitemode']==$base_index_mode?'<span class="redword">√系统当前选择</span>':'').'</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 .= '没有任何模板，也无法进行栏目分类管理！';
  }
}

function open_citys($mode) {
  if (file_exists('inc/css/'.$mode.'/city.php')) {
    $chk = ' checked="checked"';
    if (preg_match('/不要动我，动则出事/', @file_get_contents('inc/css/'.$mode.'/city.php'))) {
      $chk_ = ' onclick="openCitysV(\''.$mode.'\',\'\');"';
      $chk__ = ' checked="checked"';
    } else {
      $chk_ = ' checked="checked"';
      $chk__ = ' onclick="openCitysV(\''.$mode.'\',2);"';
    }
    $chk2 = '<div style="line-height:normal; font-size:12px; color:blue;float:right;">
<input type="radio" name="opencitys['.$mode.'][]" class="radio"'.$chk_.' />共享无地区指定的数据<br />
<input type="radio" name="opencitys['.$mode.'][]" class="radio"'.$chk__.' />只显示指定地区的数据
</div>';
  }else{
    $chk = '';
    $chk2 = '';
  }
  return '<div style="float:right; width:250px;">'.$chk2.'<input type="checkbox" class="checkbox" onclick="openCitys(this,\''.$mode.'\');"'.$chk.' /> 开启多城市
</div>';
}



?>
<div id="downdata" class="red_err">载入中…</div>
<script language="javascript" type="text/javascript">
<!--


function openCitys(o, mode) {
  if (o.checked==true) {
    var act='citysopen';
  }else{
    var act='citysclose';
  }
  addSubmitSafe();
  $('runsave').src = '?post=area&mode='+mode+'&act='+act;
}

function openCitysV(mode,number) {
  addSubmitSafe();
  $('runsave').src = '?post=area&mode='+mode+'&act=citysopen&number='+number;
}



function getAreaIdRoot(areaId) {
  return areaId.toString().replace(/^(\d+\-\d+)(\_\d+)*$/, '$1');
}

function runCH(areaId, o, theForm) {
  if (o.checked == true) {
    if (!confirm('确定开启么？')) {
      o.checked = false;
      return false;
    }
  } else {
    if (!confirm('确定关闭么？')) {
      o.checked = true;
      return false;
    }
  }
  addSubmitSafe();
  theForm.submit();
}

function runAD(areaId, theForm) {
  if (!confirm('确定保存么？')) {
    return false;
  }
  var un = $('area_admin_'+areaId+'');
  if (un.value != '' && !un.value.match(/^([^\x00-\x7f]|\w|\,){3,45}$/)) {
    alert('提交被拒绝！版主名请用汉字、数字、英文及下划线组成！请填写注册成员。如多个版主请用 , 分隔');
	un.focus();
    return false;
  }
  addSubmitSafe();
  theForm.submit();
}

function runPW(areaId, theForm) {
  if (!confirm('确定保存么？')) {
    return false;
  }
  addSubmitSafe();
  theForm.submit();
}

function areaEDI(areaId) {
  var areaNameOld = $('area_name_'+areaId+'').innerHTML;
  if (areaNameNew = prompt('新栏目名为：（系统将不进行重名查询）', areaNameOld)) {
    if (areaNameOld == areaNameNew) {
      alert('未做更改！');
      return;
    }
    addSubmitSafe();
    $('runsave').src = '?post=area&mode=<?php echo $_GET['mode']; ?>&area_id='+areaId+'&area_name='+encodeURIComponent(areaNameNew)+'&act=edit';
  }
}

function areaSEO(areaId, type) {
  var seoOld = $('area_seo_'+type+'_'+areaId+'').title;
  if (seoNew = prompt('该栏目'+type+'为：', seoOld)) {
    if (seoOld == seoNew) {
      alert('未做更改！');
      return;
    }
    addSubmitSafe();
    $('runsave').src = '?post=area&mode=<?php echo $_GET['mode']; ?>&area_id='+areaId+'&area_'+type+'='+encodeURIComponent(seoNew)+'&act=seo';
  } else {
    if (seoOld != '' && seoNew == '') {
      if (confirm('确定清空么？')) {
        addSubmitSafe();
        $('runsave').src = '?post=area&mode=<?php echo $_GET['mode']; ?>&area_id='+areaId+'&area_'+type+'='+encodeURIComponent(seoNew)+'&act=seo';
      } else {
        return;
      }
    }
  }
}


//删除
function areaDEL(areaId) {
  if (!confirm("重要提示：确定删除么？如果有子栏目、及所辖所有数据将一并删除\n（数据量大时要花费较长时间）")) {
    return false;
  }
  var listdel = '';
  /*
  if (confirm('数据库里的文章也一并删除么？点确定删除，点取消不删除（数据量大要花费较长时间）')) {
    listdel = '&listdel=yes';
  }
  */
  addSubmitSafe();
  $('runsave').src = '?post=area&mode=<?php echo $_GET['mode']; ?>&area_id='+areaId+'&act=del'+listdel+'';
}

function areaDELp(areaId) {
  var parO = $('editbase_'+getAreaIdRoot(areaId)+'');
  var divs = parO.getElementsByTagName('DIV');
  var del = [];
  var step = 0;
  for (var i = 0; i < divs.length; i++) {
    if (divs[i].parentNode.id == 'editbase_'+getAreaIdRoot(areaId)+'') {
      if (divs[i].id.indexOf('area_'+areaId) == 0) {
        del[step++] = divs[i];
      }
    }
  }
  var dellength = del.length;
  if (dellength > 0) {
    for (var i = 0; i < dellength; i++) {
      parO.removeChild(del[i]);
    }
  }
  delSubmitSafe();
}

//转移
function areaMOV(areaId) {
  if (areaIdNew = prompt('当前分类ID为'+areaId+'，请输入新的分类ID。注：所有子树将一并被转移', '')) {
    if (!areaIdNew.match(/^\d+\-\d+(\_\d+)*$/)) {
      alert('分类参数不合法！应该为数字（间隔可含下划线）');
      areaMOV(areaId);
      return false;
    }
    if ($('area_'+areaIdNew) != null) {
      alert('分类'+areaIdNew+'已经存在！');
      areaMOV(areaId);
      return false;
    }
    var base = areaIdNew;
    while (base.indexOf('_')>=0) {
      base = base.replace(/\_\d+$/, '');
      if ($('area_'+base) == null) {
        alert('上级分类'+base+'不存在！');
        areaMOV(areaId);
        return false;
      }
    }
    if (confirm('数据库里的文章也一并转移么？点确定转移，点取消不转移（数据量大时要花费较长时间）')) {
      var listmov = '&listmov=yes';
    } else {
      var listmov = '';
    }
    addSubmitSafe();
    $('runsave').src = '?post=area&mode=<?php echo $_GET['mode']; ?>&area_id='+areaId+'&area_id_new='+areaIdNew+'&act=mov'+listmov+'';
  }
}

//增树
function areaADD(areaId) {
  if (areaNameNew = prompt('新栏目名为：（系统将不进行重名查询）', '')) {
    if (areaNameNew.replace(/^\s+$/, '') == '') {
      alert('栏目名不能空值！');
      areaADD(areaId);
      return false;
    }
    addSubmitSafe();
    $('runsave').src = '?post=area&mode=<?php echo $_GET['mode']; ?>&area_id='+areaId+'&area_name='+encodeURIComponent(areaNameNew)+'&act=add';
  }
}

function areaADDp(areaId, newAreaId, newAreaPo) {
  var newPos = null;
  if (newAreaPo == 'NULL') {
    newPos = null;
    parObj = $('root');
  } else {
    var areaP = $('area_'+newAreaPo);
    if (areaP != null) {
      var nextObj = areaP.nextSibling;
      while(nextObj!=null && nextObj.nodeType!=1){
        nextObj=nextObj.nextSibling;
      }
      newPos = nextObj;
    }
    parObj = $('editbase_'+getAreaIdRoot(areaId)+'');
  }
  var newDiv = document.createElement('DIV');
  newDiv.id = 'area_'+newAreaId;
  newDiv.className = 'lili';
  newDiv.innerHTML = '\
  '+(newAreaId.replace(/[^_]+/g,'').replace(/_/g,'　　'))+''+newAreaId+' <b id="area_name_'+newAreaId+'" style="background-color:#FFCC00;">'+areaNameNew+'</b> \
  <span style="color:#CCCCCC">（编辑<a href="#" onclick="areaEDI(\''+newAreaId+'\');return false;" class="li_e">更名</a>\
  <a href="#" onclick="areaMOV(\''+newAreaId+'\');return false;" class="li_e">转移</a>\
  <a href="#" onclick="areaADD(\''+newAreaId+'\');return false;" class="li_e">增加树类</a>\
  <a href="#" onclick="areaDEL(\''+newAreaId+'\');return false;" class="li_e">删除</a>\
  字体<a href="?post=area&area_id='+newAreaId+'&act=add_style&style=redword" onclick="addSubmitSafe();" target="runsave" class="li_e redword">红</a><a href="?post=area&area_id='+newAreaId+'&act=add_style&style=greenword" onclick="addSubmitSafe();" target="runsave" class="li_e greenword">绿</a><a href="?post=area&area_id='+newAreaId+'&act=add_style&style=grayword" onclick="addSubmitSafe();" target="runsave" class="li_e grayword">灰</a><a href="?post=area&area_id='+newAreaId+'&act=add_style&style=boldword" onclick="addSubmitSafe();" target="runsave" class="li_e boldword">粗</a><a href="?post=area&area_id='+newAreaId+'&act=add_style&style=" onclick="addSubmitSafe();" target="runsave" class="li_e">无</a>\
  SEO<a href="#" onclick="areaSEO(\''+newAreaId+'\', \'keywords\');return false;" class="li_e" id="area_seo_keywords_'+newAreaId+'" title="">关键词keywords</a>\
  <a href="#" onclick="areaSEO(\''+newAreaId+'\', \'description\');return false;" class="li_e" id="area_seo_description_'+newAreaId+'" title="">简介description</a>\
\ ）</span>';
  parObj.insertBefore(newDiv,newPos);
  //location.href=location.href.replace(/\#.*$/ig,'')+'.area_name_'+newAreaId+'';
  delSubmitSafe();
}

/*
function areaADD(areaId){
  addSubmitSafe();
  var parO=$('editbase_'+getAreaIdRoot(areaId)+'');
  var divs=parO.getElementsByTagName('DIV');
  var step='';
  var pos=null;
  //alert(areaId)
  for(var i=0;i<divs.length;i++){
    if(divs[i].parentNode.id=='editbase_'+getAreaIdRoot(areaId)+''){
      if(divs[i].id!=''){
        if(getAreaIdRoot(divs[i].id.substr(5))<=getAreaIdRoot(areaId)){
          if(divs[i].id.indexOf('area_'+areaId+'_')==0){
            pos=divs[i];
            if(!divs[i].id.substr(('area_'+areaId+'_').length).match(/_+/)){
              step++;
            }
          }
        }else{
          break;
        }
      }
    }
  }

  var areaName='asfasfasdfasd';
  if(pos==null){
    var p=$('area_'+areaId); //插入位置ID
    var nid=areaId+'_1';
  }else{
    var p=pos; //插入位置ID
    var nid=areaId+'_'+(parseFloat(p.id.replace(/^.+_(\d+)$/,'$1'))+1);
  }
  //alert(p.id); //插入位置ID
  //alert(nid)
  var newDiv=document.createElement('DIV');
  newDiv.id='area_'+nid;
  newDiv.className='lili';
  newDiv.innerHTML='\
  '+(nid.replace(/[^_]+/g,'').replace(/_/g,'　　'))+''+nid+' <span id="area_name_'+nid+'" class="redword">'+areaName+'</span> \
  <a href="#" onclick="areaEDI(\''+nid+'\');return false;" class="li_e">更名</a>\
  <a href="#" onclick="areaDEL(\''+nid+'\');return false;" class="li_e">删除</a>\
  <a href="#" onclick="areaADD(\''+nid+'\');return false;" class="li_e">增加树类</a>';
  parO.insertBefore(newDiv,p.nextSibling);
  location.href='#area_'+nid;
  delSubmitSafe();
}
*/

function chanE(o, areaId){
  if(o.innerHTML.indexOf('︾')>=0){
    try{$('editbase_'+getAreaIdRoot(areaId)+'').style.height='auto';}catch(e){}
    o.innerHTML=o.innerHTML.replace(/︾/g, '︽');
  }else{
    try{$('editbase_'+getAreaIdRoot(areaId)+'').style.height='39px';}catch(e){}
    o.innerHTML=o.innerHTML.replace(/︽/g, '︾');
  }
}
-->
</script>
<style type="text/css">
<!--
.say { padding:7px; font-size:12px; border:1px #DB696E solid; line-height:normal; }
.say td { padding:0; line-height:normal; }
.say form input, .say td, .say a { font-size:12px; }
.say a { color: #66CCCC; }
.column__ { margin-bottom:10px; line-height:39px; text-align:left; clear:both; background-color:#ECECEC; overflow:hidden; }
.column__ .edit_bar { display:block; background-color:#D8D8D8; }
.arealili { width:100%; height:39px; margin-bottom:10px; overflow:hidden; clear:both; }

.lilili { text-align:left; }
.lili { text-align:left; }
/*.li span, .lili span { color:#333333; }*/
.li_e { font-size:12px; color: #66CCCC; }
.areatitleform { display:inline-block !important; display:inline; zoom:1; width:78px; height:24px; position:relative; }
.thismodeuploadfile { position:absolute; top:0; left:0; width:78px; height:24px; background-color:#FFFFFF; overflow:hidden; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0); -moz-opacity:0; -khtml-opacity:0; opacity:0; }
-->
</style>
<?php
function get_br($area_id) {
  return str_replace('_', '　　', preg_replace('/[\d\-]+/', '', $area_id));
}

function get_area_edit($area_id) {
  return '编辑
  <a href="#" onclick="areaEDI(\''.$area_id.'\');return false;" class="li_e">更名</a>
  <a href="#" onclick="areaMOV(\''.$area_id.'\');return false;" class="li_e">转移</a>
  <a href="#" onclick="areaADD(\''.$area_id.'\');return false;" class="li_e">增加树类</a>
  <a href="#" onclick="areaDEL(\''.$area_id.'\');return false;" class="li_e">删除</a>
  字体<a href="?post=area&area_id='.$area_id.'&act=add_style&style=redword" onclick="addSubmitSafe();" target="runsave" class="li_e redword">红</a><a href="?post=area&area_id='.$area_id.'&act=add_style&style=greenword" onclick="addSubmitSafe();" target="runsave" class="li_e greenword">绿</a><a href="?post=area&area_id='.$area_id.'&act=add_style&style=grayword" onclick="addSubmitSafe();" target="runsave" class="li_e grayword">灰</a><a href="?post=area&area_id='.$area_id.'&act=add_style&style=boldword" onclick="addSubmitSafe();" target="runsave" class="li_e boldword">粗</a><a href="?post=area&area_id='.$area_id.'&act=add_style&style=" onclick="addSubmitSafe();" target="runsave" class="li_e">无</a>
';
}
function get_area_seo($area_id, $keywords, $description) {
  return '
  SEO<a href="#" onclick="areaSEO(\''.$area_id.'\', \'keywords\');return false;" class="li_e" id="area_seo_keywords_'.$area_id.'" title="'.$keywords.'">关键词keywords</a>
  <a href="#" onclick="areaSEO(\''.$area_id.'\', \'description\');return false;" class="li_e" id="area_seo_description_'.$area_id.'" title="'.$description.'">简介description</a>

';
}

function get_area_power($area_id) {
  global $web, $up_key;
  global $area_power;
  $text = '';
  //return get_arearoot($area_id);
    $bg = array_rand(array("Black" => "黑色", "Sienna" => "赭色", "DarkOliveGreen" => "暗橄榄绿色", "DarkGreen" => "暗绿色", "DarkSlateBlue" => "暗灰蓝色", "Navy" => "海军色", "Indigo" => "靛青色", "DarkSlateGray" => "墨绿色", "DarkRed" => "暗红色", "DarkOrange" => "暗桔黄色", "Olive" => "橄榄色", "Green" => "绿色", "Teal" => "水鸭色", "Blue" => "蓝色", "SlateGray" => "灰石色", "DimGray" => "暗灰色", "Red" => "红色", "SandyBrown" => "沙褐色", "YellowGreen" => "黄绿色", "SeaGreen" => "海绿色", "MediumTurquoise" => "间绿宝石", "RoyalBlue" => "皇家蓝", "Purple" => "紫色", "Gray" => "灰色", "Magenta" => "红紫色", "Orange" => "橙色", "Yellow" => "黄色", "Lime" => "酸橙色", "Cyan" => "青色", "DeepSkyBlue" => "深天蓝色", "DarkOrchid" => "暗紫色", "Silver" => "银色", "Pink" => "粉色", "Wheat" => "浅黄色", /*"LemonChiffon" => "柠檬绸色",*/ "PaleGreen" => "苍绿色", "PaleTurquoise" => "苍宝石绿", "LightBlue" => "亮蓝色", "Plum" => "洋李色", /*"White" => "白色"*/));
    //global $row;
    $text .= '<div class="column__"><a id="edit_bar_'.$area_id.'" class="edit_bar" href="javascript:void(0)" onclick="chanE(this, \''.$area_id.'\');return false;">'.$area_id.' <b style="font-size:14px;" '.$area_power[$area_id]['area_style'].'>'.$area_power[$area_id]['area_name'].'</b> - 管理︾'.(empty($area_power[$area_id]['area_index']) ? ' <span class="grayword">尚未分配给任何模板的版区分类（即隐藏的版区分类）</span>':'').'</a>';
    $text .= '
      <form action="?post=area&area_id='.$area_id.'&act=index" target="runsave" method="post" style=" line-height:normal;">该栏目分类分配给';

  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 .= '
<br /><input type="checkbox" class="checkbox" name="area_index[]" value="'.$base_index_mode.'"'.(!empty($area_power[$area_id]['area_index']) && strstr($area_power[$area_id]['area_index'], $base_index_mode) ? ' checked="checked"' : '').' />
'.$base_index_mode.'['.$title.'] ';
      }
      unset($base_index_mode, $title);
    }
  }
    $text .= '<br /><button type="button" onclick="runPW(\''.$area_id.'\',this.form)"><b>保存</b></button><span style="color:#999999;">（注：不分配给任何模板则隐藏）</span>
</form>';


    $text .= '<div class="say"><b>根类规则</b> 下属所有子栏目都遵循<br />
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="360" style="text-align:left">栏目图标：当前模板下为'.(file_exists('inc/css/'.$_GET['mode'].'/area_logo_'.$area_id.'.gif') ? '<img id="upl_'.$area_id.'" src="inc/css/'.$web['sitemode'].'/area_logo_'.$area_id.'.gif" width="60" height="60" style="vertical-align:middle" />' : '<img id="upl_'.$area_id.'" alt="未上传" width="60" height="60" style="vertical-align:middle" />').' 默认为<div style="vertical-align:middle;display:inline-block !important; display:inline; zoom:1;width:60px;height:60px;line-height:60px;font-family:Tahoma;text-align:center;font-size:18px;color:#FFFFFF;background:'.$bg.' url(inc/images/area_logo_default.gif);">'.$area_id.'</div></td>
    <td style="text-align:left"><form name="areatitleform" class="areatitleform" action="?post=area&mode='.$_GET['mode'].'&area_id='.$area_id.'&act=upl" enctype="multipart/form-data" target="runsave" method="post"><input name="uploadfile" class="thismodeuploadfile" type="file" onchange="addSubmitSafe();this.form.submit();"><button type="button"><b>上传新图标</b></button></form> <a href="?post=area&mode='.$_GET['mode'].'&area_id='.$area_id.'&act=upd" target="runsave"><button type="button"><b>恢复默认</b></button></a><br />（图片大小为60×60，格式限.jpg、.gif、png）</td>
  </tr>
</table>


      <form action="?post=area&area_id='.$area_id.'&act=area_mode" target="runsave" method="post">列表模式：<input type="radio" class="radio" name="area_mode" value="0"'.($area_power[$area_id]['area_mode'] == '0' ? ' checked' : '').' />普通列表 <a href="list.php?mode='.$_GET['mode'].'&list_mode=0" target="_blank">示列</a> <a href="http://info.162100.com/list.php?mode='.$_GET['mode'].'&list_mode=0" target="_blank">官方示列</a><br />
　　　　　<input type="radio" class="radio" name="area_mode" value="1"'.($area_power[$area_id]['area_mode'] == '1' ? ' checked' : '').' />显示头像/LOGO <a href="list.php?mode='.$_GET['mode'].'&list_mode=1" target="_blank">示列</a> <a href="http://info.162100.com/list.php?mode='.$_GET['mode'].'&list_mode=1" target="_blank">官方示列</a><br />
　　　　　<input type="radio" class="radio" name="area_mode" value="2"'.($area_power[$area_id]['area_mode'] == '2' ? ' checked' : '').' />显示缩略图 <a href="list.php?mode='.$_GET['mode'].'&list_mode=2" target="_blank">示列</a> <a href="http://info.162100.com/list.php?mode='.$_GET['mode'].'&list_mode=2" target="_blank">官方示列</a><br />
　　　　　<input type="radio" class="radio" name="area_mode" value="3"'.($area_power[$area_id]['area_mode'] == '3' ? ' checked' : '').' />同时显示头像/LOGO，显示缩略图 <a href="list.php?mode='.$_GET['mode'].'&list_mode=3" target="_blank">示列</a> <a href="http://info.162100.com/list.php?mode='.$_GET['mode'].'&list_mode=3" target="_blank">官方示列</a><br />
　　　　　<input type="radio" class="radio" name="area_mode" value="4"'.($area_power[$area_id]['area_mode'] == '4' ? ' checked' : '').' />流布局（适合于图片文章） <a href="list.php?mode='.$_GET['mode'].'&list_mode=4" target="_blank">示列</a> <a href="http://info.162100.com/list.php?mode='.$_GET['mode'].'&list_mode=4" target="_blank">官方示列</a>

<button type="submit"><b>保存</b></button></form>

      <form action="?post=area&area_id='.$area_id.'&act=check" target="runsave" method="post">发表审核：<input type="checkbox" class="checkbox" name="check" value="1" onclick="runCH(\''.$area_id.'\',this,this.form)"'.($area_power[$area_id]['area_check'] == '1' ? ' checked' : '').' />开启审核</form>
      <form action="?post=area&mode='.$_GET['mode'].'&area_id='.$area_id.'&act=check_reply" target="runsave" method="post">回复审核：<input type="checkbox" class="checkbox" name="check_reply" value="1" onclick="runCH(\''.$area_id.'\',this,this.form)"'.($area_power[$area_id]['area_check_reply'] == '1' ? ' checked' : '').' />开启审核</form>';
    foreach (array('write' => '发表权限', 'read' => '浏览权限', 'reply' => '回复权限') as $p => $pk) {
      $text .= '
      <form action="?post=area&area_id='.$area_id.'&act='.$p.'" target="runsave" method="post">'.$pk.'：<input type="radio" class="radio" name="'.$p.'" value="0"'.($area_power[$area_id]['area_power_'.$p.''] == '0' ? ' checked' : '').' />匿名
      <input type="radio" class="radio" name="'.$p.'" value="-1"'.($area_power[$area_id]['area_power_'.$p.''] == '-1' ? ' checked' : '').' />成员
      <input type="radio" class="radio" name="'.$p.'" id="p_2_'.$p.'_'.$area_id.'" value="1"'.(floatval($area_power[$area_id]['area_power_'.$p.'']) > 0 ? ' checked' : '').' />积分大于<input type="text" name="p_point" size="6" value="'.($a_p = floatval($area_power[$area_id]['area_power_'.$p.'']) > 0 ? $area_power[$area_id]['area_power_'.$p.''] : '1').'" onfocus="$(\'p_2_'.$p.'_'.$area_id.'\').checked=true" onkeyup="isDigit(this,\''.$a_p.'\')" />
      <button type="button" onclick="runPW(\''.$area_id.'\',this.form)"><b>保存</b></button> 注：该权限从更改时开始执行</form>';
    }
    $text .= '
      <form action="?post=area&area_id='.$area_id.'&act=admin" target="runsave" method="post">栏目版主：
      <input type="text" name="username" id="area_admin_'.$area_id.'" style="width:210px" value="'.$area_power[$area_id]['area_admin'].'" />
      <button type="button" onclick="runAD(\''.$area_id.'\',this.form)"><b>保存</b></button> 多个版主请用英文逗号 , 分隔</form>';
    $text .= '
      <form action="?post=area&area_id='.$area_id.'&act=expires" target="runsave" method="post">文章时效：
      <input type="text" name="expires" value="'.($area_power[$area_id]['area_expires'] = abs($area_power[$area_id]['area_expires'])).'" size="3" onkeyup="isDigit(this,\''.$area_power[$area_id]['area_expires'].'\',1)" /> 天
      <button type="button" onclick="runPW(\''.$area_id.'\',this.form)"><b>保存</b></button> 0表示永不过期。<span class="redword">提醒：设置过期会降低数据库检索速度</span></form>';
    $text .= '</div>';
    $text .= '
</div>';
  return $text;
}

function get_a_class($area_id) {
  static $mark2 = 'none';
  $text = 'lili';
  if ($mark2 != get_arearoot($area_id)) {
    $text = 'lilili';
    $mark2 = get_arearoot($area_id);
  }
  return $text;
}

?>
<iframe id="runsave" name="runsave" frameborder="0" style=" display:none;"></iframe>
<div id="root">
<?php echo $text,$text__, $err; ?>
</div>
<?php echo @$_GET['area_id'] ? '<script> try{ chanE($(\'edit_bar_'.$_GET['area_id'].'\'), \''.get_arearoot($_GET['area_id']).'\'); } catch(e){} </script>' : ''; ?>

<script> $("downdata").style.display="none"; </script>
<div style="text-align:right;"><a href="http://www.162100.com/help/162100FAIcode.html" target="_blank">定位的城市不准怎么办？</a></div>
