<?php

	require("ef8fds_sqlconnect.php");
	$sides = array('left', 'bottom');
	
	$redir = key_exists('id', $_GET) ? $_GET['id'] : 0;
	$side = (key_exists('side', $_GET) && in_array($_GET['side'], $sides)) ? $side = $_GET['side'] : '';
	
	if($redir!=0 && $side!='')
	{
		$query = "SELECT clicked, url FROM mobile_reklama_$side WHERE ID=$redir limit 0, 1";
		$result = mysql_query($query, $link);
		$row = mysql_fetch_array($result);
		$clicked = $row['clicked']+1;
		$kam = $row['url'];
		$query = "UPDATE mobile_reklama_$side SET clicked=$clicked WHERE ID=$redir";
		mysql_query($query, $link);
		header("location: ".$kam);
	}
	else
	{
		echo 'Error';
	}

	mysql_close($link);
	
?>