<?php header('Cache-Control: no-cache'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<title>China Highlights Media Center</title>
	<style type="text/css">
		html,
		body,
		iframe {
			height: 100%;
			margin: 0;
			overflow: hidden;
			padding: 0;
			width: 100%;
		}

		iframe {
			overflow: auto;
		}
	</style>
</head>

<body>
	<script type="text/javascript">
		function SetReturnValue(s) {
			if (s) {
				window.parent.returnValue = s;
			}
			if (!!this.opener.callBack) {
				this.opener.callBack(s);
			}
			window.parent.close();
		}
		this.opener.callBack = window.opener ? window.opener.CallBack : window.parent.CallBack;
	</script>
	<?php
	$media_site_code = 'ch';
	if (isset($_GET['site_code'])) {
		switch ($_GET['site_code']) {
			case 'cht':
				$media_site_code = 'ch';
				break;
			case 'gm':
				$media_site_code = 'ge';
				break;
			case 'it':
				$media_site_code = 'it';
				break;
			case 'jp':
				$media_site_code = 'jp';
				break;
			case 'ru':
				$media_site_code = 'ru';
				break;
			case 'vac':
				$media_site_code = 'sp';
				break;
			case 'vc':
				$media_site_code = 'fr';
				break;
			case 'ct':
				$media_site_code = 'ct';
				break;
			case 'chinatravel':
				$media_site_code = 'chinatravel';
				break;
			case 'mbj':
				$media_site_code = 'bj';
				break;
			case 'sht':
				$media_site_code = 'sh';
				break;
			case 'yz':
				$media_site_code = 'yz';
				break;
			case 'gl':
				$media_site_code = 'gl';
				break;
			case 'tbt':
				$media_site_code = 'tb';
				break;
			case 'trippest':
				$media_site_code = 'trippest';
			case 'shanghai':
				$media_site_code = 'shanghai';
				break;
			default:
				$media_site_code = 'ch';
		}
	}

	/*

$_SERVER["REMOTE_ADDR"]!=='221.7.151.34' && $_SERVER["REMOTE_ADDR"]!=='221.7.151.43' && $_SERVER["REMOTE_ADDR"]!=='111.59.90.31' && $_SERVER["REMOTE_ADDR"]!=='221.7.151.41' && $_SERVER["REMOTE_ADDR"]!=='116.251.208.170' && $_SERVER["REMOTE_ADDR"]!=='221.7.151.39'

*/
	function is_remote_ip()
	{
		// 电脑使用自动分配 IP，取消外网 IP 限制。
		return false;
		// $ip_list = '';
		// if (isset($_SERVER["REMOTE_ADDR"])) $ip_list = $_SERVER["REMOTE_ADDR"] . ' ';
		// if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) $ip_list .= $_SERVER["HTTP_X_FORWARDED_FOR"];
		// //$ip_list=$_SERVER["REMOTE_ADDR"].' '.$_SERVER["HTTP_X_FORWARDED_FOR"];
		// //print_r($_SERVER);
		// echo '<!--' . $ip_list . '-->';

		// if (
		// 	stripos($ip_list, '202.103.68.34') !== false
		// 	|| stripos($ip_list, '221.7.151.39') !== false
		// 	|| stripos($ip_list, '221.7.151.37') !== false
		// 	|| stripos($ip_list, '221.7.151.41') !== false
		// 	|| stripos($ip_list, '111.59.90.31') !== false
		// 	|| stripos($ip_list, '180.140.114.225') !== false
		// 	|| stripos($ip_list, '116.8.4.34') !== false
		// 	|| stripos($ip_list, '180.140.114.208') !== false
		// 	|| stripos($ip_list, '116.8.4.34') !== false
		// 	|| stripos($ip_list, '::1') !== false //这个也是本地IP
		// ) {
		// 	return false;
		// }
		// return true;
	}

	//CDN分发之后，源站和前端域名不一致在这里修正，否则程序生成的链接是源站的域名
	$base_url = '';
	switch ($_SERVER['SERVER_NAME']) {
		case 'origin-ct.mycht.cn':
			$base_url = 'https://ct.mycht.cn';
			break;
		case 'origin-gm.mycht.cn':
			$base_url = 'https://gm.mycht.cn';
			break;
		case 'origin-cht.mycht.cn':
			$base_url = 'https://cht.mycht.cn';
			break;
		case 'origin-int.mycht.cn':
			$base_url = 'https://int.mycht.cn';
		case 'gh-int.mycht.cn':
			$base_url = 'https://int.mycht.cn';
			break;
		default:
			$base_url = 'https://' . $_SERVER['HTTP_HOST'];
	}

	?>
	<?php
	if (isset($_GET['rwidth'])) {
		$rwidth = 'rwidth=' . $_GET['rwidth'] . '&';
	} else {
		$rwidth = '';
	} ?>
	<?php if (isset($_GET['remote']) || is_remote_ip()) { ?>
		<iframe id="test" frameborder="0" src="https://media-center.mycht.cn/OutputApp/searchpicture.aspx?<?php echo ($rwidth); ?>webcode=<?php echo $media_site_code; ?>&lgc=<?php echo $_GET['site_lgc']; ?>&apptype=translate&uname=ycc&upass=ycc&lmisn=1&WebUrl=<?php echo isset($_GET['WebUrl']) ? $_GET['WebUrl'] : false; ?>&redirecturl=<?php echo $base_url; ?>/media/transitval.php"> </iframe>
	<?php } else { ?>
		<iframe id="test" frameborder="0" src="https://video.chtcdn.com/OutputApp/searchpicture.aspx?<?php echo ($rwidth); ?>webcode=<?php echo $media_site_code; ?>&lgc=<?php echo $_GET['site_lgc']; ?>&apptype=infomation&WebUrl=<?php echo isset($_GET['WebUrl']) ? $_GET['WebUrl'] : false; ?>&redirecturl=<?php echo $base_url; ?>/media/transitval.php"> </iframe>
	<?php } ?>
</body>

</html>
