<?
session_start ();
include "config.php";

$id = $_GET ['id'];

$query = "select * from banners where id = '" . dbput ( $id ) . "' LIMIT 1";
$result = mysql_query ( $query ) or die ( "Query failed" );
$numrows = @ mysql_num_rows ( $result );
?>
<html>
<body background="images/Back-4.gif">
<?
if ($_GET ['url']) {
	?>
<div style="float: left; padding-top: 75px;"><a
	href="<?
	echo $_GET ['url'];
	?>" target="_top">Remove This Frame</a></div>

<div style="float: right; padding-top: 75px;"><a
	href="<?
	echo $_GET ['url'];
	?>" target="_top">Remove This Frame</a></div>

<?
}
?>

<center>
<?
if ($numrows == 1) {
	
	$query1 = "select * from bannerviews where userid='" . dbput ( $userid ) . "' and blid=" . $id;
	$result1 = mysql_query ( $query1 ) or die ( "Query failed" );
	$numrows1 = @ mysql_num_rows ( $result1 );
	
	$query3 = "select * from members where userid='" . dbput ( $userid ) . "'";
	$result3 = mysql_query ( $query3 ) or die ( "Query failed" );
	
	$userrecord = mysql_fetch_array ( $result3 );
	$memtype = $userrecord ["memtype"];
	
	if ($numrows1 == 0) {
		add_adclick ( 'banner' );
		
		if ($memtype == "PRO") {
			$earn = $probannerearn;
			assignpoints ( $userrecord ['referid'], $earn );
		
		} 

		elseif ($memtype == "JV Member") {
			$earn = $jvbannerearn;
			assignpoints ( $userrecord ['referid'], $earn );
		} 

		else {
			$earn = $superjvbannerearn;
			assignpoints ( $userrecord ['referid'], $earn );
		}
		
		$queryaddpoints = "update members set points=points+" . $earn . " where userid='" . dbput ( $userid ) . "'";
		$resultaddpoints = mysql_query ( $queryaddpoints );
		if ($ppool == "1") {
			pointspool ( $earn );
		}
		if ($mpool == "1") {
			moneypool ( $earn );
		}
		
		echo "<font color=BLACK>You have earned <font color=BLUE><b>$earn</b></font> points.</font>&nbsp;&nbsp;";
		
		$query2 = "insert into bannerviews set userid='" . $userid . "', blid='" . dbput ( $id ) . "'";
		$result2 = mysql_query ( $query2 ) or die ( "Query failed" );
	
	} else
		echo "You have already received points for this link";

} else
	echo "Invalid link";

?>
<br>

<?

include ("banners2.php");
mysql_close ();
?>
</center>

</body>
</html>