<?php
require ('authentication_manager.php');
?>
<style type="text/css">
<!--
a.run_bar { font-size:12px; margin-left:1px; margin-right:1px; padding:1px; background-color: #999966; font-weight:normal; color: #FFF; }

-->
</style>
<script language="javascript" type="text/javascript">
<!--
function toToid(){
  $('lastFrame').style.display='block';
  $('lastFrame').src='inc/require/z_other_chanto.php?mode=<?php echo $GLOBALS['this_mode']; ?>';
}

function setCredit(t, v) {
  if(t){
    $('creditV').style.display='block';
    if(t=='增加'){
      $('creditV').innerHTML='同时操作：增加<input name="funds_value" onkeyup="isDigit(this,\'1\',0,\'.\')" type="text" size="6" value="0" />可用（货币）分，增加<input name="credit_value" onkeyup="isDigit(this,\'1\',1,\'.\')" type="text" size="6" value="0" />信誉值 '+(v == 1 ? '<button name="act2" id="essbutton" type="button" onclick="chk(this.form,this,\'ess\')"><b>推荐提交</b></button>' : '')+'';
    } else {
      $('creditV').innerHTML='同时操作：减掉<input name="funds_value" onkeyup="isDigit(this,\'1\',0,\'.\')" type="text" size="6" value="0" />可用（货币）分，减掉<input name="credit_value" onkeyup="isDigit(this,\'1\',1,\'.\')" type="text" size="6" value="0" />信誉值 '+(v == 1 ? '<button name="act2" id="cessbutton" type="button" onclick="chk(this.form,this,\'cess\')"><b>撤荐提交</b></button>' : '')+'';

    }
  }else{
    $('creditV').style.display='none';
  }
}

-->
</script>
<?php

/* 管理已发文章 */
/* 162100源码 - 162100.com */


//处理关键字
function process_input() {
  $str = preg_replace('/[[:punct:]]/i', ' ', $_GET['keyword']);
  $str = preg_replace('/\pP/u', ' ', $str);
  $str=trim($str);
  //$str=str_replace(' ','|',$str);
  return $str;
}

function toUnicode($word) {
  $l = strlen($word);
  $bin_str = '';
  for ($i = 0; $i < $l; $i++) {
    $bin_str .= decbin(ord(substr($word, $i, 1)));
  }
  $bin_str = preg_replace('/^.{4}(.{4}).{2}(.{6}).{2}(.{6})$/','$1$2$3', $bin_str);  
  return '&#'.bindec($bin_str).';';  
}


//加亮标题中的关键字
function red_keyword_title($str) {
  global $keyword;
  return !empty($keyword) ? @preg_replace('/('.$keyword.')/i','<span class="redword">$1</span>', $str) : $str;
}

//加亮内容中的关键字
function red_keyword_text($str){
  global $keyword;
  if(preg_match('/('.str_replace(' ','|',$keyword).')/i',$str,$matches)){
    $str=cutstr(strstr((string)$str,(string)$matches[1]),300);
    return @preg_replace('/('.$keyword.')/i','<span class="redword">$1</span>',$str);
  } else {
    return '……';
  }
}

function get_admin_area_iq($area_id_arr) {
  return preg_match('/^(\(\d+\-\d+\))+$/', $area_id_arr) ? '(area_id="'.str_replace(')(', '" OR area_id="', trim($area_id_arr, '()')).'")' : '';

}
function get_admin_area_id($area_id_arr) {
  return preg_match('/^(\(\d+\-\d+\))+$/', $area_id_arr) ? '('.trim(preg_replace('/\((\d+\-\d+)\)/', 'B.area_id="$1" OR B.area_id LIKE "$1\_%" OR ', $area_id_arr), ' OR').')' : '';

}

$article_url = $web['url_html_article'] == 1 ? '"article.".$area_mode[$area_id_root].".".$row["id"].".1.html"' : '"article.php?mode=".$area_mode[$area_id_root]."&id=".$row["id"].""';
$_GET['act'] = @$_GET['act'];
$text = $err = $e = '';
if ($_GET['act'] == 'search') {
  require('inc/function/cutstr.php');

  $keyword = process_input();
  $key = preg_replace('/[\xe0-\xef][\x80-\xbf]{2}/e', '"".toUnicode("$0").""', $keyword);
  //$key = str_replace('|', '%', $keyword);

  if (POWER == 2 || POWER == 3) {
    $whole_eval = ' AND '.get_admin_area_iq($session[4]).'';
    $out = '您所辖版区的';
  } else {
    $whole_eval = '';
    $out = '全部';
  }
  $where_key1 = '"SELECT COUNT(A.id) AS total FROM '.$sql['pref'].''.$sql['data']['承载关键词的表名'].' AS A,'.$sql['pref'].''.$sql['data']['承载主题文章的表名'].' AS B WHERE".$where_key__." B.area_check=\"0\" AND A.id=B.id AND (MATCH (A.title) AGAINST (\'\"'.$key.'\"\' IN BOOLEAN MODE))"';
  $where_key2 = '"SELECT B.* FROM '.$sql['pref'].''.$sql['data']['承载关键词的表名'].' AS A,'.$sql['pref'].''.$sql['data']['承载主题文章的表名'].' AS B WHERE".$where_key__." B.area_check=\"0\" AND A.id=B.id AND (MATCH (A.title) AGAINST (\'\"'.$key.'\"\' IN BOOLEAN MODE)) ORDER BY A.id DESC LIMIT ".$seek.",".$web["pagesize"].""';



  if ($keyword == '') { //检验关键字
    $e = '请输入字、句等有效的查询字符！';
  }
  if (($strlength = strlen($keyword)) && ($strlength > 100 || $strlength < 3)){
    $e = '关键字长度请大于等于3且少于100字符！';
  }
  $text_eval = '$text .= "<div class=\"text\">".red_keyword_text($row["text"])."</div>";';
  $search_r = '搜索结果 - ';

} else {
  if (POWER == 2 || POWER == 3) {
    $whole_eval = ' AND '.get_admin_area_iq($session[4]).'';
    $out = '您所辖版区的';
  } else {
    $whole_eval = '';
    $out = '全部';
  }
  $where_key1 = '"SELECT COUNT(B.id) AS total FROM '.$sql['pref'].''.$sql['data']['承载主题文章的表名'].' AS B WHERE".$where_key__." B.area_check=\"0\""';
  $where_key2 = '"SELECT B.* FROM '.$sql['pref'].''.$sql['data']['承载主题文章的表名'].' AS B WHERE".$where_key__." B.area_check=\"0\" ORDER BY B.topdate DESC LIMIT ".$seek.",".$web["pagesize"].""';
}
?>


<?php
echo $e;


if (!isset($sql['db_err'])) {
  db_conn();
}

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

  $arr_area_title = $arr_area_child = $row_area_expires = array();
  if (isset($_GET['area_id']) && preg_match('/^(\d+\-\d+)(\_\d+)*$/', $_GET['area_id'], $area_m) && (POWER >= 4 || strstr($session[4], '('.$area_m[1].')'))) {
    $area_id_root = $area_m[1];

    $mark_child = '该标签仍可细分';
    $base_title = $_GET['area_id'];
    $eval_title = 'area_id="'.$_GET['area_id'].'"';
    $area_title = 'strip_tags($arr_area_title[\''.$_GET['area_id'].'\'])';
    while (strpos($base_title, '_') !== false) {
      $base_title = preg_replace('/\_\d+$/', '', $base_title);
      $eval_title .= ' OR area_id="'.$base_title.'"';
      $area_title = '$arr_area_title[\''.$base_title.'\'].\' &gt; \'.'.$area_title.'';
    }
    $result = @mysql_query('SELECT * FROM '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' WHERE '.$eval_title.' OR area_id REGEXP "^'.$_GET['area_id'].'_[0-9]+$"', $db);
    if (@mysql_num_rows($result) > 0) {
      $q_l = strlen($_GET['area_id']);
      while ($row = @mysql_fetch_assoc($result)) {
        if ($row['area_id'] == $area_id_root) {
          $area_mode[$row['area_id']] = get_li_mode($row['area_index']);
          if (floatval($row['area_expires']) > 0) {
            $row_area_expires[$row['area_id']] = floatval($row['area_expires']);
          }
        }
        if ($q_l >= strlen($row['area_id'])) {
          $arr_area_title[$row['area_id']] = '<a href="?get=list&area_id='.$row['area_id'].'"'.$row['area_style'].'>'.$row['area_name'].'</a> ';
        } else/*if (strrpos($row['area_id'], '_') == $q_l)*/ {
          $arr_area_child[$row['area_id']] = '<a href="?get=list&area_id='.$row['area_id'].'"'.$row['area_style'].'>'.$row['area_name'].'</a>';
        }
        unset($row);
      }
    }
    @mysql_free_result($result);
    @uksort($arr_area_child, 'strnatcmp');
//eval('$title1 = '.$area_title.';');
    eval('$title = strip_tags('.$area_title.').\' - '.$web['sitename2'].'\'; $title1 = \'<a href="webmaster_central.php?get=list">全部根目</a> &gt; \'.'.$area_title.';');

    if (empty($arr_area_title[$_GET['area_id']])) {
      die('&#26631;&#31614;&#38169;&#35823;&#65281;&#35831;&#20174;<a href="./?get=list">&#39318;&#39029;</a>&#37325;&#26032;&#24320;&#22987;');
    }
    $where_key__ = (!empty($arr_area_child) ? ' B.area_id LIKE "'.$_GET['area_id'].'\_%"' : ' B.area_id="'.$_GET['area_id'].'"').' AND';

    //$where_key = ' WHERE '.$where_key__.' AND area_check="0"'.$where_key_.''; //      /_%" ESCAPE "/"

    //die($where_key);

    $arspit = 'if($row["area_id"] != $_GET["area_id"]){
               $a_id = $_GET["area_id"]."_".abs(substr($row["area_id"], strlen($_GET["area_id"]."_")));
               $area_name=" <span class=\"ar\">[".$arr_area_child[$a_id]."".($a_id == $row["area_id"] ? "" : "/…")."]</span>";
             }';

  } else {
    $power_err = isset($_GET['area_id']) && $_GET['area_id'] != '' && POWER < 4 ? '<span class="redword">操作越权！您没栏目['.$_GET['area_id'].']的管理权限 - </span>' : '';
    $mark_child = ''.$out.'模板下的根类目';
    $title1 = '全部根目';

    $result = @mysql_query('SELECT * FROM `'.$sql['pref'].''.$sql['data']['承载版区分类的表名'].'` WHERE area_id REGEXP "^[0-9]+\-[0-9]+$" '.$whole_eval.'', $db);
	
    if (@mysql_num_rows($result) > 0) {
      while ($row = @mysql_fetch_assoc($result)) {
        $arr_area_child[$row['area_id']] = '<a href="?get=list&area_id='.$row['area_id'].'"'.$row['area_style'].'>'.$row['area_name'].'</a>';
        if (floatval($row['area_expires']) > 0) {
          $row_area_expires[$row['area_id']] = floatval($row['area_expires']);
        }
        $area_mode[$row['area_id']] = get_li_mode($row['area_index']);
        unset($row);
      }
    }
    @mysql_free_result($result);
    @uksort($arr_area_child, 'strnatcmp');
    $where_key__ = get_admin_area_id($session[4]);
    $where_key__ = $where_key__ == '' ? ' ' : ' '.$where_key__.' AND';

    $arspit = '$area_name=" <span class=\"ar\">[".$arr_area_child[$area_id_root]."/…]</span>";';
  }

  $result = @mysql_query(''.eval('return '.$where_key1.';').'', $db);
  $row = @mysql_fetch_assoc($result);
  $n = abs($row['total']);
  @mysql_free_result($result);
  unset($row);

