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

/* 管理成员 */
/* 162100源码 - 162100.com */

$_GET['order'] = @$_GET['order'];
if ($_GET['order'] != 'username' && $_GET['order'] != 'id' && $_GET['order'] != 'point' && $_GET['order'] != 'writecount') {
  $_GET['order'] = 'id';
}
$_GET['username'] = @$_GET['username'];
if ($_GET['username']) {
  $_GET['username'] = strtolower(trim($_GET['username']));
  if (preg_match('/^([^\x00-\x7f]|\w|\.){3,45}$/', $_GET['username'])) {
    $_GET['username'] = str_replace('.', '&#46;', $_GET['username']);
    $eval = ' (username LIKE "%'.$_GET['username'].'%") AND'; //走索引的话 (username LIKE "'.$_GET['username'].'%") AND
    $search_r = '搜索结果 - ';
  } elseif (preg_match('/^[\w\.\-]+@[\w\.\-]+\.[\w\.]+$/', $_GET['username'])) {
    $eval = ' (email LIKE "%'.$_GET['username'].'%") AND'; //走索引的话 (email LIKE "'.$_GET['username'].'%") AND
    $search_r = '搜索结果 - ';
  } else {
    $search_r = '<span class=\"red\">用户名|邮箱名不合法</span> | ';
  }
}

$text = $err = '';
function getPower($v, $u) {
  global $web;
  if ($v == '') {
    return '普通用户';
  } else {
    if ($v == 'm') {
      return '<span class="redword">'.($u == $web['manager'] ? '基础' : '').'管理员</span>';
    } elseif (preg_match('/(\(\d+\-\d+\))+/', $v)) {
      return '<span class="redword">版主,负责版区'.$v.'</span>';
    } elseif (strstr($v.'_', 'a')) {
      return '限制所有';
    } else {
	  if (strstr($v.'_', 't')) {
        $text .= '限制发表主题 ';
      }
	  if (strstr($v.'_', 'r')) {
        $text .= '限制发表评论回复 ';
      }
	  if (strstr($v.'_','u')) {
        $text .= '限制上传 ';
      }
      return $text;
	}
  }
}


$n = 0;

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

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

  $result = @mysql_query('SELECT COUNT(id) AS total FROM '.$sql['pref'].''.$sql['data']['承载成员档案的表名'].' WHERE'.$eval.' check_reg="0"', $db);
  $row = @mysql_fetch_assoc($result);
  $n = $row['total'];
  @mysql_free_result($result);
  unset($row);

  require ('inc/function/get_page.php');
  if ($n > 0) :
    $p = get_page($n); //页数
    $seek = $web['pagesize'] * ($p-1);
    $result = @mysql_query('SELECT * FROM '.$sql['pref'].''.$sql['data']['承载成员档案的表名'].' WHERE'.$eval.' check_reg="0" ORDER BY '.$_GET['order'].' DESC LIMIT '.$seek.','.$web['pagesize'].'', $db);

    require ('inc/set/set_userface.php');

    $text .= '
<div class="list_title_">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th>用户名 <select name="order" id="order" style="height:auto;" onchange="location.href=\'?p='.$p.'&get=member&username='.urlencode($_GET['username']).'&order=\'+this.value+\'\';">
    <option value="id"'.($_GET['order'] == 'id' ? ' selected="selected"' : '').'>按注册时间查看</option>
    <option value="username"'.($_GET['order'] == 'username' ? ' selected="selected"' : '').'>按帐户名查看</option>
    <option value="point"'.($_GET['order'] == 'point' ? ' selected="selected"' : '').'>按积分查看</option>
    <option value="writecount"'.($_GET['order'] == 'writecount' ? ' selected="selected"' : '').'>按发表数量查看</option>
  </select></th>
      <th width="220">积分/权限</th>
      <th width="220">详细</th>
    </tr>
  </table>
