$field_value = str_replace('.', ',', $field_value); } if (preg_match("/[,;\"\n\r\t\\s]/", $field_value)) { $field_value = "\"" . str_replace("\"", "\"\"", $field_value) . "\""; } if ($i > 0) { $csv_row .= $delimiter_symbol; } $csv_row .= $field_value; } echo $csv_row . $eol; // end output $related_number = 0; // update exported status if ($table_name == $table_prefix . "orders") { $dbh->query("UPDATE " . $table_prefix . "orders SET is_exported=1 WHERE order_id=" . $prev_id); } } $related_number++; // collect data for next step for ($i = 0; $i < $columns_selected; $i++) { $column_name = $columns[$i]; $field_value = ""; if ($column_name == "item_category") { $item_id = $db->f("item_id"); $sql = " SELECT ic.category_id, c.category_path FROM " . $table_prefix . "items_categories ic "; $sql .= " LEFT JOIN " . $table_prefix . "categories c ON ic.category_id=c.category_id "; $sql .= " WHERE ic.item_id=" . $db->tosql($item_id, INTEGER); $dbh->query($sql); while ($dbh->next_record()) { $category = "";
function delete_categories($categories_ids) { global $db, $table_prefix; // additional connection $dbs = new VA_SQL(); $dbs->DBType = $db->DBType; $dbs->DBDatabase = $db->DBDatabase; $dbs->DBHost = $db->DBHost; $dbs->DBPort = $db->DBPort; $dbs->DBUser = $db->DBUser; $dbs->DBPassword = $db->DBPassword; $dbs->DBPersistent = $db->DBPersistent; $categories = array(); $sql = " SELECT category_id,category_path FROM " . $table_prefix . "categories "; $sql .= " WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ") "; $dbs->query($sql); while ($dbs->next_record()) { $category_id = $dbs->f("category_id"); $category_path = $dbs->f("category_path"); if (!in_array($category_id, $categories)) { $categories[] = $category_id; $sql = " SELECT category_id FROM " . $table_prefix . "categories "; $sql .= " WHERE category_path LIKE '" . $db->tosql($category_path . $category_id . ",", TEXT, false) . "%'"; $db->query($sql); while ($db->next_record()) { $categories[] = $db->f("category_id"); } } } if (is_array($categories) && sizeof($categories) > 0) { $categories_ids = join(",", $categories); $db->query("DELETE FROM " . $table_prefix . "categories WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")"); $db->query("DELETE FROM " . $table_prefix . "items_categories WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")"); $db->query("DELETE FROM " . $table_prefix . "categories_user_types WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")"); $db->query("DELETE FROM " . $table_prefix . "categories_subscriptions WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")"); $db->query("DELETE FROM " . $table_prefix . "categories_sites WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")"); $db->query("DELETE FROM " . $table_prefix . "categories_columns WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")"); } // delete products that are not assigned to any category $sql = " SELECT i.item_id FROM (" . $table_prefix . "items i "; $sql .= " LEFT JOIN " . $table_prefix . "items_categories ic ON i.item_id=ic.item_id) "; $sql .= " WHERE ic.category_id IS NULL "; $dbs->query($sql); while ($dbs->next_record()) { $item_id = $dbs->f("item_id"); delete_products($item_id); } }
include_once "../includes/db_{$db_lib}.php"; session_start(); $db = new VA_SQL(); $db->DBType = $db_type; $db->DBDatabase = $db_name; $db->DBHost = $db_host; $db->DBPort = $db_port; $db->DBUser = $db_user; $db->DBPassword = $db_password; $db->DBPersistent = $db_persistent; if (isset($_REQUEST['action']) && $_REQUEST['action'] == "add" && isset($_REQUEST['item_id']) && is_numeric($_REQUEST['item_id']) && isset($_REQUEST['item_name']) && isset($_REQUEST['quantity']) && isset($_REQUEST['price'])) { $duplicates = false; if (isset($_REQUEST['user_id']) && is_numeric($_REQUEST['user_id'])) { $user_id = get_session("session_user_id") ? get_session("session_user_id") : $_REQUEST['user_id']; $product_dup_query = "SELECT * FROM va_saved_items WHERE item_id = " . $_REQUEST['item_id'] . " AND user_id = " . $user_id; $db->query($product_dup_query); $duplicates = $db->next_record(); } else { $id_query = "SELECT MAX(user_id) AS last_user_id FROM va_saved_items"; $db->query($id_query); $db->next_record(); $user_id = $db->f("last_user_id") < 444444444 ? 444444444 : $db->f("last_user_id") + 1; } if (!$duplicates) { $sql = "INSERT INTO `va_saved_items` (`cart_item_id`, `site_id`, `item_id`, `cart_id`, `user_id`, `type_id`, `item_name`, `quantity`, `quantity_bought`, `price`,`date_added`) VALUES (NULL, 1, '" . $_REQUEST['item_id'] . "', 0, '" . $user_id . "', '1', '" . $_REQUEST['item_name'] . "', '" . $_REQUEST['quantity'] . "', 0, '" . $_REQUEST['price'] . "', NOW())"; $db->query($sql); } $data = array('user_id' => $user_id, 'duplicates' => $duplicates); echo json_encode($data); } else { if (isset($_REQUEST['action']) && $_REQUEST['action'] == "show") {
//if (preg_match('/.*books.*/i', $item_google_type)) { // write_to("\t\t<" . $schema_type . ":isbn>" . $item_code . "</" . $schema_type . ":isbn>" . $eol); //} //else if (preg_match('/.*media.*/i', $item_google_type) || preg_match('/.*software.*/i', $item_google_type)) { // write_to("\t\t<" . $schema_type . ":upc>" . $item_code . "</" . $schema_type . ":upc>" . $eol); //} //else { // write_to("\t\t<" . $schema_type . ":gtin>" . $item_code . "</" . $schema_type . ":gtin>" . $eol); //} } else { write_to("\t\t<" . $schema_type . ":mpn><![CDATA[" . substr(md5(microtime()), rand(0, 26), 5) . "]]></" . $schema_type . ":mpn>" . $eol); } //Customization by Vital - adding product category description $specific_item_type = "Wall Stencils"; $sql = "SELECT c.category_name FROM ( " . $table_prefix . "items_categories ic LEFT JOIN " . $table_prefix . "categories c ON ic.category_id=c.category_id) WHERE ic.item_id=" . $dbd->tosql($item_id, INTEGER) . " ORDER BY c.category_order"; $dbd->query($sql); if ($dbd->next_record()) { if ($dbd->f("category_name")) { $specific_item_type = $dbd->f("category_name"); } } //END customization write_to("\t\t<" . $schema_type . ":product_type>" . htmlspecialchars($item_google_type) . " > " . $specific_item_type . "</" . $schema_type . ":product_type>" . $eol); write_to("\t\t<" . $schema_type . ":google_product_category>" . htmlspecialchars($item_google_type) . "</" . $schema_type . ":google_product_category>" . $eol); write_to("\t\t<" . $schema_type . ":expiration_date>" . $expiration_date_formatted . "</" . $schema_type . ":expiration_date>" . $eol); write_to("\t\t<" . $schema_type . ":condition>" . $google_base_product_condition . "</" . $schema_type . ":condition>" . $eol); $description = trim(strip_tags(get_translation($db->f("full_description")))); if (!strlen($description)) { $description = trim(strip_tags(get_translation($db->f("short_description")))); } if (!strlen($description)) {
<?php include_once "../includes/var_definition.php"; include_once "../includes/constants.php"; include_once "../includes/db_{$db_lib}.php"; header('Content-Type: text/html; charset=iso-8859-1'); $db = new VA_SQL(); $db->DBType = $db_type; $db->DBDatabase = $db_name; $db->DBHost = $db_host; $db->DBPort = $db_port; $db->DBUser = $db_user; $db->DBPassword = $db_password; $db->DBPersistent = $db_persistent; $sql = " SELECT article_id, article_title, short_description FROM va_articles WHERE article_id IN (SELECT article_id FROM va_articles_assigned WHERE category_id = 43) AND status_id = 2 "; $db->query($sql); ?> <ul class="DetailTabs"><li class="tab tabActive"><a id="desc_a_tab" href="#" class="tab tabActive">Questions on Ordering, Shipping and Returns</a></li><li class="tab" id="reviews_td_tab"><a href="#" class="tab">Questions on Stenciling and Paint</a></li></ul> <div style="display: none;" id="faqData2"> <?php while ($db->next_record()) { echo '<div class="accordionButton" name="' . $db->f("article_id") . '">' . $db->f("article_title") . '</div> <div class="accordionContent" style="display: none;">' . $db->f("short_description") . '</div>'; } ?> </div> <?php $sql = " SELECT article_id, article_title, short_description FROM va_articles WHERE article_id IN (SELECT article_id FROM va_articles_assigned WHERE category_id = 42) AND status_id = 2 "; $db->query($sql); ?> <div style="display: none;" id="faqData">
$product_search = true; if (strlen($where)) { $where .= " AND "; } $where .= " (oi.item_name LIKE '%" . $db->tosql($r->get_value("s_kw"), TEXT, false) . "%'"; $where .= " OR oi.item_properties LIKE '%" . $db->tosql($r->get_value("s_kw"), TEXT, false) . "%'"; $where .= " OR ois.serial_number=" . $db->tosql($r->get_value("s_kw"), TEXT); $where .= " OR osa.generation_key=" . $db->tosql($r->get_value("s_kw"), TEXT); $where .= " OR osa.activation_key=" . $db->tosql($r->get_value("s_kw"), TEXT); $where .= " OR o.shipping_type_desc LIKE '%" . $db->tosql($r->get_value("s_kw"), TEXT, false) . "%')"; } //Customization by Vital if (!$r->is_empty("s_coupon")) { //get coupon id $sql_cc = "SELECT coupon_id FROM va_coupons WHERE coupon_code=" . $db->tosql($r->get_value("s_coupon"), TEXT); $dbp->query($sql_cc); $coupon_id = $dbp->next_record() ? $dbp->f("coupon_id") : "00000000"; $product_search = true; if (strlen($where)) { $where .= " AND "; } $where .= " ( ( o.order_id IN (SELECT order_id FROM va_orders_coupons WHERE coupon_code=" . $db->tosql($r->get_value("s_coupon"), TEXT) . ") ) OR ( oi.order_id IN ( SELECT order_id FROM va_orders_items WHERE " . $coupon_id . " IN (coupons_ids) ) ) )"; } $s_sku = ""; if (!$r->is_empty("s_sku")) { $product_search = true; $s_sku = str_replace(",", " ", $r->get_value("s_sku")); $s_sku = str_replace("'", "", $s_sku); $s_sku = preg_replace('!\\s+!', ' ', $s_sku); $SKUs = explode(" ", $s_sku); $SKUsFinal = array();
$sql .= " price,quantity"; $sql .= " FROM " . $table_prefix . "orders_items WHERE order_id=" . $db->tosql($order_id, INTEGER); $db->query($sql); while ($db->next_record()) { $google_item_id = $db->f("item_id"); $google_item_name = $db->f("item_name"); //$google_sku_code = $db->f("manufacturer_code"); //if (!$google_sku_code) { $google_sku_code = $db->f("item_code"); //} $google_price = $db->f("price"); $google_quantity = $db->f("quantity"); $google_category = ""; $count = 0; $sql = "SELECT c.category_name FROM " . $table_prefix . "items_categories ic, " . $table_prefix . "categories c WHERE ic.category_id=c.category_id AND ic.item_id=" . $dbh->tosql($google_item_id, INTEGER); $dbh->query($sql); while ($dbh->next_record()) { if ($count > 0) { $google_category .= " / "; } $count++; $google_category .= $dbh->f("category_name"); } $t->set_var("google_sku_code", str_replace("\"", "\\\"", htmlspecialchars($google_sku_code))); $t->set_var("google_item_name", str_replace(array("\"", "'"), array("\\\"", "\\'"), htmlspecialchars($google_item_name))); $t->set_var("google_price", $google_price); $t->set_var("google_quantity", $google_quantity); $t->set_var("google_category", str_replace(array("\"", "'"), array("\\\"", ""), htmlspecialchars($google_category))); $t->sparse("google_items", true); } $t->sparse("google_trans", true);
$parsed_url = parse_url($item_url); if (isset($parsed_url['query'])) { $query_symbol = '&'; } else { $query_symbol = '?'; } foreach ($languages as $language_code) { $language_item_url = $item_url . $query_symbol . 'language_code=' . $language_code; xml_add_url($language_item_url, $date_modified); } } if ($show_manual_articles) { $sql = " SELECT article_id, friendly_url, date_added, date_modified "; $sql .= " FROM " . $table_prefix . "manuals_articles "; $sql .= " WHERE manual_id=" . $dbp->tosql($manual_id, INTEGER); $dbm->query($sql); while ($dbm->next_record()) { if ($dbm->f("friendly_url") && $friendly_urls) { $item_url = $settings["site_url"] . $dbm->f("friendly_url") . $friendly_extension; } else { $item_url = $settings["site_url"] . "manuals_article_details.php?article_id=" . $dbm->f('article_id'); } $date_modified = ''; if ($dbp->f("date_modified")) { $date_modified = $dbm->f("date_modified", DATETIME); } elseif ($dbp->f("date_added")) { $date_modified = $dbm->f("date_added", DATETIME); } if (is_array($date_modified)) { $date_modified = va_date($datetime_loc_format, $date_modified); } else {
function sync_wishlist($user_id) { if (isset($_COOKIE['wishlist_user_id']) && is_numeric($_COOKIE['wishlist_user_id'])) { global $db, $table_prefix; $dba = new VA_SQL(); $dba->DBType = $db->DBType; $dba->DBDatabase = $db->DBDatabase; $dba->DBUser = $db->DBUser; $dba->DBPassword = $db->DBPassword; $dba->DBHost = $db->DBHost; $dba->DBPort = $db->DBPort; $dba->DBPersistent = $db->DBPersistent; // 1st sync step: add cookie wishlist items to user wishlist items by updating the user_id $sql = "UPDATE " . $table_prefix . "saved_items SET user_id=" . $db->tosql($user_id, INTEGER) . " WHERE user_id=" . $db->tosql($_COOKIE['wishlist_user_id'], INTEGER) . " AND item_id NOT IN (SELECT item_id FROM (SELECT DISTINCT item_id FROM va_saved_items WHERE user_id = " . $db->tosql($user_id, INTEGER) . ") AS tmptable)"; $dba->query($sql); // 2nd sync step: get and load items to the cookie wishlist $sql = "SELECT DISTINCT item_id, item_name, quantity, price, date_added FROM " . $table_prefix . "saved_items WHERE user_id=" . $db->tosql($user_id, INTEGER) . " AND item_id NOT IN (SELECT item_id FROM (SELECT DISTINCT item_id FROM va_saved_items WHERE user_id = " . $db->tosql($_COOKIE['wishlist_user_id'], INTEGER) . ") AS tmptable)"; $dba->query($sql); if ($dba->next_record()) { $wishlist_item_values = "(NULL, 1, '" . $dba->f("item_id") . "', 0, '" . $dba->tosql($_COOKIE['wishlist_user_id'], INTEGER) . "', '1', '" . $dba->f("item_name") . "', '" . $dba->f("quantity") . "', 0, '" . $dba->f("price") . "', TIMESTAMP('" . $dba->f("date_added") . "'))"; while ($dba->next_record()) { $wishlist_item_values .= ",(NULL, 1, '" . $dba->f("item_id") . "', 0, '" . $dba->tosql($_COOKIE['wishlist_user_id'], INTEGER) . "', '1', '" . $dba->f("item_name") . "', '" . $dba->f("quantity") . "', 0, '" . $dba->f("price") . "', TIMESTAMP('" . $dba->f("date_added") . "'))"; } $sql = "INSERT INTO `va_saved_items` (`cart_item_id`, `site_id`, `item_id`, `cart_id`, `user_id`, `type_id`, `item_name`, `quantity`, `quantity_bought`, `price`, `date_added`) VALUES " . $wishlist_item_values; $dba->query($sql); } } }