//die($whole_eval);
//die($where_key);
//print_r($arr_area_child);die;
  require ('inc/function/get_page.php');
  require ('inc/function/get_date.php'); //时间
  if ($n > 0) :
    $p = get_page($n); //页数
    $seek = $web['pagesize'] * ($p-1);

    $result = @mysql_query(''.eval('return '.$where_key2.';').'', $db);
    while ($row = @mysql_fetch_assoc($result)) {
      //$row['title'] = preg_replace('/(\|.*)?/', '', $row['title']);
      $area_id_root = get_arearoot($row['area_id']);
      @eval($arspit);
      if (isset($row_area_expires[$area_id_root]) && $row_area_expires[$area_id_root] > 0) {
        if (gmdate('Y-m-d H:i:s', time() + floatval($web['time_pos']) * 3600 - $row_area_expires[$area_id_root] * 24 * 60 * 60) > $row['topdate']) {
          $area_name .= '<span class="ar">[已过期]</span>';
        }
      }
          $text .= '
<table width="100%" class="li_face" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="20"><input name="id[]" id="id[]" type="checkbox" class="checkbox" value="'.$row['id'].'" /><input name="area_id['.$row['id'].']" id="area_id['.$row['id'].']" type="hidden" value="'.$row['area_id'].'" /></td>
    <td class="li_subject">
      '.$row['title_mark'].'<a href="'.eval('return '.$article_url.';').'" class="li_a" target="_blank"'.$row['title_style'].'>'.red_keyword_title($row['title']).'</a> '.$area_name.' '.(empty($row['city']) ? ' <img src="inc/images/po.gif" title="此条未指定地区" />' : '<span class="ar">['.$row['city'].']</span>').'
     <div class="li_">
	  发表 '.(strstr((string)$row['author_ip'], '.') ? '<span title="匿名用户">'.$row['author_ip'].'</span> <a href="?post=ip&ips='.$row['author_ip'].'&m=1" class="run_bar" target="lastFrame">屏蔽此IP</a>' : '<a href="user.php?get=card&username='.urlencode($row['author_ip']).'" target="_blank" title="点击查看发布人名片"><img src="inc/images/card.gif" />'.$row['author_ip'].'</a> <a href="?get=member&username='.urlencode($row['author_ip']).'" class="run_bar" target="_blank">管理作者</a><a href="?post=unity_run&dataname=member&id[]='.urlencode($row['author_ip']).'&limit=del" class="run_bar" title="直接删除作者">×</a>').'（'.get_date_c($row['date']).'）
      <span class="li_update_mark" title="更新"></span> '.(!empty($row['other']) ? (strstr((string)$row['other'], '.') ? $row['other'] : '<a href="user.php?get=card&username='.urlencode($row['other']).'" target="_blank" title="'.$row['other'].'
点击查看回复人名片">'.$row['other'].'</a>') : '<span title="'.$row['author_ip'].'">'.$row['author_ip'].'</span>').'（'.get_date_c($row['topdate']).'）

     </div>

</td>
    <td class="li_views_reply">回复/阅览<br />'.$row['reply'].'/'.$row['views'].'</td>
  </tr>
</table>
';






      unset($row, $area_id_root, $area_name);

    }
    @mysql_free_result($result);
    unset($topdate);
    $text .= @get_page_foot($n, $web['pagesize'], $p, '?get=list&area_id='.$_GET['area_id'].'&act='.$_GET['act'].'&keyword='.urlencode($_GET['keyword']).'&p=');

  else :
    $err .= '暂无记录';
  endif;

  $sql['sql_version'] = @mysql_get_server_info();

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

