<?php

// if no $_GET die!
if (!$_GET['campaign']) {
	die('No advertiser detected!');
} else {

// include WordPress
require_once('../../../wp-load.php');
global $news;

// get the $_GET
$name = $_GET['campaign'];

// see if the campaign exists first
if (array_key_exists($name, $news['ads'])) {

$clicks = $news['ads'][$name]['clicks']; // retireve the clicks
$update_clicks = $clicks + 1; // calculate new clicks count
$news['ads'][$name]['clicks'] = $update_clicks; // update count
update_option('news', $news); // store new count in DB

if (preg_match('/href="([^"]*)"/i', stripslashes($news['ads'][$name]['code']), $regs)) {
	header('Location: '.$regs[1]);
}

// not a valid campaign, die!
} else {
	die('No campaign detected!');
}

// done?
}

?>