コード例 #1
0
                 $category_ids .= "'" . (int) $value['categories'][$i] . "', ";
             }
             $category_ids = substr($category_ids, 0, -2);
             $check = $db->Execute("select count(*) as total\n                                           from " . TABLE_PRODUCTS_TO_CATEGORIES . "\n                                           where products_id = '" . (int) $key . "'\n                                           and categories_id not in (" . $category_ids . ")");
             if ($check->fields['total'] < '1') {
                 $products_delete[$key] = $key;
             }
         }
         // removing categories can be a lengthy process
         zen_set_time_limit(600);
         for ($i = 0, $n = sizeof($categories); $i < $n; $i++) {
             zen_remove_category($categories[$i]['id']);
         }
         reset($products_delete);
         while (list($key) = each($products_delete)) {
             zen_remove_product($key);
         }
     }
     zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
     break;
     //////////////////////////////////
     // delete new
 //////////////////////////////////
 // delete new
 case 'delete_category_confirm':
     // demo active test
     if (zen_admin_demo()) {
         $_GET['action'] = '';
         $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
         zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
     }
コード例 #2
0
        }
        //echo 'SQL=' . "select artists_id, record_company_id, music_genre_id from " . TABLE_PRODUCT_MUSIC_EXTRA . "                                 where products_id = '" . (int)$product_id . "'<br />";
        $music_extra = $db->Execute("select artists_id, record_company_id, music_genre_id from " . TABLE_PRODUCT_MUSIC_EXTRA . "\r\n                                       where products_id = '" . (int) $product_id . "'");
        //echo 'media count =' . $music_extra->RecordCount() . '<br />';
        if ($music_extra->RecordCount() > 0) {
            //echo 'artists_id delete=' . $music_extra->fields['artists_id'] . '<br />';
            //echo 'record_company_id delete=' . $music_extra->fields['record_company_id'] . '<br />';
            //echo 'music_genre_id delete=' . $music_extra->fields['music_genre_id'] . '<br />';
            $db->Execute("delete from " . TABLE_PRODUCT_MUSIC_EXTRA . "\r\n                      where products_id = '" . (int) $product_id . "'\r\n                      and artists_id = '" . zen_db_input($music_extra->fields['artists_id']) . "'\r\n                      and record_company_id = '" . zen_db_input($music_extra->fields['record_company_id']) . "'\r\n                      and music_genre_id = '" . zen_db_input($music_extra->fields['music_genre_id']) . "'");
        }
    }
    //--------------PRODUCT_TYPE_SPECIFIC_INSTRUCTIONS_GO__ABOVE__HERE--------------------------------------------------------
    // now do regular non-type-specific delete:
    // remove product from all its categories:
    for ($k = 0, $m = sizeof($product_categories); $k < $m; $k++) {
        $db->Execute("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . "\r\n                    where products_id = '" . (int) $product_id . "'\r\n                    and categories_id = '" . (int) $product_categories[$k] . "'");
    }
    // confirm that product is no longer linked to any categories
    $count_categories = $db->Execute("select count(categories_id) as total\r\n                                      from " . TABLE_PRODUCTS_TO_CATEGORIES . "\r\n                                      where products_id = '" . (int) $product_id . "'");
    // echo 'count of category links for this product=' . $count_categories->fields['total'] . '<br />';
    // if not linked to any categories, do delete:
    if ($count_categories->fields['total'] == '0') {
        zen_remove_product($product_id, $delete_linked);
    }
}
// endif $do_delete_flag
// if this is a single-product delete, redirect to categories page
// if not, then this file was called by the cascading delete initiated by the category-delete process
if ($action == 'delete_product_confirm') {
    zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
}
コード例 #3
0
ファイル: manufacturers.php プロジェクト: zenmagick/zencart
                zen_redirect(zen_href_link(FILENAME_MANUFACTURERS, 'page=' . $_GET['page']));
            }
            $manufacturers_id = zen_db_prepare_input($_POST['mID']);
            if (isset($_POST['delete_image']) && $_POST['delete_image'] == 'on') {
                $manufacturer = $db->Execute("select manufacturers_image\n                                        from " . TABLE_MANUFACTURERS . "\n                                        where manufacturers_id = '" . (int) $manufacturers_id . "'");
                $image_location = DIR_FS_CATALOG_IMAGES . $manufacturer->fields['manufacturers_image'];
                if (file_exists($image_location)) {
                    @unlink($image_location);
                }
            }
            $db->Execute("delete from " . TABLE_MANUFACTURERS . "\n                      where manufacturers_id = '" . (int) $manufacturers_id . "'");
            $db->Execute("delete from " . TABLE_MANUFACTURERS_INFO . "\n                      where manufacturers_id = '" . (int) $manufacturers_id . "'");
            if (isset($_POST['delete_products']) && $_POST['delete_products'] == 'on') {
                $products = $db->Execute("select products_id\n                                    from " . TABLE_PRODUCTS . "\n                                    where manufacturers_id = '" . (int) $manufacturers_id . "'");
                while (!$products->EOF) {
                    zen_remove_product($products->fields['products_id']);
                    $products->MoveNext();
                }
            } else {
                $db->Execute("update " . TABLE_PRODUCTS . "\n                        set manufacturers_id = 0\n                        where manufacturers_id = '" . (int) $manufacturers_id . "'");
            }
            zen_redirect(zen_href_link(FILENAME_MANUFACTURERS, 'page=' . $_GET['page']));
            break;
    }
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php 
echo HTML_PARAMS;
?>
>
コード例 #4
0
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | license@zen-cart.com so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
//  $Id: delete_product_confirm.php 290 2004-09-15 19:48:26Z wilt $
//
//
// demo active test
if (zen_admin_demo()) {
    $_GET['action'] = '';
    $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
    zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&pID=' . $_GET['pID'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
}
if (isset($_POST['products_id']) && isset($_POST['product_categories']) && is_array($_POST['product_categories'])) {
    $product_id = zen_db_prepare_input($_POST['products_id']);
    $product_categories = $_POST['product_categories'];
    for ($i = 0, $n = sizeof($product_categories); $i < $n; $i++) {
        $db->Execute("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . "\r\n                          where products_id = '" . (int) $product_id . "'\r\n                          and categories_id = '" . (int) $product_categories[$i] . "'");
    }
    $product_categories = $db->Execute("select count(*) as total\r\n                                              from " . TABLE_PRODUCTS_TO_CATEGORIES . "\r\n                                              where products_id = '" . (int) $product_id . "'");
    if ($product_categories->fields['total'] == '0') {
        zen_remove_product($product_id);
    }
}
zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
コード例 #5
0
function ep_purge_dross()
{
    $dross = array();
    $dross = ep_get_dross();
    foreach ($dross as $products_id => $langer) {
        zen_remove_product($products_id);
    }
}
コード例 #6
0
ファイル: categories.php プロジェクト: severnaya99/Sg-2010
         for ($i = 0, $n = sizeof($categories); $i < $n; $i++) {
             $product_ids = $db->Execute("select products_id\r\n                                         from " . TABLE_PRODUCTS_TO_CATEGORIES . "\r\n                                         where categories_id = '" . (int) $categories[$i]['id'] . "'");
             while (!$product_ids->EOF) {
                 $products[$product_ids->fields['products_id']]['categories'][] = $categories[$i]['id'];
                 $product_ids->MoveNext();
             }
         }
         // change the status of categories and products
         zen_set_time_limit(600);
         for ($i = 0, $n = sizeof($categories); $i < $n; $i++) {
             // set products_status based on selection
             $sql = "select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $categories[$i]['id'] . "'";
             $category_products = $db->Execute($sql);
             while (!$category_products->EOF) {
                 // future cat specific use for
                 zen_remove_product($category_products->fields['products_id'], $delete_linked);
                 $category_products->MoveNext();
             }
             zen_remove_category($categories[$i]['id']);
         }
         // for
     }
     zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
     break;
     // eof delete new
     /////////////////////////////////
     // @@TODO where is delete_product_confirm
 // eof delete new
 /////////////////////////////////
 // @@TODO where is delete_product_confirm
 case 'move_category_confirm':