</div>
';
    while ($row = @mysql_fetch_assoc($result)) {
      $text .= '
  <div class="li">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="20"><input name="id[]" id="id[]" type="checkbox" class="checkbox" value="'.$row['username'].'" /></td>
    <td style="text-align:left;"><span class="iface_s"><img src="obj.php?title=face-'.urlencode($row['username']).'.'.$web['img_up_format'].'" width="'.$web['img_w_s'].'" height="'.$web['img_h_s'].'" /></span><br />
    '.$row['username'].'
    </td>
    <td width="220" style="text-align:left;">
    权限:'.getPower($row['power'], $row['username']).'<br />
    邮箱:'.$row['email'].'<br />
    等级分:'.$row['point'].'<br />
    </td>
    <td width="220" style="text-align:left;">
    文章|回复:'.($row['writecount'] > 0 ? '<a href="user.php?get=list&username='.urlencode($row['username']).'" target="_blank">'.$row['writecount'].'</a>' : 0).'|'.($row['replycount'] > 0 ? '<a href="user.php?get=reply&username='.urlencode($row['username']).'" target="_blank">'.$row['replycount'].'</a>' : 0).'<br />
    <div id="funds_credit_'.$row['username'].'"><a href="inc/require/z_other_getmember.php?username='.urlencode($row['username']).'" target="lastFrame">更多…</a></div>
    <div id="other_'.$row['username'].'" style="display:none">
    密码问题:'.$row['password_question'].'<br />
    密码答案:'.$row['password_answer'].'<br />
    注册日期:'.$row['regdate'].'<br />
    最后访问:'.$row['thisdate'].'</div>
    </td>
    </tr>
    </table>
  </div>';
    }
    @mysql_free_result($result);

    $text .= get_page_foot($n, $web['pagesize'], $p, '?get=member&username='.urlencode($_GET['username']).'&order='.$_GET['order'].'&p=');


  else :
    $err .= '没有记录！或已被删除。';
  endif;

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

@mysql_close();

?>
  <iframe id="lastFrame" name="lastFrame" frameborder="0" style="display:none"></iframe>
  <div class="list_title"><a href="?get=member" class="list_title_in"><?php echo @$search_r; ?>成员列表<span>（<?php echo @$n; ?>）</span></a><a href="?get=member_userface">成员头像管理</a><a href="?get=member_company">商号管理</a></div>
  <form method="post" id="manageform" action="?post=unity_run&dataname=member" onsubmit="if(get_checkbox('id[]')==0){alert ('请点选！');return false;}">
    <div class="manager_menu">
      <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><input name="username" id="usernamebox" type="text" value="<?php echo $_GET['username']; ?>" size="20" />
    <button type="button" onclick="location.href='?get=member&username='+encodeURIComponent($('usernamebox').value)+''"><b>搜索会员|邮箱</b></button> 如果搜索不到，请到<a href="?get=member_check_reg&act=punished">黑名单</a>或<a href="?get=member_check_reg">待审核注册用户</a>中查询<br />
