Example #1
0
function zen_start_featured()
{
    global $gBitDb;
    $featured_query = "select `featured_id`\n                       from " . TABLE_FEATURED . "\n                       where `status` = '0'\n                       and (((`featured_date_available` <= 'NOW' and `featured_date_available` != '0001-01-01') and (`expires_date` >= 'NOW'))\n                       or ((`featured_date_available` <= 'NOW' and `featured_date_available` != '0001-01-01') and (`expires_date` = '0001-01-01'))\n                       or (`featured_date_available` = '0001-01-01' and `expires_date` >= 'NOW'))\n                       ";
    if ($rs = $gBitDb->Execute($featured_query)) {
        while ($featured = $rs->FetchRow()) {
            zen_set_featured_status($featured['featured_id'], '1');
        }
    }
    // turn off featured if not active yet
    $featured_query = "select `featured_id`\n                       from " . TABLE_FEATURED . "\n                       where `status` = '1'\n                       and ('NOW' < `featured_date_available` and `featured_date_available` != '0001-01-01')\n                       ";
    if ($rs = $gBitDb->Execute($featured_query)) {
        while ($featured = $rs->FetchRow()) {
            zen_set_featured_status($featured['featured_id'], '0');
        }
    }
}
Example #2
0
function zen_start_featured()
{
    global $db;
    $featured_query = "select featured_id\r\n                       from " . TABLE_FEATURED . "\r\n                       where status = '0'\r\n                       and (((featured_date_available <= now() and featured_date_available != '0001-01-01') and (expires_date >= now()))\r\n                       or ((featured_date_available <= now() and featured_date_available != '0001-01-01') and (expires_date = '0001-01-01'))\r\n                       or (featured_date_available = '0001-01-01' and expires_date >= now()))\r\n                       ";
    $featured = $db->Execute($featured_query);
    if ($featured->RecordCount() > 0) {
        while (!$featured->EOF) {
            zen_set_featured_status($featured->fields['featured_id'], '1');
            $featured->MoveNext();
        }
    }
    // turn off featured if not active yet
    $featured_query = "select featured_id\r\n                       from " . TABLE_FEATURED . "\r\n                       where status = '1'\r\n                       and (now() < featured_date_available and featured_date_available != '0001-01-01')\r\n                       ";
    $featured = $db->Execute($featured_query);
    if ($featured->RecordCount() > 0) {
        while (!$featured->EOF) {
            zen_set_featured_status($featured->fields['featured_id'], '0');
            $featured->MoveNext();
        }
    }
}
Example #3
0
/**
 * @package admin
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 *  $Id: featured.php 19294 2011-07-28 18:15:46Z drbyte $
 */
require 'includes/application_top.php';
require DIR_WS_CLASSES . 'currencies.php';
$currencies = new currencies();
$action = isset($_GET['action']) ? $_GET['action'] : '';
if (zen_not_null($action)) {
    switch ($action) {
        case 'setflag':
            if (isset($_POST['flag']) && ($_POST['flag'] == 1 || $_POST['flag'] == 0)) {
                zen_set_featured_status($_GET['id'], $_POST['flag']);
                zen_redirect(zen_href_link(FILENAME_FEATURED, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'fID=' . $_GET['id'] . (isset($_GET['search']) ? '&search=' . $_GET['search'] : ''), 'NONSSL'));
            }
            break;
        case 'insert':
            if ($_POST['products_id'] < 1) {
                $messageStack->add_session(ERROR_NOTHING_SELECTED, 'caution');
            } else {
                $products_id = zen_db_prepare_input($_POST['products_id']);
                $featured_date_available = zen_db_prepare_input($_POST['start']) == '' ? '0001-01-01' : zen_date_raw($_POST['start']);
                $expires_date = zen_db_prepare_input($_POST['end']) == '' ? '0001-01-01' : zen_date_raw($_POST['end']);
                $db->Execute("insert into " . TABLE_FEATURED . "\n                    (products_id, featured_date_added, expires_date, status, featured_date_available)\n                    values ('" . (int) $products_id . "',\n                            now(),\n                            '" . zen_db_input($expires_date) . "', '1', '" . zen_db_input($featured_date_available) . "')");
                $new_featured = $db->Execute("select featured_id from " . TABLE_FEATURED . " where products_id='" . (int) $products_id . "'");
            }
            // nothing selected to add
            if ($_GET['go_back'] == 'ON') {