<?
$sub_menu = "400200";
include_once("./_common.php");

auth_check($auth[$sub_menu], "r");

$token		= get_token();
$sql_where	= "where 1";

$now		= date("Y-m-d H:i:s", $g4[server_time]);
if($sfl == "id")	{ $sql_where .= " and db_block_id='$stx'"; }
if($sfl == "block")	{ $sql_where .= " and db_block_end>='$now'"; }

$sql	= "select count(*) as cnt from $zmb[table_blacklist_mem] $sql_where";
$row	= sql_fetch($sql);
$total_count = $row[cnt];

$rows	= $config[cf_page_rows];
$total_page  = ceil($total_count / $rows);		// 전체 페이지 계산
if ($page == "") { $page = 1; }					// 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows;				// 시작 열을 구함

$sql	= "select * from $zmb[table_blacklist_mem] $sql_where limit $from_record, $rows";
$result = sql_query($sql);


$g4[title] = "블랙리스트";
include_once("./admin.head.php");

$colspan = 6;
?>
<style>
.tbl_box	{ border:1px solid #CBCBCB; border-top:2px solid #989898; }
.tbl_box tr th	{ background:#F7F7F7; height:30px; border-right:1px solid #EFEFEF; border-bottom:1px solid #EFEFEF; }
.tbl_box tr th:last-child	{ border-right:0; }
.tbl_box tr td	{ padding:6px; border-right:1px solid #EFEFEF; border-bottom:1px solid #EFEFEF; }
.tbl_box tr td:last-child	{ border-right:0; }
.tbl_box tr:last-child td	{ border-bottom:0; }
div.msg		{ font:normal 11px Dotum; padding:4px; }
span.rept	{ font:normal 11px Dotum; }
span.rept a	{ color:#359C0C; margin:0 10px 0 10px; }
span.rept a:hover	{ text-decoration:underline; }
span.member:hover	{ text-decoration:underline; }
</style>

<?=subtitle($g4[title])?>
<div class="subtitle_msg">신고가 많은 회원과 블럭 처리 할 회원을 관리 합니다.</div>

<table width=100% cellpadding=2 cellspacing=1 border=0>
<form name=fsearch method=get>
<tr>
    <td width=40% align=left><span class="rept">블랙리스트 : <?=number_format($total_count)?>명</span> <span class="rept"><a href="?sfl=block">차단된 회원만 보기▼</a> <a href="?">모두 보기▼</a></span></td>
	<td width=>	</td>
    <td width=30% align=right>
        <select name=sfl>
            <option value='id'>아이디</option>
        </select>
        <input type=text name=stx required itemname='검색어' value='<?=$stx?>'>
        <input type=submit value="검색" class="bttn_search"></td>
</tr>
</form>
</table>

<form name=fboardlist method=post>
<input type="hidden" name="mode" value="bl_update">
<table width=100% cellpadding=0 cellspacing= border=0 class="tbl_box">
<colgroup width=30>
<colgroup width=20%>
<colgroup width=20%>
<colgroup width=20%>
<colgroup width=20%>
<colgroup width=>
<tr>
    <th><input type=checkbox name=chkall value="1" onclick="check_all(this.form)"></th>
    <th><?=subject_sort_link("bo_table")?>닉네임</a></th>
	<th>누적신고 수</th>
    <th>차단 마감일 (영구차단)</th>
	<th>이용제한 서비스</th>
    <th></th>
</tr>
<?	$i	= 0;
	while($rd = sql_fetch_array($result)) : 
	$mb		= get_member($rd[db_block_id]);
	$nick	= get_sideview($rd[db_block_id], $mb[mb_nick], $mb[mb_email], $mb[mb_homepage]);
	if(!$rd[db_block_id])	$nick	="<span class='txtsmall'>(탈퇴회원)</span>";
	$tmp	= explode("/", $rd[db_block_service]);
	if($tmp[0]) $service_write = "checked"; else $service_write = "";
	if($tmp[1]) $service_memo = "checked"; else $service_memo = "";
	if($rd[db_flag] == "1") $forever_block = "checked"; else $forever_block = "";
?>
<tr class='list<?=$list?> col1 ht center' onMouseOver="this.style.backgroundColor='#F6F8FA'" onMouseOut="this.style.backgroundColor=''">
    <td height=25><input type=checkbox name=chk[] value="<?=$rd[db_recno]?>"></td>
	<td><?=$nick?> <?=$rd[db_block_id]?></td>
    <td><input size=4 name="in_report_cnt[<?=$rd[db_recno]?>]" value="<?=$rd[db_report_count]?>"> (숫자만)</td>
	<td><input name="in_block_end[<?=$rd[db_recno]?>]" value="<?=$rd[db_block_end]?>" title="날짜 형식을 지켜주세요. <?=date("Y-m-d H:i:s")?>"> (<input type="checkbox" name="in_flag[<?=$rd[db_recno]?>]" <?=$forever_block?> value="1" onClick="chkAlert(this, 'f', '<?=$i?>');">)</td>
    <td><input type="checkbox" name="in_write[<?=$rd[db_recno]?>]" <?=$service_write?> value="1" onClick="chkAlert(this, 'w', '<?=$i?>');">글쓰기, 
	<input type="checkbox" name="in_memo[<?=$rd[db_recno]?>]" <?=$service_memo?> value="1" onClick="chkAlert(this, 'm', '<?=$i?>');">쪽지발송</td>
    <td><input type="button" value="삭제" class="bttn_common" onClick="if(confirm('회원을 블랙리스트에서 제외 할까요?')) zm_gourl('./zm.report_process.php?mode=bl_delete&recno=<?=$rd[db_recno]?>');"></td>
</tr>
<?	$i++;
	endwhile; ?>
 
<?
if ($i == 0)
    echo "<tr><td colspan='$colspan' align=center height=100 bgcolor=#ffffff>자료가 없습니다.</td></tr>"; 
?>
	</table>
<?
$pagelist = get_paging($config[cf_write_pages], $page, $total_page, "$_SERVER[PHP_SELF]?$qstr&page=");
?>
<div class="msg">※ 목록에 있어도 차단 마감일이 오늘보다 크고 이용제한 서비스에 체크 된 항목이 있어야 서비스 제한을 받습니다.</div>
	<table width=100% cellpadding=3 cellspacing=1>
	<tr><td width=50%>
		<input type=button class='bttn_common' value='수정적용' onClick="btn_chk(this.form, 'bl_update')">
<?
if ($is_admin == "super")
    echo "<input type=button class='bttn_common' value='선택삭제' onclick=\"btn_chk(this.form, 'bl_delete_all')\">";
?>
		</td>
		<td align=right><?=$pagelist?></td></tr></table>
<?
if ($stx)
    echo "<script>document.fsearch.sfl.value = '$sfl';</script>";
?>
</form>
<script language="javascript">
function btn_chk(f, m) {
	var chk = document.getElementsByName("chk[]");

	f.mode.value = m;
	
	var sw = 0;
	for(i=0; i<chk.length; i++) {
		if(chk[i].checked) sw = 1;
	}
	if(!sw) { alert("선택 된 리스트가 없습니다."); return false; }

	f.action	= "./zm.report_process.php";
	f.submit();
}

function chkAlert(th, d, idx) {
	var	s = "";
	var fi = document.getElementsByName("chk[]");

	if(d == "w") s = "글쓰기";
	if(d == "m") s = "쪽지발송";
	if(d == "f") s = "영구히";
	if(th.checked) {
		alert(s+" 서비스를 제한 합니다.");
		fi[idx].checked	= true;
	}
}

</script>

<?
include_once("./admin.tail.php");
?>
