<?php

/*
*	Copyright VeryIDE,2007-2010
*	http://www.veryide.com/
*
*	$Id: index.php,v2 10:10 2009-7-28 Leilei $
*/

/**********/


//载入全局配置和函数包
require("../../../include/global.php");

require(VI_ROOT."/module/go/function.php");
require(VI_ROOT."/module/go/config.php");
require(VI_ROOT."/module/analytic/function.php");

//Action
$ip=getIP();

$id = GetNumber("id",0);

loader_cache($appid,"$appid.".$id);

switch($VICACHE["mod.go"]["method"]){
	
	//链出统计
	case "click":
	
		if ($VICACHE["mod.go"]["link"] && $id){
			
			//ping
			analytic_ping($appid,$id,'click');
			
			//清空缓冲
			ob_clean();
			
			//redirect
			header("Location: ".$VICACHE["mod.go"]["link"]);
			
		}
		
	break;
	
	//展示统计
	case "view":
	
		if ($id){
		
			//ping
			analytic_ping($appid,$id,'view');
			
			//清空缓冲
			ob_clean();
			
			//analytic_tote
			$conut = analytic_tote($appid,$id,'view');
			
			//echo $conut;
			//exit();
	
			$width		= 10 + strlen($conut) * 6;
			$height		= 20;
			
			$im=@imagecreate($width,$height) or die("Cannot Initialize new GD image stream");
			imagecolortransparent($im,imagecolorallocate($im,255,255,255));
			imagestring($im,2,5,3,$conut,imagecolorallocate($im,0,0,0));
			header("Content-type: image/png");
			imagepng($im);
			
		}
		
	break;
}

?>