<?php

include("inc.top.php");
get_logged_info();
$member_id=$q->f("id");
$q=new Cdb;
$q2=new Cdb;
$email = $_GET['email'];
$campaign = $_GET['campaign'];

if ($email != '' && $campaign != '' && $campaign != 'all')
{
	$q->query("SELECT id FROM banlist WHERE member_id = '".$member_id."' AND email = '".$email."' AND campaign = '".$campaign."'");
	if ($q->nf() > 0) {
		header("location: member.area.emailbanlist.php?add=1&error=1");
		exit;
	}else{
		$query="INSERT INTO banlist SET member_id = '".$member_id."' ,email = '".$email."' ,campaign = '".$campaign."' ,date_added ='".date("Y-m-d h:i:s")."' ,ban = 1 ";
		$q->query($query);
		
	}
}else { header("Location: member.area.emailbanlist.php?add=1&error=2");
		exit;
}

if ($campaign != 'all'){
	$q->query("SELECT id FROM campaigns");
	while ($q->next_record()) {
		$q->query("SELECT id FROM banlist WHERE member_id = '".$member_id."' AND email = '".$email."' AND campaign = '".$q2->f('id')."'");
		if ($q->nf() == 0) {
			$query="INSERT INTO banlist SET member_id = '".$member_id."' ,email = '".$email."' ,campaign = '".$q2->f('id')."' ,date_added ='".date("Y-m-d h:i:s")."' ,ban = 1 ";
			$q->query($query);
		}
	}

}

header("Location: member.area.emailbanlist.php");
include("inc.bottom.php");
?>