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

$g5['title'] = $g4['title'] = '내글 반응';

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

include_once(G5_PATH.'/_head.php');

$flag_query = $flag ? "and re_flag = '".$flag."'" : "";

switch($read) {
	case 'y' : $chk_query = "and re_chk = '1'"; break;
	case 'n' : $chk_query = "and re_chk = '0'"; break;
	default	 : $chk_query = ""; break;
}

switch($type) {
	case 'w' : $type_query = "and re_type = '0'"; break;
	case 'c' : $type_query = "and re_type = '1'"; break;
	default	 : $type_query = ""; break;
}

if(AMINA) {
	$page_rows = G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'];
} else {
	$page_rows = $config['cf_write_pages'];
}

$sql_common = " from {$g5['amina_response']} where mb_id = '{$member['mb_id']}' $chk_query $flag_query $type_query";
$sql_order = " order by re_chk, re_datetime desc ";
$sql = " select count(*) as cnt $sql_common ";
$row = sql_fetch($sql);
$total_count = $row['cnt'];
$rows = $config['cf_page_rows'];
$total_page  = ceil($total_count / $rows);
if (!$page || $page > $total_page) $page = 1;
$from_record = ($page - 1) * $rows;

$pagelist = get_paging($page_rows, $page, $total_page, "?read={$read}&flag={$flag}&type={$type}{$frame_opt}&page=");

$res = sql_query(" select * $sql_common $sql_order limit $from_record, $rows ");
$list = array();
$i = 0;
while($row = sql_fetch_array($res)) {
  $list[$i] = $row;
  $i++;
}

$skin_val = $aminaThema['response_skin'];
$skin_dir = 'misc/response';
$skin_name = 'response.skin.php';
$action = 'response';

if(file_exists(THEMA_PATH.'/skin/'.$skin_name)) {
	$response_skin_path = THEMA_PATH.'/skin';
	$response_skin_url = THEMA_URL.'/skin';
} else if(file_exists(AMINA_PATH.'/'.$skin_dir.'/'.$skin_val.'/'.$skin_name)) {
	$response_skin_path = AMINA_PATH.'/'.$skin_dir.'/'.$skin_val;
	$response_skin_url = AMINA_URL.'/'.$skin_dir.'/'.$skin_val;
} else {
	$response_skin_path = AMINA_PATH.'/'.$skin_dir.'/basic';
	$response_skin_url = AMINA_URL.'/'.$skin_dir.'/basic';
}

include($response_skin_path.'/'.$skin_name);

include_once(G5_PATH.'/_tail.php');

?>