<button name="act" type="button" onclick="chk(this.form,this,'r')"><b>限制评论</b></button>
              <button name="act" type="button" onclick="chk(this.form,this,'rr')"><b>取消限制评论</b></button>
            |
            <button name="act" type="button" onclick="chk(this.form,this,'t')"><b>限制发表</b></button>
            <button name="act" type="button" onclick="chk(this.form,this,'tt')"><b>取消限制发表</b></button>
            <br />
              <button name="act" type="button" onclick="chk(this.form,this,'u')"><b>限制上传</b></button>
            <button name="act" type="button" onclick="chk(this.form,this,'uu')"><b>取消限制上传</b></button>
            |
            <button name="act" type="button" onclick="chk(this.form,this,'a')"><b>限制所有</b></button>
            <button name="act" type="button" onclick="chk(this.form,this,'aa')"><b>取消限制所有</b></button>
            <br />
              <button name="act" type="button" onclick="chk(this.form,this,'addadmin')"><b>设为管理员</b></button>
            <button name="act" type="button" onclick="chk(this.form,this,'deladmin')"><b>取消管理员</b></button>
            |
            <button name="act" type="button" onclick="location.href='?get=bulk_mail'"><b>群发邮件</b></button>
            |
            <button name="act" type="button" onclick="chk(this.form,this,'delface')"><b>删除头像</b></button>
            |
            <button name="act" type="button" onclick="if(this.form.del_1.value==''){alert('请填离线时间（不活跃的天数）！')}else{if(confirm('确定执行么？！')){addSubmitSafe();location.href='?post=unity_run&dataname=member&limit=del_&id[]=1&del_1='+$('del_1').value+'';}}"><b>一键清除零发言帐户</b></button>
            离线大于<input name="del_1" id="del_1" onkeyup="isDigit(this,30,0)" type="text" size="3" />天
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="7%" rowspan="2"><button name="act" type="button" onclick="if(confirm('提示：执行删除这个人发布的文章也将全部被删！')){chk(this.form,this,'del')}"><b>删除</b></button></td>
                <td width="93%"><input type="checkbox" class="checkbox" name="delcomplete" value="1" />
点选彻底删除 | 否则进入黑名单。进入黑名单原因如下：</td>
              </tr>
              <tr>
                <td><input type="checkbox" class="checkbox" name="delcomplete_reason[]" value="更换用户名发表" />
更换用户名发表
<input type="checkbox" class="checkbox" name="delcomplete_reason[]" value="发布重复信息" />
信息重复
<input type="checkbox" class="checkbox" name="delcomplete_reason[]" value="发布劣质信息" />
信息劣质
<input type="checkbox" class="checkbox" name="delcomplete_reason[]" value="邮箱无效" />
邮箱无效；其它原因
<input type="text" name="delcomplete_reason[]" size="8" /></td>
              </tr>
            </table> 
            <button name="act" type="button" onclick="chk(this.form,this,'addfunds')"><b>加赠</b></button>
            <input name="addfunds" onkeyup="isDigit(this,1,0,'.')" onfocus="this.form.delfunds.value=''" type="text" size="6" />
            货币值，
            <button name="act" type="button" onclick="chk(this.form,this,'delfunds')"><b>减扣</b></button>
            <input name="delfunds" onkeyup="isDigit(this,1,0,'.')" onfocus="this.form.addfunds.value=''" type="text" size="6" />
            货币值。注：扣减货币值不能大于用户当前货币值<br />
            <button name="act" type="button" onclick="chk(this.form,this,'addpoint')"><b>加赠</b></button>
            <input name="addpoint" onkeyup="isDigit(this,1)" onfocus="this.form.delpoint.value=''" type="text" size="6" />
            等级分，
            <button name="act" type="button" onclick="chk(this.form,this,'delpoint')"><b>减扣</b></button>
            <input name="delpoint" onkeyup="isDigit(this,1)" onfocus="this.form.addpoint.value=''" type="text" size="6" />
            等级分。注：扣减等级分不能大于用户当前等级分<br />
            <button name="act" type="button" onclick="chk(this.form,this,'addcredit')"><b>加赠</b></button>
            <input name="addcredit" onkeyup="isDigit(this,1,0,'.')" onfocus="this.form.delcredit.value=''" type="text" size="6" />
            信誉值，
            <button name="act" type="button" onclick="chk(this.form,this,'delcredit')"><b>减扣</b></button>
            <input name="delcredit" onkeyup="isDigit(this,1,0,'.')" onfocus="this.form.addcredit.value=''" type="text" size="6" />
            信誉值。注：扣减信誉值不能大于用户当前信誉值</td>
        </tr>
      </table>
    </div>
    <?php
echo $text, $err;
?>
    <input type="hidden" name="limit" />
  </form>
  