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

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

$token		= get_token();

$sql_where	= "where 1";
if($table && $wrid) $sql_where	.= " and db_table='$table' and db_wrid='$wrid'";

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

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

$sql	= "select * from $zmb[table_blacklist_report] $sql_where order by db_datetime desc, db_table asc, db_wrid desc limit $from_record, $rows";
$result = sql_query($sql);

$g4[title] = "신고목록";
include_once("./admin.head.php");

$colspan = 8;
?>
<style type="text/css">
.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.member:hover	{ text-decoration:underline; }
</style>

<?=subtitle("신고 목록")?>
<div class="subtitle_msg">신고 된 게시글 목록입니다.</div>
<table width=100% cellpadding=0 cellspacing=1 border=0 class="tbl_box">
<colgroup width=10%>
<colgroup width=10%>
<colgroup width=10%>
<colgroup width=7%>
<colgroup width=40%>
<colgroup width=10%>
<colgroup width=18%>
<colgroup width=>
<tr>
    <th>테이블</th>
	<th>글쓴이</th>
	<th>신고자</th>
	<th>글번호</th>
    <th>제목</th>
	<th>신고사유</th>
	<th>신고일</th>
    <th></th>
</tr>
<?
while($rd = sql_fetch_array($result)) : 
	if($g4[memo_table] == $rd[db_table])	$report	= "memo";
	else									$report	= "bbs";
	if($report == "bbs") {
		//-- 게시판 정보
		$bo_table	= $g4[write_prefix] . $rd[db_table];
		$bbsinfo	= sql_fetch("select * from $bo_table where wr_id='$rd[db_wrid]'");
		$write_mb	= get_member($rd[db_block_id]);				//-- 작성자
		$report_mb	= get_member($rd[db_report_id]);			//-- 신고자
	
		$write_nick	= get_sideview($write_mb[mb_id], $write_mb[mb_nick], $write_mb[mb_email], $write_mb[mb_homepage]);
		$report_nick= get_sideview($report_mb[mb_id], $report_mb[mb_nick], $report_mb[mb_email], $report_mb[mb_homepage]);

		if(!$bbsinfo[mb_id])	$write_nick	="<span class='txtsmall'>(비회원)</span>";

		$no_record	= 0;
		if($bbsinfo[wr_is_comment] == "1")	
			$subject = "[코] ".cut_str($bbsinfo[wr_content], 100);
		else if(!$bbsinfo[wr_id]) {
			$subject = "(해당글은 삭제되어 게시글에 대한 정보가 존재 하지 않습니다.)";
			$no_record	= 1;
		} else 
			$subject = $bbsinfo[wr_subject];
	}elseif($report == "memo") {
		//-- 메모 정보
		$memoinfo	= sql_fetch("select * from $g4[memo_table] where me_id='$rd[db_wrid]'");
		$write_mb	= get_member($memoinfo[me_send_mb_id]);			//-- 작성자 정보
		$report_mb	= get_member($memoinfo[me_recv_mb_id]);			//-- 신고자 정보

		$write_nick		= get_sideview($write_mb[mb_id], $write_mb[mb_nick], $write_mb[mb_email], $write_mb[mb_homepage]);

		$no_record	= 0;
		if(!$memoinfo[me_id]) {
			$subject = "(해당글은 삭제되어 게시글에 대한 정보가 존재 하지 않습니다.)";
			$no_record	= 1;
		} else 
			$subject = "[쪽] " . cut_str($memoinfo[me_memo], 100, "");
	}
?>
<tr class='list<?=$list?> col1 ht center' onMouseOver="this.style.backgroundColor='#F6F8FA'" onMouseOut="this.style.backgroundColor=''">
	<td><?=$rd[db_table]?></td>
    <td><?=$write_nick?> <?=$write_mb[mb_id]?></td>
	<td><?=$report_nick?> <?=$report_mb[mb_id]?></td>
	<td><?=$rd[db_wrid]?></td>
	<td align=left><?=$subject?></a></td>
	<td align=left><a title="<?=$rd[db_why_report]?>"><?=cut_str($rd[db_why_report], 20, "")?></a></td>
    <td><?=$rd[db_datetime]?></td>
    <td><span style="width:70px;"><input type="button" value="취소" class="btn1" onClick="if(confirm('신고를 취소 합니다.')) zm_gourl('./zm.report_process.php?mode=report_cancel&recno=<?=$rd[db_recno]?>&write_id=<?=$write_mb[mb_id]?>&table=<?=$rd[db_table]?>&wrid=<?=$rd[db_wrid]?>');"></span>
	</td>
</tr>
<? endwhile; ?>
<?
//-- 테이블 이름
$q	= sql_query("select db_table from $zmb[table_blacklist_report] group by db_table");
$i	= 0;
while($r = sql_fetch_array($q)) { $tablename[$i] = $r[db_table]; $i++; }
?>
<tr align=center>
	<td>
	<select id="table" name="table">
<?	for($i = 0; $i < count($tablename); $i++) :
	if($tablename[$i] == $table) $strsel = "selected"; else $strsel = ""; ?>	
	<option value=<?=$tablename[$i]?> <?=$strsel?>><?=$tablename[$i]?></option>
<?	endfor; ?>
	</select>
	</td>
    <td></td>
	<td></td>
	<td><input id=wrid name=wrid size=4 value=<?=$wrid?>></td>
	<td></td>
	<td></td>
    <td><input type="button" value="신고 글 검색" class="btn1" onClick="search_bbs()"></td>
    <td></td>
</tr>
<? if($table && $wrid) : ?>
<tr><td colspan=<?=$colspan?> align=center><input type='button' value='모두 보기' onClick='zm_gourl("<?=$_SERVER[PHP_SELF]?>")' class=btn1></td></tr>
<? endif; ?>

<?
if ($i == 0)
    echo "<tr><td colspan='$colspan' align=center height=100 bgcolor=#ffffff>자료가 없습니다.</td></tr>"; 
?>
</table>
<?
$qstr	= "&";
foreach($_GET as $key=>$value) { $qstr .= $key . "=" . $value . "&"; }
$pagelist = get_paging($config[cf_write_pages], $page, $total_page, "$_SERVER[PHP_SELF]?$qstr&page=");
?>
	<table width=100% cellpadding=3 cellspacing=1>
	<tr>
		<td align=center><?=$pagelist?></td>
	</tr>
	</table>
<script language="javascript">
function search_bbs() {
	var t	= $("#table").val();
	var r	= $("#wrid").val();
	if(!t || !r) {
		alert("테이블명과 글번호를 입력 해 주세요.");
		return false;
	}
	zm_gourl("./zm.report_listall.php?table="+t+"&wrid="+r);
}
</script>

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