<?php
include_once("../../mainfile.php");

if ($HTTP_GET_VARS['bid']) {
	$bid = $HTTP_GET_VARS['bid'];
	$result = $db->query("SELECT clickurl FROM ".$db->prefix("banner_items")." WHERE bid=$bid");
	list($clickurl) = $db->fetch_row($result);
	if ($clickurl) {
		if ( !isset($HTTP_COOKIE_VARS['banners'][$bid]) ) {
			cookie("banners[$bid]", $bid, 86400);
			$db->query("UPDATE ".$db->prefix("banner_items")." SET clicks=clicks+1 WHERE bid=$bid");
		}
		echo "
			<html>
			<head><meta http-equiv='Refresh' content='0; URL=".$clickurl."'></head>
			<body></body>
			</html>";
		exit();
	}
}

redirect_header(XOOPS_URL.'/');
exit();
?>
