// Delete Banner ACLs
        phpAds_dbQuery("\n\t\t\tDELETE FROM\n\t\t\t\t" . $phpAds_config['tbl_acls'] . "\n\t\t\tWHERE\n\t\t\t\tbannerid = " . $row['bannerid'] . "\n\t\t") or phpAds_sqlDie();
        // Delete stats for each banner
        phpAds_deleteStats($row['bannerid']);
    }
    // Delete Banners
    phpAds_dbQuery("\n\t\tDELETE FROM\n\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\tWHERE\n\t\t\tclientid = '{$campaignid}'\n\t") or phpAds_sqlDie();
}
if (isset($campaignid) && $campaignid != '') {
    // Campaign is specified, delete only this campaign
    phpAds_DeleteCampaign($campaignid);
} elseif (isset($clientid) && $clientid != '') {
    // No campaign specified, delete all campaigns for this client
    $res_campaigns = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tclientid\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\tWHERE\n\t\t\tparent = " . $clientid . "\n\t");
    while ($row = phpAds_dbFetchArray($res_campaigns)) {
        phpAds_DeleteCampaign($row['clientid']);
    }
}
// Rebuild priorities
phpAds_PriorityCalculate();
// Rebuild cache
if (!defined('LIBVIEWCACHE_INCLUDED')) {
    include phpAds_path . '/libraries/deliverycache/cache-' . $phpAds_config['delivery_caching'] . '.inc.php';
}
phpAds_cacheDelete();
if (!isset($returnurl) && $returnurl == '') {
    $returnurl = 'client-campaigns.php';
}
// Prevent HTTP response splitting
if (!preg_match('/[\\r\\n]/', $returnurl)) {
    $url = stripslashes($returnurl);
            phpAds_ImageDelete($row['storagetype'], $row['filename']);
        }
        // Delete Banner ACLs
        phpAds_dbQuery("\n\t\t\tDELETE FROM\n\t\t\t\t" . $phpAds_config['tbl_acls'] . "\n\t\t\tWHERE\n\t\t\t\tbannerid = " . $row['bannerid'] . "\n\t\t") or phpAds_sqlDie();
        // Delete stats for each banner
        phpAds_deleteStatsByBannerID($row['bannerid']);
    }
    // Delete Banners
    phpAds_dbQuery("\n\t\tDELETE FROM\n\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\tWHERE\n\t\t\tcampaignid = '{$campaignid}'\n\t") or phpAds_sqlDie();
}
if (isset($campaignid) && $campaignid != '') {
    // Campaign is specified, delete only this campaign
    phpAds_DeleteCampaign($campaignid);
} elseif (isset($clientid) && $clientid != '') {
    // No campaign specified, delete all campaigns for this client
    $res_campaigns = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tcampaignid\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_campaigns'] . "\n\t\tWHERE\n\t\t\tclientid = " . $clientid . "\n\t");
    while ($row = phpAds_dbFetchArray($res_campaigns)) {
        phpAds_DeleteCampaign($row['campaignid']);
    }
}
// Rebuild priorities
phpAds_PriorityCalculate();
// Rebuild cache
if (!defined('LIBVIEWCACHE_INCLUDED')) {
    include phpAds_path . '/libraries/deliverycache/cache-' . $phpAds_config['delivery_caching'] . '.inc.php';
}
phpAds_cacheDelete();
if (!isset($returnurl) && $returnurl == '') {
    $returnurl = 'advertiser-campaigns.php';
}
header("Location: " . $returnurl . "?clientid=" . $clientid);