<?php

/*
	[SupeSite/X-Space] (C)2001-2006 Comsenz Inc.
	ÏÔÊ¾¹ã¸æÄÚÈÝ

	$RCSfile: batch.ad.php,v $
	$Revision: 1.16 $
	$Date: 2007/02/12 14:48:31 $
*/

define('IN_SUPESITE', TRUE);

$adid = empty($_GET['id'])?0:intval($_GET['id']);
if(empty($adid)) exit();

$_SGLOBAL = array();

@include_once('./data/system/ad.cache.php');

if(empty($_SGLOBAL['ad'][$adid])) exit();
$thead = $_SGLOBAL['ad'][$adid];

if($thead['adtype'] == 'iframe') {

	print<<<END
	<script type="text/javascript" language="javascript" src="include/js/ajax.js"></script>
	<script type="text/javascript">
	function adclick(id) {
		var x = new Ajax('statusid', 'XML');
		x.get('batch.common.php?action=adclick&id='+id, function(s){});
	}
	</script>
	<div onclick="javascript:adclick($adid);">$thead[adcontent]</div>
END;

} elseif($thead['adtype'] == 'js') {

	preg_match("/\<script.*?\>(.+?)\<\/script\>/is", $thead['adcontent'], $mathes);
	if(!empty($mathes[1])) {
		$jsmessage = str_replace(array('<!--', '//-->'), '', $mathes[1]);
		echo $jsmessage;
		$thead['adcontent'] = preg_replace("/\<script.*?\>(.+?)\<\/script\>/is", '', $thead['adcontent']);
	}
	$code = $thead['adcontent'];
	$code = preg_replace("/(\r|\n)/s", '', $code);
	$code = addcslashes($code, '"\\');
	echo 'document.write("<div onclick=\"javascript:adclick('.$adid.');\">'.$code.'</div>");';

}

?>