<?php
include_once('./_common.php');

if(!$is_member) {
	alert('로그인해 주세요.', G5_BBS_URL.'/login.php?url='.urlencode('../amina/response.php'));
}

if($act == "delete") {

	sql_query(" delete from {$g5['amina_response']} where id = '{$rid}' and mb_id = '{$member['mb_id']}' ");

	$goto_url = AMINA_URL.'/response.php?read='.$read.'&flag='.$flag.'&type='.$type.'&page='.$page;

} else if($act == "read_all" || $act == "delete_all") {

	if(empty($re_id)) {
		alert('선택한 알림이 없습니다.');
	} else {
		$ids = implode(',', $re_id);
		if($act == "delete_all") {
			sql_query(" delete from {$g5['amina_response']} where id in ( $ids ) and mb_id = '{$member['mb_id']}' ");
		} else {
			sql_query(" update {$g5['amina_response']} set re_chk = '1' where id in ( $ids ) and mb_id = '{$member['mb_id']}' ");
		}
	}

	$goto_url = AMINA_URL.'/response.php?read='.$read.'&flag='.$flag.'&type='.$type.'&page='.$page;

} else {

	$row = sql_fetch(" select * from {$g5['amina_response']} where id = '{$rid}' and mb_id = '{$member['mb_id']}' ");

	if(!$row['id']) alert("값이 잘못 전달되었습니다.");

	if($row['re_chk']) {
		;
	} else {
		sql_query(" update {$g5['amina_response']} set re_chk = '1' where id = '{$rid}' and mb_id = '{$member['mb_id']}' ");
	}

	$goto_url = $row['wr_cmt'] ? G5_BBS_URL.'/board.php?bo_table='.$row['bo_table'].'&wr_id='.$row['wr_id'].'#c_'.$row['wr_cmt'] : G5_BBS_URL.'/board.php?bo_table='.$row['bo_table'].'&wr_id='.$row['wr_id'];

}

goto_url($goto_url);

?>