@mysql_close();


?>
<div class="column">
<h5><?php echo $title1; ?></h5>
<?php echo count($arr_area_child) > 0 ? '<div class="column_in"><span class="redword">'.$mark_child.'：</span>'.@implode(' &nbsp; ', $arr_area_child).'</div>' : ''; ?>
</div>
<div class="list_title"><a href="?get=list" class="list_title_in"><?php echo @$power_err.@$search_r.@$out; ?>文章列表<span>（<?php echo $n; ?>）</span></a></div>
<form method="post" id="manageform" action="?post=unity_run&dataname=listdata">
  <div class="manager_menu">
    <iframe id="lastFrame" name="lastFrame" frameborder="0" scrolling="No" style="position:absolute; top:24px; left:0; width:100%; height:320px; display:none; z-index:18;"></iframe>
    <input name="to_id" id="to_id" type="hidden" />
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="120"><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></td>
        <td><button name="act" type="button" onmouseover="setCredit('');" onclick="chk(this.form,this,'edit')"><b>编辑</b></button>
            <button name="act2" type="button" onmouseover="setCredit('');" onclick="if(get_checkbox('id[]')==0){alert('数据为空或尚未点选！');}else{toToid();}"><b>转移</b></button>
          <button name="act2" type="button" onmouseover="setCredit('');" onclick="chk(this.form,this,'top')"><b>置顶</b></button>
          <button name="act2" type="button" onmouseover="setCredit('');" onclick="chk(this.form,this,'ctop')"><b>撤顶</b></button>
          <button name="act2" type="button" onmouseover="setCredit('增加', 1);"><b>推荐</b></button>
          <button name="act2" type="button" onmouseover="setCredit('减掉', 1);"><b>撤荐</b></button>
