<?php 
require_once dirname(__FILE__)."/".'global.php';
require_once WEBROOT.'include/function.php';

$iid = htmlspecialchars(var_request("iid",""),ENT_QUOTES);

$AppErrPages = "http://www.taobao.com/go/chn/tbk_channel/channelcode.php?pid=".$userpid."&eventid=101329";

if(!empty($iid)){
	
		$Taoapi->method = 'taobao.taobaoke.items.convert';
		$Taoapi->fields = 'num_iid,click_url,shop_click_url';
		$Taoapi->pid = $userpiddp;
		$Taoapi->num_iids = $iid;
		$TaoapiClickItem = $Taoapi->Send('get','xml')->getArrayData();
	$click_url = $TaoapiClickItem["taobaoke_items"]["taobaoke_item"]["click_url"];
	$shop_click_url = $TaoapiClickItem["taobaoke_items"]["taobaoke_item"]["shop_click_url"];

	if(empty($click_url)){
		header("location:".$AppErrPages);
		exit;
	}else{
		header("location:".$click_url);
		exit;
	}
}

$url = base64_decode($_GET["url"]);
if(empty($url)){
	header("location:".$AppErrPages);
	exit;
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>正在指向，请稍等</title>
</head>

<body>
<a href="<?php echo $url;?>" id="goto">   </a>

<script type="text/javascript"> 
	function invokeClick(element) {
		if(element.click)element.click();
		else if(element.fireEvent)element.fireEvent('onclick');
		else if(document.createEvent){
		var evt = document.createEvent("MouseEvents");
		evt.initEvent("click", true, true);
		element.dispatchEvent(evt);
		}
	}
	try{
		document.getElementById("goto").click();
	}catch(e){
		try{
			invokeClick(document.getElementById("goto"));
		}catch(x){
			location.href="<?php echo $url;?>";
		}
	}
</script>
</body>
</html>
