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

/* 群发电邮 */
/* 162100源码 - 162100.com */


function getPower($v) {
  if ($v == '') {
    return '普通用户';
  } else {
    if ($v == 'm') {
      return '<span class="redword">管理员</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;
	}
  }
}

$_GET['sort_type'] = @ $_GET['sort_type'];
$_GET['username'] = @ $_GET['username'];
if ($_GET['sort_type'] != 'username' && $_GET['sort_type'] != 'point' && $_GET['sort_type'] != 'writecount' && $_GET['sort_type'] != 'regdate') {
  $_GET['sort_type'] = 'id';
}

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 {
    $eval = '';
    $search_r = '<span class="redword">用户名|邮箱名不合法</span> | ';
  }
}

$text = $err = '';

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 = abs($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['sort_type'].' 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>用户名</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 valign="top"><td style="text-align:left;"><input name="id[]" id="id[]" type="checkbox" class="checkbox" value="'.$row['email'].'" />'.$row['username'].'</td><td width="220" style="text-align:left;">权限:'.getPower($row['power']).'&nbsp;<br />邮箱:'.$row['email'].'&nbsp;</td><td width="220" style="text-align:left;">等级分:'.$row['point'].'&nbsp;<br />注册日期:'.$row['regdate'].'&nbsp;</td></tr></table></div>';
    }
    @mysql_free_result($result);
    $text_page = @ get_page_foot($n, $web['pagesize'], $p, '?get=bulk_mail&username='.urlencode($_GET['username']).'&sort_type='.$_GET['sort_type'].'&p=');

  else :
    $err .= '没有记录！';
  endif;

} else {
  $err .= $sql['db_err'];
}
@mysql_close();


?>
<div class="list_title"><a class="list_title_in">用户列表<span>（<?php echo $n; ?>）</span></a></div>
<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>查看：
                  <select name="sort_type" onchange="location.href='?p=<?php echo $p; ?>&get=bulk_mail&username=<?php echo urlencode($_GET['username']); ?>&sort_type='+this.value+''">
                    <option value="regdate"<?php echo $_GET['sort_type'] == "username" ? ' selected="selected"' : ''; ?>>按注册时间</option>
                    <option value="username"<?php echo $_GET['sort_type'] == "username" ? ' selected="selected"' : ''; ?>>按帐户名</option>
                    <option value="point"<?php echo $_GET['sort_type'] == "point" ? ' selected="selected"' : ''; ?>>按积分</option>
                    <option value="writecount"<?php echo $_GET['sort_type'] == "writecount" ? ' selected="selected"' : ''; ?>>按发表数量</option>
                  </select>
                 |
          <input name="username" id="usernamebox" type="text" value="<?php echo $_GET['username']; ?>" size="20" />
        <button type="button" onclick="location.href='?get=bulk_mail&username='+encodeURIComponent($('usernamebox').value)+''"><b>搜索会员|邮箱</b></button></td>
    </tr>
  </table>
</div>
<?php echo $err; ?>
<iframe id="lastFrame" name="lastFrame" frameborder="0" style="display:none"></iframe>
<script type="text/javascript">
<!--
var liMaxCount = <?php echo $web['mess_wordcount']; ?>;
var eXSize = 588;       //编辑器宽度，最小宽度限588px
var formU = '?post=bulk_mail';
var formT='<?php echo $text; ?><br /><u><b id="a_subject"><span class="redword">*</span> 题　目：</b></u><br /><input class="large" name="subject" id="subject" type="text" value="" style="width:330px" maxlength="180" /><br /><br /><u><b id="a_content"><span class="redword">*</span> 内　容：</b></u><br /><input type="hidden" name="limit" value="bulk_mail" />';
document.write('<'+'sc'+'ript language="javascript" src="inc/js/editor.js?'+new Date().getTime()+'" type="text/javascript"></'+'sc'+'ript>');
-->
</script>
<?php echo $text_page; ?>





