function xtc_activate_banners()
{
    $banners_query = xtc_db_query("select banners_id, date_scheduled from " . TABLE_BANNERS . " where date_scheduled != ''");
    if (xtc_db_num_rows($banners_query)) {
        while ($banners = xtc_db_fetch_array($banners_query)) {
            if (date('Y-m-d H:i:s') >= $banners['date_scheduled']) {
                xtc_set_banner_status($banners['banners_id'], '1');
            }
        }
    }
}
function xtc_expire_banners()
{
    $banners_query = xtc_db_query("select b.banners_id, b.expires_date, b.expires_impressions, sum(bh.banners_shown) as banners_shown from " . TABLE_BANNERS . " b, " . TABLE_BANNERS_HISTORY . " bh where b.status = '1' and b.banners_id = bh.banners_id group by b.banners_id");
    if (xtc_db_num_rows($banners_query)) {
        while ($banners = xtc_db_fetch_array($banners_query)) {
            if (xtc_not_null($banners['expires_date'])) {
                if (date('Y-m-d H:i:s') >= $banners['expires_date']) {
                    xtc_set_banner_status($banners['banners_id'], '0');
                }
            } elseif (xtc_not_null($banners['expires_impressions'])) {
                if ($banners['banners_shown'] >= $banners['expires_impressions']) {
                    xtc_set_banner_status($banners['banners_id'], '0');
                }
            }
        }
    }
}
   Contribution based on:

   osCommerce, Open Source E-Commerce Solutions
   http://www.oscommerce.com

   Copyright (c) 2002 - 2003 osCommerce

   Released under the GNU General Public License
   ---------------------------------------------------------------------------*/
require 'includes/application_top.php';
$affiliate_banner_extension = xtc_banner_image_extension();
if ($_GET['action']) {
    switch ($_GET['action']) {
        case 'setaffiliate_flag':
            if ($_GET['affiliate_flag'] == '0' || $_GET['affiliate_flag'] == '1') {
                xtc_set_banner_status($_GET['abID'], $_GET['affiliate_flag']);
                $messageStack->add_session(SUCCESS_BANNER_STATUS_UPDATED, 'success');
            } else {
                $messageStack->add_session(ERROR_UNKNOWN_STATUS_FLAG, 'error');
            }
            xtc_redirect(xtc_href_link(FILENAME_AFFILIATE_BANNER_MANAGER, 'page=' . $_GET['page'] . '&abID=' . $_GET['abID']));
            break;
        case 'insert':
        case 'update':
            $affiliate_banners_id = xtc_db_prepare_input($_POST['affiliate_banners_id']);
            $affiliate_banners_title = xtc_db_prepare_input($_POST['affiliate_banners_title']);
            $affiliate_products_id = xtc_db_prepare_input($_POST['affiliate_products_id']);
            $new_affiliate_banners_group = xtc_db_prepare_input($_POST['new_affiliate_banners_group']);
            $affiliate_banners_group = empty($new_affiliate_banners_group) ? xtc_db_prepare_input($_POST['affiliate_banners_group']) : $new_affiliate_banners_group;
            $affiliate_banners_image_target = xtc_db_prepare_input($_POST['affiliate_banners_image_target']);
            $affiliate_banners_image_local = xtc_db_prepare_input($_POST['affiliate_banners_image_local']);
   --------------------------------------------------------------
   based on: 
   (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
   (c) 2002-2003 osCommerce(banner_manager.php,v 1.70 2003/03/22); www.oscommerce.com 
   (c) 2003	 nextcommerce (banner_manager.php,v 1.9 2003/08/18); www.nextcommerce.org

   Released under the GNU General Public License 
   --------------------------------------------------------------*/
require 'includes/application_top.php';
$action = isset($_GET['action']) ? $_GET['action'] : '';
$banner_extension = xtc_banner_image_extension();
if (xtc_not_null($action)) {
    switch ($action) {
        case 'setflag':
            if ($_GET['flag'] == '0' || $_GET['flag'] == '1') {
                xtc_set_banner_status($_GET['bID'], $_GET['flag']);
                $messageStack->add_session(SUCCESS_BANNER_STATUS_UPDATED, 'success');
            } else {
                $messageStack->add_session(ERROR_UNKNOWN_STATUS_FLAG, 'error');
            }
            xtc_redirect(xtc_href_link(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page'] . '&bID=' . (int) $_GET['bID']));
            break;
        case 'insert':
        case 'update':
            if (isset($_POST['banners_id'])) {
                $banners_id = xtc_db_prepare_input($_POST['banners_id']);
            }
            $banners_title = xtc_db_prepare_input($_POST['banners_title']);
            $banners_url = xtc_db_prepare_input($_POST['banners_url']);
            $new_banners_group = xtc_db_prepare_input($_POST['new_banners_group']);
            $banners_group = empty($new_banners_group) ? xtc_db_prepare_input($_POST['banners_group']) : $new_banners_group;