<?PHP

require '../inc/page.zip.php';
require '../inc/conf.php';
require _Core.'/extender.php';
require _Core.'/template.php';
require _Core.'/engine.php';

$self = new Engine;
$self->__init();
$self->callSqlClass(array('banners'),  $self);

if(!is_numeric($_GET['banner_id'])) die($this->Redirect(_RootUrl));

$self->banners->Update("UPDATE banners SET clicked = clicked+1 WHERE id = ".$_GET['banner_id']);
$self->banners->Select("WHERE id = ".$_GET['banner_id']);

if($self->banners->Numrows > 0){

	$row = $self->banners->Assoc();

	$self->end();

	$url = !preg_match('/http/i', $row['url']) ? 'http://'.$row['url'] : $row['url'];

	die($self->Redirect($url));
}
die($self->Redirect(_RootUrl));

?>