<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

//-------------------------------------------------------------------------------------
// Load AMINA SKIN 3.x - Copyright (c) 2012 AMINA - http://amina.co.kr
//-------------------------------------------------------------------------------------

//AMINA Skin Version
$amina_skin_version = 'v3.2.9';

//Load AMINA SKIN Setting
$xp = array();
$amina = array();
$g4_m = array();

if(defined('G4_PATH')) {
	define('AMINA', 'g4s');
	$g4['path'] = G4_PATH;
	$g4['url'] = G4_URL;
	$g4['bbs'] = G4_BBS_DIR;
	$g4['bbs_path'] = G4_BBS_PATH;
	$g4['bbs_url'] = G4_BBS_URL;
	$g4['img_url'] = G4_IMG_URL;
	$g4['admin'] = G4_ADMIN_DIR;
	$g4['admin_path'] = G4_ADMIN_PATH;
	$g4['admin_url'] = G4_ADMIN_URL;
	$g4['server_time'] = G4_SERVER_TIME;
	$g4['time_ymd'] = G4_TIME_YMD;
	$g4['time_his'] = G4_TIME_HIS;
	$g4['time_ymdhis'] = G4_TIME_YMDHIS;
	$g4['table_prefix'] = G4_TABLE_PREFIX;
	$g4['cookie_domain'] = G4_COOKIE_DOMAIN;
	$g4['link_count'] = G4_LINK_COUNT;
	$g4['charset'] = 'utf-8';
	$g4['token_time'] = 3;
	$g4['https_url'] = G4_HTTPS_DOMAIN;
	$g4['table_prefix'] = G4_TABLE_PREFIX;
} else {
	define('AMINA', 'g4');
	define('G4_PATH', $g4['path']);
	include_once(G4_PATH.'/amina/define.php');
	if(G4_CSS_BUFFER) ob_start();
}

// AMINA DB Table
$g4['amina'] = G4_TABLE_PREFIX.'amina';
$g4['amina_skin'] = G4_TABLE_PREFIX.'amina_skin';
$g4['amina_star'] = G4_TABLE_PREFIX.'amina_star';
$g4['amina_blind'] = G4_TABLE_PREFIX.'amina_blind';
$g4['amina_point'] = G4_TABLE_PREFIX.'amina_point';
$g4['amina_cache'] = G4_TABLE_PREFIX.'amina_cache';
$g4['amina_tag'] = G4_TABLE_PREFIX.'amina_tag';
$g4['amina_taglog'] = G4_TABLE_PREFIX.'amina_taglog';
$g4['amina_poll'] = G4_TABLE_PREFIX.'amina_poll';
$g4['amina_polllog'] = G4_TABLE_PREFIX.'amina_polllog';
$g4['amina_file'] = G4_TABLE_PREFIX.'amina_file';
$g4['amina_mileage'] = G4_TABLE_PREFIX.'amina_mileage';

//AMINA Path & URL
define('AMINA_PATH', G4_PATH.'/amina');
define('AMINA_URL', G4_URL.'/amina');

if(G4_DOMAIN || G4_URL) {
	$chk_host = G4_DOMAIN ? parse_url(G4_DOMAIN) : parse_url(G4_URL);
	define('AMINA_HOST', $chk_host['host']);
} else {
	define('AMINA_HOST', $_SERVER['HTTP_HOST']);
}

//Load AMINA Common Function
include_once(AMINA_PATH.'/lib/common.lib.php');

//B4 Thumbnail
include_once(AMINA_PATH.'/lib/thumb.lib.php');

//AMINA SKIN 3.x Extra Settings
include_once(G4_PATH.'/amina.skin.php');

//Chage XP
if($xp['xp_use']) {
	$member['mb_9'] = (int)$member['mb_9'];
	$member['mb_10'] = (int)$member['mb_10'];
}

