<?
include_once("./_common.php");
extract($_GET);

//-- 공유할 기본 정보 불러오기
$tablename	= $g4[write_prefix] . $bo_table;
$sql	= "select * from $tablename where wr_id='$wr_id'";
$rd	= sql_fetch($sql);

//-- 썸네일 정보
$tableboard	= $g4[board_file_table];
$sql		= "select * from $tableboard where bo_table='$bo_table' and wr_id='$wr_id' order by bf_no asc limit 1";
$rdimg	= sql_fetch($sql);
if($rdimg[bf_type] > 0) {
	$thumb	= $g4[url]."/data/file/".$bo_table."/thumb/".$rdimg[bf_file];
}

$title		= str_replace(array("\r", "\n"), "", $rd[wr_subject]);
//-- 태그 제거
$rd[wr_content]	= strip_tags($rd[wr_content]);
$desc	= cut_str(str_replace(array("\r", "\n"), "", $rd[wr_content]), 200);
?>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<? //-- Facebook 공유를 위한 메타 태그 ?>
<meta property='og:image' content='<?=$thumb?>'>
<meta property="og:title" content="<?=$title?>">
<meta property="og:description" content="<?=$desc?>">
<meta property="og:site_name" content="<?=$config[cf_title]?>">

</head>
<body>
<?
$long_url	= $g4[url] . "/bbs/board.php?bo_table=".$bo_table."&wr_id=".$wr_id;
$sns_url	= $g4[url] . $_SERVER[PHP_SELF] . "?bo_table=".$bo_table."&wr_id=".$wr_id;


if($sns == "fb") {
	$api_url		= "https://www.facebook.com/sharer/sharer.php?u=". urlencode($sns_url);
	zm_gourl($api_url);
	exit;
}

if($sns == "tw") {
	//$surl	= naver_short_url(urlencode($long_url));
	$txt	= urlencode($title);
	$api_url	= "https://twitter.com/intent/tweet?text=".urlencode($sns_url) . " " . $txt;
	zm_gourl($api_url);
}

//-- $sns 값이 없으면 SNS에서 연결 된 것으로 간주하고 해당 페이지로 이동
if($sns == "") {
	zm_gourl("$long_url");
}
?>
</body>
</html>