<?php
require ('authentication_manager.php');
?>
<?php

/* 管理回复 */
/* 162100源码 - 162100.com */


$_GET['act'] = @$_GET['act'];
$text = $err = '';
if ($_GET['act'] == 'check_reply_warning') {
  $where_eval = '2';
  $list_title = '"<a href=\"?get=check_reply\">".$out."待审核回帖记录</a><a class=\"list_title_in\">".$out."审核未通过的回帖记录<span>（".$n."）</span></a>"';
  $run_bar = '"<a href=\"?post=unity_run&dataname=reply&id[]=".$row["id"]."&limit=check_reply&m=1\" class=\"run_bar\" target=\"lastFrame\">过</a><a href=\"?post=unity_run&dataname=reply&id[]=".$row["id"]."&limit=del_check_reply&m=1\" class=\"run_bar\" target=\"lastFrame\">删</a>".(strstr($row["author_ip"], ".") ? "<a href=\"?post=ip&ips=".$row["author_ip"]."&m=1\" class=\"run_bar\" target=\"lastFrame\">屏蔽此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>").""';
} else {
  $where_eval = '1';
  $list_title = '"<a class=\"list_title_in\">".$out."待审核回帖记录<span>（".$n."）</span></a><a href=\"?get=check_reply&act=check_reply_warning\">".$out."审核未通过的回帖记录</a>"';
  $run_bar = '"<a href=\"?post=unity_run&dataname=reply&id[]=".$row["id"]."&limit=check_reply&m=1\" class=\"run_bar\" target=\"lastFrame\">过</a><a href=\"?post=unity_run&dataname=reply&id[]=".$row["id"]."&limit=check_reply_warning&m=1\" class=\"run_bar\" target=\"lastFrame\">否</a><a href=\"?post=unity_run&dataname=reply&id[]=".$row["id"]."&limit=del_check_reply&m=1\" class=\"run_bar\" target=\"lastFrame\">删</a>".(strstr($row["author_ip"], ".") ? "<a href=\"?post=ip&ips=".$row["author_ip"]."&m=1\" class=\"run_bar\" target=\"lastFrame\">屏蔽此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>").""';
}

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[get_arearoot($row["area_id"])].".".$row["r_id"].".1.html' : '"article.php?mode=".$area_mode[get_arearoot($row["area_id"])]."&id=".$row["r_id"]."';

if (POWER == 2 || POWER == 3) {
  $out = '您所辖版区的';
  $key = ','.$sql['pref'].''.$sql['data']['承载主题文章的表名'].' AS B WHERE A.area_check_reply="'.$where_eval.'" AND B.id=A.r_id AND '.get_admin_area_id($session[4]).'';
} else {
  $out = '全部';
  $key = ','.$sql['pref'].''.$sql['data']['承载主题文章的表名'].' AS B WHERE A.area_check_reply="'.$where_eval.'" AND B.id=A.r_id';
}


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

if ($sql['db_err'] == '') {
    $result = @mysql_query('SELECT area_id,area_check_reply,area_index FROM '.$sql['pref'].''.$sql['data']['承载版区分类的表名'].' WHERE area_id REGEXP "^[0-9]+\-[0-9]+$"', $db);
    while ($row = @mysql_fetch_assoc($result)) {
      $area_mode[$row['area_id']] = get_li_mode($row['area_index']);
      unset($row);
    }
    @mysql_free_result($result);

  $result = @mysql_query('SELECT COUNT(A.id) AS total FROM '.$sql['pref'].''.$sql['data']['承载回复评论的表名'].' AS A'.$key.'', $db);
  $row = @mysql_fetch_assoc($result);
  $n = abs($row['total']);
  @mysql_free_result($result);
  unset($row);

  require ('inc/function/get_page.php');
@ require ('inc/function/get_date.php'); //时间
    require ('inc/function/cutstr.php');
  if ($n > 0) :
    $p = get_page($n); //页数
    $seek = $web['pagesize'] * ($p-1);
    //die('SELECT A.* FROM '.$sql['pref'].''.$sql['data']['承载回复评论的表名'].' AS A'.$key.' ORDER BY A.id DESC LIMIT '.$seek.','.$web['pagesize'].'');
    $result = @mysql_query('SELECT A.id,A.r_id,A.text,A.date,A.area_check_reply,B.area_id,B.author_ip,B.title,B.date AS d FROM '.$sql['pref'].''.$sql['data']['承载回复评论的表名'].' AS A'.$key.' ORDER BY A.id DESC LIMIT '.$seek.','.$web['pagesize'].'', $db);
    while ($row = @mysql_fetch_assoc($result)) {
        $text .= '
<table width="100%" class="li" id="reply_'.$row['id'].'" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="20"><input name="id[]" id="id[]" type="checkbox" class="checkbox" value="'.$row['id'].'" /></td>
    <td>

      <div><span class="column_">于'.$row['author_ip'].' '.$row['d'].'发表的主题<a href="'.eval('return '.$article_url.'";').'" target="_blank"><b>《'.$row['title'].'》</b></a>中</span></div>
      <div class="text">'.cutstr($row['text'], 450).'</div>
     <div class="li_">
    <span class="li_update_mark" title="更新"></span> '.(strstr((string)$row['author_ip'], '.') ? '<span title="匿名用户">'.$row['author_ip'].'</span>' : '<a href="user.php?get=card&username='.urlencode($row['author_ip']).'" target="_blank" title="点击查看发布人名片"><img src="inc/images/card.gif" />'.$row['author_ip'].'</a>').'（'.get_date_c($row['date']).'）
     '.eval('return '.$run_bar.';').' 
    <a href="'.eval('return '.$article_url.'&reply_id='.$row['id'].'#reply_'.$row['id'].'";').'" target="_blank">查看回复详情&raquo;</a>
     </div>

    </td>
  </tr>
</table>
';

      unset($row);
    }
    @mysql_free_result($result);

    $text .= get_page_foot($n, $web['pagesize'], $p, '?get=check_reply&act='.$_GET['act'].'&p=');


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

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

@mysql_close();


?>
<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; }
.li .column_ { border-bottom:1px #999966 solid; }
-->
</style>
<iframe id="lastFrame" name="lastFrame" frameborder="0" marginheight="0" marginwidth="0" style="display:none;"></iframe>
<div class="list_title"><?php echo eval('return '.$list_title.';'); ?></div>
<form method="post" id="manageform" action="?post=unity_run&dataname=reply">
  <div class="manager_menu"> <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="chk(this.form,this,'check_reply')"><b>审核通过</b></button>
    <?php echo $_GET['act'] == 'check_reply_warning' ? '' : '
      <button type="button" name="act2" onclick="chk(this.form,this,\'check_reply_warning\')"><b>审核不通过</b></button>'; ?> |
    <button type="button" name="act2" onclick="chk(this.form,this,'del_check_reply')"><b>删除</b></button>
    <input type="checkbox" class="checkbox" name="delsendmess" id="delsendmess" value="1" />
    同时发信 </div>
  <?php
echo $text, $err;
?>
  <input type="hidden" name="limit" />
</form>
