';
}
}
//get and set the campaign id
$campaignselect = $_POST['campaignselect'];
if ($campaignselect){
$sql = "SELECT * FROM $campaignTable WHERE id='$campaignselect'";
$result = mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
$data = mysql_fetch_assoc($result);
$_SESSION['campaignlabel'] = $data['label'];
$_SESSION['cid'] = $campaignselect;
$_SESSION['testmode'] = $data['testmode'];
//set this in the settings table
$sql = "UPDATE $settingsTable SET selectedcid='$campaignselect'";
mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
include('globals.php'); //need to call this again to make any updates to header
}else{
//need to check if session cid even exists
$sql = "SELECT * FROM $campaignTable WHERE id='".$_SESSION['cid']."'";
$result = mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
if ($result){
$nc = mysql_num_rows($result);
if ($nc == 0){
//if not then select the last entry in the campaign table
$sql = "SELECT * FROM $campaignTable ORDER BY id DESC LIMIT 1";
$result = mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
$data = mysql_fetch_assoc($result);
$_SESSION['campaignlabel'] = $data['label'];
$_SESSION['cid'] = $data['id'];
$_SESSION['testmode'] = $data['testmode'];
include('globals.php'); //need to call this again to make any updates to header
}
}
}
//this only occurs when a campaign has been created or updated
$ncid = $_GET['ncid'];
if ($ncid){
$sql = "SELECT * FROM $campaignTable WHERE id='$ncid'";
$result = mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
$data = mysql_fetch_assoc($result);
$_SESSION['campaignlabel'] = $data['label'];
$_SESSION['cid'] = $ncid;
$_SESSION['testmode'] = $data['testmode'];
//set this in the settings table
$sql = "UPDATE $settingsTable SET selectedcid='$ncid'";
mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
include('globals.php'); //need to call this again to make any updates to header
}
//stats for the past 10 days
$sd = mktime(0,0,0,date("n"),date("j")-9,date("Y"));
$ed = mktime(23,59,59,date("n"),date("j"),date("Y"));
?>
Virtual Agent Control Panel