<?php
// www.bcoos.net 2006-09 1.0.2 GPL
include_once("../../mainfile.php");
if ($_GET['bid']) {
	$bid = $_GET['bid'];
	$result = $db->query("SELECT clickurl FROM ".$db->prefix("banner_items")." WHERE bid=$bid");
	list($clickurl) = $db->fetchRow($result);
	if ($clickurl) {
		if ( !isset($_COOKIE['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();
?>
