Exemple #1
0
function zen_expire_banners()
{
    global $gBitDb;
    $banners_query = "select b.`banners_id`, b.`expires_date`, b.`expires_impressions`,\n                             sum(bh.`banners_shown`) as `banners_shown`\n                      from " . TABLE_BANNERS . " b, " . TABLE_BANNERS_HISTORY . " bh\n                      where b.`status` = '1'\n                      and b.`banners_id` = bh.`banners_id`\n                      group by b.`banners_id`, b.`expires_date`, b.`expires_impressions`";
    $banners = $gBitDb->Execute($banners_query);
    if ($banners = $gBitDb->Execute($banners_query)) {
        while ($row = $banners->fetchRow()) {
            if (zen_not_null($row['expires_date'])) {
                if (date('Y-m-d H:i:s') >= $row['expires_date']) {
                    zen_set_banner_status($row['banners_id'], '0');
                }
            } elseif (zen_not_null($row['expires_impressions'])) {
                if ($row['expires_impressions'] > 0 && $row['banners_shown'] >= $row['expires_impressions']) {
                    zen_set_banner_status($row['banners_id'], '0');
                }
            }
        }
    }
}
Exemple #2
0
function zen_expire_banners()
{
    global $db;
    $banners_query = "select b.banners_id, b.expires_date, b.expires_impressions,\n                             sum(bh.banners_shown) as banners_shown\n                      from " . TABLE_BANNERS . " b, " . TABLE_BANNERS_HISTORY . " bh\n                      where b.status = 1\n                      and b.banners_id = bh.banners_id\n                      group by b.banners_id, b.expires_date, b.expires_impressions";
    $banners = $db->Execute($banners_query);
    if ($banners->RecordCount() > 0) {
        while (!$banners->EOF) {
            if (zen_not_null($banners->fields['expires_date'])) {
                if (date('Y-m-d H:i:s') >= $banners->fields['expires_date']) {
                    zen_set_banner_status($banners->fields['banners_id'], '0');
                }
            } elseif (zen_not_null($banners->fields['expires_impressions'])) {
                if ($banners->fields['expires_impressions'] > 0 && $banners->fields['banners_shown'] >= $banners->fields['expires_impressions']) {
                    zen_set_banner_status($banners->fields['banners_id'], '0');
                }
            }
            $banners->MoveNext();
        }
    }
}
}
if (isset($_GET['flag'])) {
    $_GET['flag'] = (int) $_GET['flag'];
}
if (isset($_GET['page'])) {
    $_GET['page'] = (int) $_GET['page'];
}
if (isset($_GET['flagbanners_open_new_windows'])) {
    $_GET['flagbanners_open_new_windows'] = (int) $_GET['flagbanners_open_new_windows'];
}
$banner_extension = zen_banner_image_extension();
if (zen_not_null($action)) {
    switch ($action) {
        case 'setflag':
            if ($_GET['flag'] == '0' || $_GET['flag'] == '1') {
                zen_set_banner_status($_GET['bID'], $_GET['flag']);
                $messageStack->add_session(SUCCESS_BANNER_STATUS_UPDATED, 'success');
            } else {
                $messageStack->add_session(ERROR_UNKNOWN_STATUS_FLAG, 'error');
            }
            zen_redirect(zen_href_link(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page'] . '&bID=' . $_GET['bID']));
            break;
        case 'setbanners_on_ssl':
            if ($_GET['flagbanners_on_ssl'] == '0' || $_GET['flagbanners_on_ssl'] == '1') {
                $db->Execute("update " . TABLE_BANNERS . " set banners_on_ssl='" . $_GET['flagbanners_on_ssl'] . "' where banners_id='" . $_GET['bID'] . "'");
                $messageStack->add_session(SUCCESS_BANNER_ON_SSL_UPDATED, 'success');
            } else {
                $messageStack->add_session(ERROR_UNKNOWN_BANNER_ON_SSL, 'error');
            }
            zen_redirect(zen_href_link(FILENAME_BANNER_MANAGER, 'page=' . $_GET['page'] . '&bID=' . $_GET['bID']));
            break;