//Check g4
if(AMINA != "g4s") {
	$is_mobile = false;
	if($g4_m['use']) {
		if($bo_table && ($group['gr_10'] == 'pc' || $board['bo_10'] == 'pc')) {
			;
		} else {
			if ($_REQUEST['device']=='pc') {
			    $is_mobile = false;
			} else if ($_REQUEST['device']=='mobile') {
			    $is_mobile = true;
			} else if (isset($_SESSION['ss_is_mobile'])) {
			    $is_mobile = $_SESSION['ss_is_mobile'];
			} else if (amina_mobile()) {
			    $is_mobile = true;
			}
		}

		$_SESSION['ss_is_mobile'] = $is_mobile;
	}

	define('G4_IS_MOBILE', $is_mobile);

	if (G4_IS_MOBILE) {
		define('G4_MOBILE_DIR', '');
		define('G4_MOBILE_URL', G4_URL);
		define('G4_MOBILE_PATH', G4_PATH);
		$g4['mobile_path'] = G4_MOBILE_PATH;
		$board['bo_skin'] = ($board['bo_10'] == "mobile") ? 'amina-v3' : $board['bo_skin'];
		$config['cf_new_skin'] = $g4_m['new_skin'];
		$config['cf_member_skin'] = $g4_m['member_skin'];
	    $config['cf_search_skin'] = $g4_m['search_skin'];
	    $config['cf_connect_skin'] = $g4_m['connect_skin'];
	} 

	$board_skin_path = G4_SKIN_PATH.'/board/'.$board['bo_skin'];
	$board_skin_url = G4_SKIN_URL.'/board/'.$board['bo_skin'];
	$is_amina = is_amina($board['bo_skin']);
	
	//API Key
	$config['cf_googl_shorturl_apikey'] = $amina['googl_key'];
	$config['cf_facebook_appid'] = $amina['facebook_appid'];
	$config['cf_facebook_secret'] = $amina['facebook_secret'];
	$config['cf_twitter_key'] = $amina['twitter_key'];
	$config['cf_twitter_secret'] = $amina['twitter_secret'];
	$config['cf_me2day_key'] = $amina['me2day_key'];

} else {
	$is_amina = G4_IS_MOBILE ? is_amina($board['bo_mobile_skin']) : is_amina($board['bo_skin']);
}

//Check AMINA SKIN
define('IS_AMINA', $is_amina);

//Thema Path & URL
$thema = G4_IS_MOBILE ? $m_thema : $thema;
define('THEMA_PATH', AMINA_PATH.'/thema/'.$thema);
define('THEMA_URL', AMINA_URL.'/thema/'.$thema);

//Movie Type
define('AMINA_VIDEO', 'http:\/\/(youtu\.be|www\.youtube\.com|vimeo\.com|tvpot\.daum\.net|www\.ted\.com|channel\.pandora\.tv|pann\.nate\.com|www\.tagstory\.com|www\.dailymotion\.com)');

//Load AMINA SETTING
if(IS_AMINA) {
	$amina = load_amina_setting($amina, $bo_table, $board['bo_skin'], $board['bo_mobile_skin'], $sca);

	//AMINA Skin Path & URL
	$emo_skin_path = AMINA_PATH.'/skin/emo/'.$amina['emo_skin'];
	$emo_skin_url = AMINA_URL.'/skin/emo/'.$amina['emo_skin'];
	$cmt_skin_path = AMINA_PATH.'/skin/cmt/'.$amina['cmt_skin'];
	$cmt_skin_url = AMINA_URL.'/skin/cmt/'.$amina['cmt_skin'];
	$view_skin_path = AMINA_PATH.'/skin/view/'.$amina['view_skin'];
	$view_skin_url = AMINA_URL.'/skin/view/'.$amina['view_skin'];
	$write_skin_path = AMINA_PATH.'/skin/write/'.$amina['write_skin'];
	$write_skin_url = AMINA_URL.'/skin/write/'.$amina['write_skin'];

	//Use SNS
	$board['bo_use_sns'] = (AMINA == 'g4s') ? $board['bo_use_sns'] : $amina['auto_sns'];

	//Link Option
	$frame_opt = '';
	if($frame) {
		$frame_opt .= '&frame='.$frame;
		$qstr .= '&frame='.$frame;
	}

	if($bo_it) {
		$frame_opt .= '&bo_it='.$bo_it;
		$qstr .= '&bo_it='.$bo_it;
	}

	if($bo_linked) {
		$frame_opt .= '&bo_linked='.$bo_linked;
		$qstr .= '&bo_linked='.$bo_linked;
	}

	if($bo_row) {
		$frame_opt .= '&bo_row='.$bo_row;
		$qstr .= '&bo_row='.$bo_row;
	}

	if($view_it) {
		$frame_opt .= '&view_it='.$view_it;
		$qstr .= '&view_it='.$view_it;
	}
}

//크로스도메인 관련 jQuery 오류 해결..
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Max-Age: 1000');
if(array_key_exists('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', $_SERVER)) {
    header('Access-Control-Allow-Headers: '
           . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
} else {
    header('Access-Control-Allow-Headers: *');
}
 
if("OPTIonS" == $_SERVER['REQUEST_METHOD']) {
    exit(0);
}

?>