コード例 #7
0
function ep_4_remove_product($product_model)
{
    global $db, $ep_debug_logging, $ep_debug_logging_all, $ep_stack_sql_error;
    $project = PROJECT_VERSION_MAJOR . '.' . PROJECT_VERSION_MINOR;
    $ep_uses_mysqli = PROJECT_VERSION_MAJOR > '1' || PROJECT_VERSION_MINOR >= '5.3' ? true : false;
    $sql = "SELECT products_id FROM " . TABLE_PRODUCTS . " WHERE products_model = '" . zen_db_input($product_model) . "'";
    $products = $db->Execute($sql);
    if ($ep_uses_mysqli ? mysqli_errno($db->link) : mysql_errno()) {
        $ep_stack_sql_error = true;
        if ($ep_debug_logging == true) {
            $string = "MySQL error " . ($ep_uses_mysqli ? mysqli_errno($db->link) : mysql_errno()) . ": " . ($ep_uses_mysqli ? mysqli_error($db->link) : mysql_error()) . "\nWhen executing:\n{$sql}\n";
            write_debug_log($string);
        }
    } elseif ($ep_debug_logging_all == true) {
        $string = "MySQL PASSED\nWhen executing:\n{$sql}\n";
        write_debug_log($string);
    }
    while (!$products->EOF) {
        zen_remove_product($products->fields['products_id']);
        $products->MoveNext();
    }
    return;
}
コード例 #8
0
 function importProduct($data, $format)
 {
     // prepare data
     $validate = true;
     $ignore_column = $this->getFormatColumnIgnore($format['csv_format_type_id']);
     $ignore_id = $ignore_column['csv_column_id'];
     $delete_column = $this->getFormatColumnDelete($format['csv_format_type_id']);
     $delete_id = $delete_column['csv_column_id'];
     $this->messageStack->reset();
     // search products_model and validate
     foreach ($format['columns'] as $key => $val) {
         if (!empty($val['csv_column_validate_function'])) {
             $validate_function = $val['csv_column_validate_function'];
             if ($this->{$validate_function}($data[$key], $val['csv_column_name']) === true) {
                 $validate = $validate && true;
             } else {
                 $validate = $validate && false;
             }
         }
         if ($val['csv_columns_dbtable'] == 'products' && $val['csv_columns_dbcolumn'] == 'products_model') {
             $products_model = $data[$key];
         }
         if ($val['csv_column_id'] == $delete_id) {
             if ($data[$key] == 1) {
                 $delete_flag = true;
             } else {
                 $delete_flag = false;
             }
         }
     }
     if (empty($products_model)) {
         $validate = $validate && false;
         $this->messageStack->add(PRODUCT_CSV_MESSAGE_NO_MODEL, 'warning');
     }
     // return if validate is false
     if ($validate === false) {
         return false;
     }
     // main
     $sql = 'SELECT * FROM ' . TABLE_PRODUCTS . ' WHERE products_model=\'' . zen_db_input($products_model) . '\'';
     $product = $this->db->Execute($sql);
     if ($product->RecordCount() == 0) {
         $sql = 'INSERT INTO ' . TABLE_PRODUCTS . ' (products_model, products_date_added, products_status) VALUES(\'' . zen_db_input($products_model) . '\', NOW(), 1)';
         $this->db->Execute($sql);
         $products_id = $this->db->Insert_ID();
         // search language id
         foreach ($format['columns'] as $val) {
             if (isset($val['language_id'])) {
                 $language_ids[$val['language_id']] = 1;
             }
         }
         // insert products description
         foreach ($language_ids as $language_id => $flag) {
             $sql = 'INSERT INTO ' . TABLE_PRODUCTS_DESCRIPTION . ' (products_id, language_id) VALUES (\'' . $products_id . '\', \'' . $language_id . '\')';
             $this->db->Execute($sql);
             $sql = 'INSERT INTO ' . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ' (products_id, language_id) VALUES (\'' . $products_id . '\', \'' . $language_id . '\')';
             $this->db->Execute($sql);
         }
     } else {
         $products_id = $product->fields['products_id'];
     }
     // delete product
     if ($delete_flag === true) {
         zen_remove_product($products_id);
         $this->messageStack->add(PRODUCT_CSV_MESSAGE_DELETE, 'success');
         return true;
     }
     foreach ($format['columns'] as $key => $val) {
         if ($val['csv_column_id'] == $ignore_id) {
             continue;
         }
         if ($val['csv_columns_dbtable'] == 'products') {
             if ($val['csv_columns_dbcolumn'] == 'products_status' && $data[$key] == '') {
                 continue;
             }
             $sql = 'UPDATE ' . TABLE_PRODUCTS . ' SET ' . $val['csv_columns_dbcolumn'] . '=\'' . zen_db_input($data[$key]) . '\' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
             if ($val['csv_columns_dbcolumn'] == 'products_price') {
                 $products_price = $data[$key];
             }
         } elseif ($val['csv_columns_dbtable'] == 'tax_class') {
             $sql = 'SELECT tax_class_id FROM ' . TABLE_TAX_CLASS . ' WHERE ' . $val['csv_columns_dbcolumn'] . '=\'' . zen_db_input($data[$key]) . '\'';
             $tax_class = $this->db->Execute($sql);
             $sql = 'UPDATE ' . TABLE_PRODUCTS . ' SET products_tax_class_id=\'' . $tax_class->fields['tax_class_id'] . '\' WHERE products_id=\'' . $products_id . '\'';
             $this->db->Execute($sql);
         } elseif ($val['csv_columns_dbtable'] == 'product_types') {
             $sql = 'SELECT type_id FROM ' . TABLE_PRODUCT_TYPES . ' WHERE ' . $val['csv_columns_dbcolumn'] . '=\'' . zen_db_input($data[$key]) . '\'';
             $product_type = $this->db->Execute($sql);
             $sql = 'UPDATE ' . TABLE_PRODUCTS . ' SET products_type=\'' . $product_type->fields['type_id'] . '\' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         } elseif ($val['csv_columns_dbtable'] == 'manufacturers') {
             $sql = 'SELECT manufacturers_id FROM ' . TABLE_MANUFACTURERS . ' WHERE ' . $val['csv_columns_dbcolumn'] . '=\'' . zen_db_input($data[$key]) . '\'';
             $manufacturer = $this->db->Execute($sql);
             if ($manufacturer->RecordCount() == 0) {
                 // insert manufacturer
                 $sql = 'INSERT INTO ' . TABLE_MANUFACTURERS . ' (manufacturers_name, date_added, last_modified) VALUES (\'' . zen_db_input($data[$key]) . '\', NOW(), NOW())';
                 $this->db->Execute($sql);
                 $manufacturer_id = $this->db->Insert_ID();
             } else {
                 $manufacturer_id = $manufacturer->fields['manufacturers_id'];
             }
             $sql = 'UPDATE ' . TABLE_PRODUCTS . ' SET manufacturers_id=\'' . $manufacturer_id . '\' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         } elseif ($val['csv_columns_dbtable'] == 'products_description') {
             if (isset($val['language_id'])) {
                 $sql = 'UPDATE ' . TABLE_PRODUCTS_DESCRIPTION . ' SET ' . $val['csv_columns_dbcolumn'] . '=\'' . zen_db_input($data[$key]) . '\' WHERE products_id=' . $products_id . ' AND language_id=' . $val['language_id'] . '';
                 $this->db->Execute($sql);
             }
         } elseif ($val['csv_columns_dbtable'] == 'meta_tags_products_description') {
             if (isset($val['language_id'])) {
                 $meta_tags[$val['language_id']][$val['csv_columns_dbcolumn']] = $data[$key];
             }
         } elseif ($val['csv_columns_dbtable'] == 'featured') {
             $featured[$val['csv_columns_dbcolumn']] = $data[$key];
         } elseif ($val['csv_columns_dbtable'] == 'specials') {
             $specials[$val['csv_columns_dbcolumn']] = $data[$key];
         }
     }
     if (isset($meta_tags)) {
         foreach ($meta_tags as $key => $val) {
             if (!empty($val['metatags_title']) || !empty($val['metatags_keywords']) || !empty($val['metatags_description'])) {
                 // set metatags
                 $sql = 'SELECT * FROM ' . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ' WHERE products_id=' . $products_id . ' AND language_id=' . $key . '';
                 $meta_tags_record = $this->db->Execute($sql);
                 if ($meta_tags_record->RecordCount() == 0) {
                     $sql = 'INSERT INTO ' . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ' (products_id, language_id) VALUES (\'' . $products_id . '\', \'' . $key . '\')';
                     $this->db->Execute($sql);
                 }
                 $sql = 'UPDATE ' . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ' SET metatags_title=\'' . zen_db_input($val['metatags_title']) . '\', metatags_keywords=\'' . zen_db_input($val['metatags_keywords']) . '\', metatags_description=\'' . zen_db_input($val['metatags_description']) . '\' WHERE products_id=' . $products_id . ' AND language_id=' . $key . '';
                 $this->db->Execute($sql);
             } else {
                 // delete metatags
                 $sql = 'DELETE FROM ' . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . ' WHERE products_id=' . $products_id . ' AND language_id=' . $key . '';
                 $this->db->Execute($sql);
             }
         }
     }
     if (isset($featured)) {
         if (!empty($featured['featured_date_available']) || !empty($featured['expires_date'])) {
             // set featured
             $sql = 'SELECT * FROM ' . TABLE_FEATURED . ' WHERE products_id=' . $products_id . '';
             $featured_record = $this->db->Execute($sql);
             if ($featured_record->RecordCount() == 0) {
                 $sql = 'INSERT INTO ' . TABLE_FEATURED . ' (products_id) VALUES (\'' . $products_id . '\')';
                 $this->db->Execute($sql);
             }
             $sql = 'UPDATE ' . TABLE_FEATURED . ' SET featured_date_available=\'' . zen_db_input($featured['featured_date_available']) . '\', expires_date=\'' . zen_db_input($featured['expires_date']) . '\' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         } else {
             // delete featured
             $sql = 'DELETE FROM ' . TABLE_FEATURED . ' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         }
     }
     if (isset($specials)) {
         if (!empty($specials['specials_new_products_price'])) {
             // prepare data
             $status = 1;
             if (!isset($specials['specials_date_available']) || empty($specials['specials_date_available'])) {
                 $specials['specials_date_available'] = '0001-01-01';
                 $status = $status * 1;
             } else {
                 $available_time = strtotime($specials['specials_date_available']);
                 if ($available_time !== false && $available_time <= time()) {
                     $status = $status * 1;
                 } else {
                     $status = $status * 0;
                 }
             }
             if (!isset($specials['expires_date']) || empty($specials['expires_date'])) {
                 $specials['expires_date'] = '0001-01-01';
                 $status = $status * 1;
             } else {
                 $expire_time = strtotime($specials['expires_date']);
                 if ($expire_time !== false && $expire_time >= time()) {
                     $status = $status * 1;
                 } else {
                     $status = $status * 0;
                 }
             }
             // set specials
             $sql = 'SELECT * FROM ' . TABLE_SPECIALS . ' WHERE products_id=' . $products_id . '';
             $specials_record = $this->db->Execute($sql);
             if ($specials_record->RecordCount() == 0) {
                 $sql = 'INSERT INTO ' . TABLE_SPECIALS . ' (products_id, specials_date_added, specials_last_modified) VALUES (\'' . $products_id . '\', NOW(), NOW())';
                 $this->db->Execute($sql);
             }
             $sql = 'UPDATE ' . TABLE_SPECIALS . ' SET specials_new_products_price=\'' . zen_db_input($specials['specials_new_products_price']) . '\', expires_date=\'' . zen_db_input($specials['expires_date']) . '\', specials_date_available=\'' . zen_db_input($specials['specials_date_available']) . '\', status=' . $status . ', date_status_change=NOW(), specials_last_modified=NOW() WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         } else {
             // delete specials
             $sql = 'DELETE FROM ' . TABLE_SPECIALS . ' WHERE products_id=' . $products_id . '';
             $this->db->Execute($sql);
         }
     }
     // update products_price_sorter
     $special_price = zen_get_products_special_price($products_id);
     $products_price = isset($products_price) ? $products_price : 0;
     $products_price_sorter = $special_price === false ? $products_price : $special_price;
     $sql = 'UPDATE ' . TABLE_PRODUCTS . ' SET products_price_sorter=\'' . zen_db_input($products_price_sorter) . '\' WHERE products_id=' . $products_id;
     $this->db->Execute($sql);
     $this->messageStack->add(PRODUCT_CSV_MESSAGE_SUCCESS, 'success');
     return true;
 }