<button name="act2" type="button" onmouseover="setCredit('增加', 0);" onclick="chk(this.form,this,'ess_index')"><b>首页图文展示（如果文中含图）</b></button>
<button name="act2" type="button" onmouseover="setCredit('');" onclick="chk(this.form,this,'cess_index')"><b>撤消首页图文展示（如果有）</b></button><br />
          <div id="creditV" style="display:none" class="red_err"></div>
          <button name="act2" type="button" onmouseover="setCredit('');" onclick="chk(this.form,this,'ccity')" title="清除归属地，可以被所有地区共享"><b>清除地区</b></button>
          |
          <button name="act2" type="button" onmouseover="setCredit('');" onclick="chk(this.form,this,'del')"><b>删除</b></button>
          <input type="checkbox" class="checkbox" name="delsendmess" id="delsendmess" value="1" />
          同时发信 |
          <input type="text" id="keyword" name="keyword" style="width:120px;" onfocus="if(this.value=='关键词'){this.value=''}" value="<?php echo $keyword ? $_GET['keyword'] : '关键词'; ?>" />
            <button type="button" onclick="if($('keyword').value!='' && $('keyword').value!='关键词'){location.href='?get=list&area_id=<?php echo $_GET['area_id']; ?>&act=search&keyword='+$('keyword').value+'';}"><b>搜索题目</b></button>
<br />


</td>
      </tr>
    </table>
  </div>
  <?php
if (isset($sql['sql_version']) && $sql['sql_version'] < '5.0') {
  echo '<div class="red_err">服务器数据库版本（'.$mysql_v.'）太低！数据可能显示不正常。本程序建设基于MySQL版本5.0以上</div>';
}

echo $text, $err;
?>
  <input type="hidden" name="limit" />
</form>
