Beispiel #1
0
         while (list($key, $value) = each($products)) {
             $category_ids = '';
             for ($i = 0, $n = sizeof($value['categories']); $i < $n; $i++) {
                 $category_ids .= "'" . (int) $value['categories'][$i] . "', ";
             }
             $category_ids = substr($category_ids, 0, -2);
             $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int) $key . "' and categories_id not in (" . $category_ids . ")");
             $check = tep_db_fetch_array($check_query);
             if ($check['total'] < '1') {
                 $products_delete[$key] = $key;
             }
         }
         // removing categories can be a lengthy process
         tep_set_time_limit(0);
         for ($i = 0, $n = sizeof($categories); $i < $n; $i++) {
             tep_remove_category($categories[$i]['id']);
         }
         reset($products_delete);
         while (list($key) = each($products_delete)) {
             tep_remove_product($key);
         }
     }
     if (USE_CACHE == 'true') {
         tep_reset_cache_block('categories');
         tep_reset_cache_block('also_purchased');
     }
     tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
     break;
 case 'delete_product_confirm':
     if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) {
         $product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
                 $products[$Qproducts->valueInt('products_id')]['categories'][] = $c_entry['id'];
             }
         }
         foreach ($products as $key => $value) {
             $Qcheck = $osC_Database->query('select count(*) as total from :table_products_to_categories where products_id = :products_id and categories_id not in :categories_id');
             $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
             $Qcheck->bindInt(':products_id', $key);
             $Qcheck->bindRaw(':categories_id', '("' . implode('", "', $value['categories']) . '")');
             $Qcheck->execute();
             if ($Qcheck->valueInt('total') < 1) {
                 $products_delete[$key] = $key;
             }
         }
         tep_set_time_limit(0);
         foreach ($categories as $c_entry) {
             tep_remove_category($c_entry['id']);
         }
         foreach ($products_delete as $key => $value) {
             tep_remove_product($key);
         }
         osC_Cache::clear('categories');
         osC_Cache::clear('category_tree');
         osC_Cache::clear('also_purchased');
         $osC_MessageStack->add_session('header', SUCCESS_DB_ROWS_UPDATED, 'success');
     }
     tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'page=' . $_GET['page'] . '&cPath=' . $cPath . '&search=' . $_GET['search']));
     break;
 case 'move_category_confirm':
     if (isset($_GET['cID']) && $_GET['cID'] != end(explode('_', $_POST['move_to_category_id']))) {
         $path = explode('_', $_POST['move_to_category_id']);
         if (in_array($_GET['cID'], $path)) {
        $metatags_title = $categories_name;
        $content_type = 'category';
        $content_id = $categories_id;
        tep_db_query("replace into " . TABLE_METATAGS . " (metatags_page_title, metatags_title, metatags_keywords, metatags_description, language_id, content_type, content_id) values ('" . tep_db_input($metatags_page_title) . "', '" . tep_db_input($metatags_title) . "', '" . tep_db_input($metatags_keywords) . "', '" . tep_db_input($metatags_description) . "', '" . (int) $languages_id . "', '" . tep_db_input($content_type) . "', '" . (int) $content_id . "')");
        $total++;
        $cells_count++;
    }
}
fclose($fp);
if ($action == 'upload_categories') {
    $shops_query = tep_db_query("select shops_database from " . TABLE_SHOPS . " where shops_database <> '' order by shops_default_status desc");
    while ($shops = tep_db_fetch_array($shops_query)) {
        tep_db_select_db($shops['shops_database']);
        $categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where products_types_id = '1' and categories_id not in ('" . implode("', '", $all_categories) . "')");
        while ($categories = tep_db_fetch_array($categories_query)) {
            tep_remove_category($categories['categories_id'], false);
        }
        tep_db_query("update " . TABLE_CATEGORIES_DESCRIPTION . " set categories_name = replace(categories_name, '\\\"', '\"')");
        //	  tep_db_query("update " . $shop_db . "." . TABLE_CATEGORIES . " set categories_status = '0' where products_types_id in (select products_types_id from " . TABLE_PRODUCTS_TYPES . " where products_types_status = '0')");
    }
    tep_db_select_db(DB_DATABASE);
}
$products_types_names = array();
tep_db_query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where language_id = '1' and categories_name = ''");
$fields = array('categories_name', 'categories_description');
$categories_query = tep_db_query("select categories_id, categories_name, categories_description from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id not in (select categories_id from " . TABLE_CATEGORIES_DESCRIPTION . " where language_id = '1') order by rand()");
while ($categories = tep_db_fetch_array($categories_query)) {
    $categories_id = $categories['categories_id'];
    $check_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int) $categories_id . "' and language_id = '1'");
    $check = tep_db_fetch_array($check_query);
    if ($check['total'] == 0) {
                 $category_ids = '';
                 for ($i = 0, $n = sizeof($value['categories']); $i < $n; $i++) {
                     $category_ids .= "'" . (int) $value['categories'][$i] . "', ";
                 }
                 $category_ids = substr($category_ids, 0, -2);
                 $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int) $key . "' and categories_id not in (" . $category_ids . ")");
                 $check = tep_db_fetch_array($check_query);
                 if ($check['total'] < '1') {
                     $products_delete[$key] = $key;
                 }
             }
         }
         // removing categories can be a lengthy process
         //		  reset($categories);
         //		  while (list(, $category_id) = each($categories)) {
         tep_remove_category($categories, $HTTP_POST_VARS['delete_category_products'] == '1');
         //		  }
         if ($HTTP_POST_VARS['delete_category_products'] == '1') {
             //			reset($products_delete);
             //			while (list($key) = each($products_delete)) {
             tep_remove_product($products_delete);
             //			}
         }
     }
     tep_db_query("update " . TABLE_PRODUCTS_TYPES . " set products_last_modified = now() where products_types_id = '" . (int) $tPath . "'");
     tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'tPath=' . $tPath . '&cPath=' . $cPath));
     break;
 case 'delete_product_confirm':
     if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) {
         $product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
         $product_categories = $HTTP_POST_VARS['product_categories'];