Exemple #1
0
             if (tep_not_null($products[$field])) {
                 $result = tep_get_translation($products[$field]);
                 ${$field} = $result['translation'];
                 if (tep_not_null($HTTP_GET_VARS['products_id'])) {
                     echo $result['page'];
                     die;
                 }
             } else {
                 ${$field} = '';
             }
         }
         $products_text = $products_name;
         $products_model = $products['products_model'];
         $authors_name = tep_transliterate($products['authors_name']);
         $manufacturers_name = tep_transliterate($products['manufacturers_name']);
         $series_name = tep_transliterate($products['series_name']);
         if (tep_not_null($products_model)) {
             $products_text .= ' ISBN ' . $products_model;
         }
         if (strlen($authors_name) > 2) {
             $products_text .= ' by ' . $authors_name;
         }
         //		  if (strlen($manufacturers_name) > 2) $products_text .= ' publisher ' . $manufacturers_name;
         //		  if (strlen($series_name) > 2) $products_text .= ' serie ' . $series_name;
         $products_text = strip_tags(strtolower(html_entity_decode($products_text)));
         $products_text = str_replace(array('«', '»', '+', '"', '/', '.', ',', '(', ')', '{', '}', '[', ']', '!', '?', '*', ';', '\'', '—', '_', ' - ', ':', '#', '\\', '|', '`', '~', '$', '^'), ' ', $products_text);
         $products_text = trim(preg_replace('/\\s+/', ' ', $products_text));
         $sql = "insert ignore into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, products_name, products_description, products_text, language_id) values ('" . (int) $products_id . "', '" . tep_db_input($products_name) . "', '" . tep_db_input($products_description) . "', ' " . tep_db_input($products_text) . " ', '1')";
         tep_db_query($sql);
     }
 }
function tep_get_full_product_info($products_id)
{
    global $languages_id, $all_categories, $currency, $currencies, $HTTP_GET_VARS, $categories_audio, $for, $customer_discount;
    $products = tep_db_query_fetch_array("SELECT * FROM " . TABLE_PRODUCTS . " WHERE products_id = '" . (int) $products_id . "'");
    if (DEFAULT_LANGUAGE_ID == $languages_id) {
        $product_info = tep_db_query_fetch_array("SELECT * FROM " . TABLE_PRODUCTS_INFO . " WHERE products_id = '" . (int) $products['products_id'] . "'");
        $product_info = array_merge($product_info, $products);
        $product_info['products_url'] = HTTP_SERVER . $product_info['products_url'];
    } else {
        //Добавление перевода
        $product_info_query = tep_db_query("\n\t\t\tSELECT products_name, \n\t\t\tproducts_description \n\t\t\tFROM " . TABLE_PRODUCTS_DESCRIPTION . " \n\t\t\tWHERE products_id = '" . (int) $products['products_id'] . "' \n\t\t\tAND language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        $product_info = tep_db_fetch_array($product_info_query);
        if (DEFAULT_LANGUAGE_ID == 1) {
            $product_ru_info = tep_db_query_fetch_array("\n\t\t\t\tSELECT products_name, \n\t\t\t\tproducts_description \n\t\t\t\tFROM " . TABLE_PRODUCTS_DESCRIPTION . " \n\t\t\t\tWHERE products_id = '" . (int) $products['products_id'] . "' \n\t\t\t\tAND language_id = '" . (int) $languages_id . "'");
            $product_ru_name = tep_transliterate($product_ru_info['products_name']);
            if ($product_info['products_name'] != $product_ru_info['products_name'] && $product_info['products_name'] != $product_ru_name) {
                $product_info['products_name'] .= (tep_not_null($product_info['products_name']) ? ' / ' : '') . $product_ru_name;
            }
        }
        $author_info = tep_db_query_fetch_array("\n\t\t\t\tSELECT authors_name \n\t\t\t\tFROM " . TABLE_AUTHORS . " \n\t\t\t\tWHERE authors_id = '" . (int) $products['authors_id'] . "' \n\t\t\t\tAND language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        if (!is_array($author_info)) {
            $author_info = array();
        }
        $serie_info = tep_db_query_fetch_array("\n\t\t\t\tSELECT series_name \n\t\t\t\tFROM " . TABLE_SERIES . " \n\t\t\t\tWHERE series_id = '" . (int) $products['series_id'] . "' \n\t\t\t\tAND language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        if (!is_array($serie_info)) {
            $serie_info = array();
        }
        $manufacturer_info = tep_db_query_fetch_array("\n\t\t\t\tSELECT manufacturers_name \n\t\t\t\tFROM " . TABLE_MANUFACTURERS_INFO . " \n\t\t\t\tWHERE manufacturers_id = '" . (int) $products['manufacturers_id'] . "' \n\t\t\t\tAND languages_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        if (!is_array($manufacturer_info)) {
            $manufacturer_info = array();
        }
        $product_info['products_width'] = '';
        $product_info['products_height'] = '';
        $product_info['products_width_height_measure'] = '';
        $product_format_info = tep_db_query_fetch_array("\n\t\t\t\tSELECT products_formats_name \n\t\t\t\tFROM " . TABLE_PRODUCTS_FORMATS . " \n\t\t\t\tWHERE products_formats_id = '" . (int) $products['products_formats_id'] . "'");
        if (!is_array($product_format_info)) {
            $product_format_info = array();
        }
        if (tep_not_null($product_format_info['products_formats_name'])) {
            $product_format = $product_format_info['products_formats_name'];
            list($product_format) = explode(' ', $product_format);
            list($product_format) = explode('/', $product_format);
            if (preg_match('/^(\\d+)x(\\d+)$/i', $product_format, $regs)) {
                $product_info['products_width'] = $regs[1];
                $product_info['products_height'] = $regs[1];
                $product_info['products_width_height_measure'] = 'mm';
            }
        }
        $product_cover_info = tep_db_query_fetch_array("\n\t\t\t\tSELECT products_covers_name \n\t\t\t\tFROM " . TABLE_PRODUCTS_COVERS . " \n\t\t\t\tWHERE products_covers_id = '" . (int) $products['products_covers_id'] . "' \n\t\t\t\tAND language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        if (!is_array($product_cover_info)) {
            $product_cover_info = array();
        }
        $product_type_info = tep_db_query_fetch_array("\n\t\t\t\tSELECT products_types_name \n\t\t\t\tFROM " . TABLE_PRODUCTS_TYPES . " \n\t\t\t\tWHERE products_types_id = '" . (int) $products['products_types_id'] . "' \n\t\t\t\tAND language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        if (!is_array($product_type_info)) {
            $product_type_info = array();
        }
        $category_info = tep_db_query_fetch_array("\n\t\t\t\tSELECT categories_id \n\t\t\t\tFROM " . TABLE_PRODUCTS_TO_CATEGORIES . " \n\t\t\t\tWHERE products_id = '" . (int) $products['products_id'] . "' \n\t\t\t\tORDER BY categories_id DESC \n\t\t\t\tLIMIT 1");
        if (!is_array($category_info)) {
            $category_info = array();
        }
        $product_info = array_merge($product_info, $products, $author_info, $serie_info, $manufacturer_info, $product_format_info, $product_cover_info, $category_info);
        $product_info['products_url'] = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_info['products_id'], 'NONSSL', false);
    }
    if ($customer_discount['type'] == 'purchase' && $products['products_purchase_cost'] > 0) {
        $product_info['products_price'] = $products['products_purchase_cost'] * (1 + $customer_discount['value'] / 100);
    }
    if (mb_strpos($product_info['products_description'], '<table', 0, 'CP1251') !== false) {
        $product_info['products_description'] = mb_substr($product_info['products_description'], 0, mb_strpos($product_info['products_description'], '<table', 0, 'CP1251'), 'CP1251');
    }
    $short_description = trim(preg_replace('/\\s+/', ' ', preg_replace('/<\\/?[^>]+>/', ' ', $product_info['products_description'])));
    $product_info['products_description'] = $short_description;
    $product_info['products_description_short'] = $short_description;
    if (!in_array($currency, array('RUR', 'EUR', 'USD', 'UAH'))) {
        $product_info['products_currency'] = 'RUR';
        $product_info['products_price'] = str_replace(',', '.', round($product_info['products_price'], $currencies->get_decimal_places($product_info['products_currency'])));
    } else {
        $product_info['products_currency'] = str_replace('RUB', 'RUR', DEFAULT_CURRENCY);
        $product_info['products_price'] = str_replace(',', '.', round($product_info['products_price'] * $currencies->get_value($product_info['products_currency']), $currencies->get_decimal_places($product_info['products_currency'])));
    }
    if (tep_not_null($product_info['products_image'])) {
        $product_info['products_image_big'] = 'http://85.236.24.26/big/' . $product_info['products_image'];
        $product_info['products_image'] = 'http://85.236.24.26/thumbs/' . $product_info['products_image'];
    }
    $product_info['products_buy'] = tep_href_link(FILENAME_SHOPPING_CART, 'action=buy_now&product_id=' . $product_info['products_id'], 'NONSSL', false);
    $product_info['products_quantity'] = '';
    $product_info['is_audio'] = false;
    if (in_array($product_info['categories_id'], $categories_audio)) {
        $product_info['is_audio'] = true;
    }
    if (ALLOW_SHOW_AVAILABLE_IN == 'true' && tep_not_null($HTTP_GET_VARS['limit']) || SHOP_ID == 4) {
        //пусто
    } elseif ($product_info['products_listing_status'] == 1) {
        $product_info['products_available_in'] = 1;
    } else {
        $product_info['products_available_in'] = 10;
    }
    reset($product_info);
    while (list($k, $v) = each($product_info)) {
        $v = str_replace($from1, $to, str_replace($from, $to, $v));
        if (in_array($k, array('products_name', 'products_description'))) {
            $v = preg_replace('/\\s{2,}/', ' ', preg_replace('/[^_\\/\\w\\d\\#\\&(\\)\\-\\[\\]\\.",;]/', ' ', $v));
        }
        $product_info[$k] = htmlspecialchars(strip_tags(tep_html_entity_decode($v)), ENT_QUOTES);
    }
    return $product_info;
}
 $check = tep_db_fetch_array($check_query);
 if ($check['total'] == 0) {
     reset($fields);
     $products_name = '';
     $products_description = '';
     while (list(, $field) = each($fields)) {
         if (tep_not_null($products[$field])) {
             ${$field} = tep_get_translation($products[$field]);
         } else {
             ${$field} = '';
         }
     }
     $products_text = $products_name;
     $products_model = $products['products_model'];
     $authors_name = tep_transliterate($products['authors_name']);
     $manufacturers_name = tep_transliterate($products['manufacturers_name']);
     $product_serie_info_query = tep_db_query("select series_id from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'");
     $product_serie_info = tep_db_fetch_array($product_serie_info_query);
     $serie_info_query = tep_db_query("select series_name from " . TABLE_SERIES . " where series_id = '" . (int) $product_serie_info['series_id'] . "' and language_id = '1'");
     $serie_info = tep_db_fetch_array($serie_info_query);
     $series_name = $serie_info['series_name'];
     if (tep_not_null($products_model)) {
         $products_text .= ' ISBN ' . $products_model;
     }
     if (strlen($authors_name) > 2) {
         $products_text .= ' by ' . $authors_name;
     }
     if (strlen($manufacturers_name) > 2) {
         $products_text .= ' publisher ' . $manufacturers_name;
     }
     if (strlen($series_name) > 2) {
     }
 }
 $serie_info_query = tep_db_query("select series_name from " . TABLE_SERIES . " where series_id = '" . (int) $product_info['series_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
 $serie_info = tep_db_fetch_array($serie_info_query);
 if (!is_array($serie_info)) {
     $serie_info = array();
 }
 $author_info_query = tep_db_query("select authors_name from authors where authors_id = '" . (int) $product_info['authors_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
 $author_info = tep_db_fetch_array($author_info_query);
 if (!is_array($author_info)) {
     $author_info = array();
 }
 $product_info = array_merge($product_info, $product_description_info, $product_description_en_info, $manufacturer_info, $serie_info, $author_info);
 if (DEFAULT_LANGUAGE_ID == 1) {
     $product_info['products_name'] .= ' / ' . (tep_not_null($product_info['products_en_name']) ? $product_info['products_en_name'] : tep_transliterate($product_info['products_name']));
     $product_info['products_short_description'] = tep_not_null($product_info['products_en_short_description']) ? $product_info['products_en_short_description'] : tep_transliterate($product_info['products_short_description']);
 }
 reset($product_info);
 while (list($k, $v) = each($product_info)) {
     while (strpos($v, "\\'") !== false) {
         $v = str_replace("\\'", "'", $v);
     }
     while (strpos($v, '\\"') !== false) {
         $v = str_replace('\\"', '"', $v);
     }
     $product_info[$k] = $v;
 }
 $special_text = '';
 if (basename(PHP_SELF) != FILENAME_SHOPPING_CART) {
     $special_types_query = tep_db_query("select distinct specials_types_id from " . TABLE_SPECIALS . " where products_id = '" . (int) $product_info['products_id'] . "' and specials_date_added >= '" . tep_db_input($min_specials_date_added) . " 00:00:00'");
     while ($special_types = tep_db_fetch_array($special_types_query)) {
function tep_get_full_product_info($products_id, $pricelist_type = 'csv')
{
    global $languages_id, $all_categories, $currency, $currencies, $HTTP_GET_VARS, $categories_audio, $for, $customer_discount;
    $products_query = tep_db_query("select * from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'");
    $products = tep_db_fetch_array($products_query);
    if (DEFAULT_LANGUAGE_ID == $languages_id) {
        $product_info_query = tep_db_query("select * from " . TABLE_PRODUCTS_INFO . " where products_id = '" . (int) $products['products_id'] . "'");
        $product_info = tep_db_fetch_array($product_info_query);
        $product_info = array_merge($product_info, $products);
        $product_info['products_url'] = HTTP_SERVER . $product_info['products_url'];
    } else {
        $product_info_query = tep_db_query("select products_name, products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int) $products['products_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        $product_info = tep_db_fetch_array($product_info_query);
        if (DEFAULT_LANGUAGE_ID == 1) {
            $product_ru_info_query = tep_db_query("select products_name, products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int) $products['products_id'] . "' and language_id = '" . (int) $languages_id . "'");
            $product_ru_info = tep_db_fetch_array($product_ru_info_query);
            $product_ru_name = tep_transliterate($product_ru_info['products_name']);
            if ($product_info['products_name'] != $product_ru_info['products_name'] && $product_info['products_name'] != $product_ru_name) {
                $product_info['products_name'] .= (tep_not_null($product_info['products_name']) ? ' / ' : '') . $product_ru_name;
            }
        }
        $author_info_query = tep_db_query("select authors_name from " . TABLE_AUTHORS . " where authors_id = '" . (int) $products['authors_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        $author_info = tep_db_fetch_array($author_info_query);
        if (!is_array($author_info)) {
            $author_info = array();
        }
        $serie_info_query = tep_db_query("select series_name from " . TABLE_SERIES . " where series_id = '" . (int) $products['series_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        $serie_info = tep_db_fetch_array($serie_info_query);
        if (!is_array($serie_info)) {
            $serie_info = array();
        }
        $manufacturer_info_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int) $products['manufacturers_id'] . "' and languages_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        $manufacturer_info = tep_db_fetch_array($manufacturer_info_query);
        if (!is_array($manufacturer_info)) {
            $manufacturer_info = array();
        }
        $product_info['products_width'] = '';
        $product_info['products_height'] = '';
        $product_info['products_width_height_measure'] = '';
        $product_format_info_query = tep_db_query("select products_formats_name from " . TABLE_PRODUCTS_FORMATS . " where products_formats_id = '" . (int) $products['products_formats_id'] . "'");
        $product_format_info = tep_db_fetch_array($product_format_info_query);
        if (!is_array($product_format_info)) {
            $product_format_info = array();
        }
        if (tep_not_null($product_format_info['products_formats_name'])) {
            $product_format = $product_format_info['products_formats_name'];
            list($product_format) = explode(' ', $product_format);
            list($product_format) = explode('/', $product_format);
            if (preg_match('/^(\\d+)x(\\d+)$/i', $product_format, $regs)) {
                $product_info['products_width'] = $regs[1];
                $product_info['products_height'] = $regs[1];
                $product_info['products_width_height_measure'] = 'mm';
            }
        }
        $product_cover_info_query = tep_db_query("select products_covers_name from " . TABLE_PRODUCTS_COVERS . " where products_covers_id = '" . (int) $products['products_covers_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        $product_cover_info = tep_db_fetch_array($product_cover_info_query);
        if (!is_array($product_cover_info)) {
            $product_cover_info = array();
        }
        $product_type_info_query = tep_db_query("select products_types_name from " . TABLE_PRODUCTS_TYPES . " where products_types_id = '" . (int) $products['products_types_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
        $product_type_info = tep_db_fetch_array($product_type_info_query);
        if (!is_array($product_type_info)) {
            $product_type_info = array();
        }
        $category_info_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int) $products['products_id'] . "' order by categories_id desc limit 1");
        $category_info = tep_db_fetch_array($category_info_query);
        if (!is_array($category_info)) {
            $category_info = array();
        }
        $product_info = array_merge($product_info, $products, $author_info, $serie_info, $manufacturer_info, $product_format_info, $product_cover_info, $category_info);
        $product_info['products_url'] = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_info['products_id'], 'NONSSL', false);
    }
    if ($customer_discount['type'] == 'purchase' && $products['products_purchase_cost'] > 0) {
        $product_info['products_price'] = $products['products_purchase_cost'] * (1 + $customer_discount['value'] / 100);
    }
    if (mb_strpos($product_info['products_description'], '<table', 0, 'CP1251') !== false) {
        $product_info['products_description'] = mb_substr($product_info['products_description'], 0, mb_strpos($product_info['products_description'], '<table', 0, 'CP1251'), 'CP1251');
    }
    $short_description = trim(preg_replace('/\\s+/', ' ', preg_replace('/<\\/?[^>]+>/', ' ', $product_info['products_description'])));
    $product_info['products_description'] = $short_description;
    $product_info['products_description_short'] = $short_description;
    if ($pricelist_type == 'csv') {
        if ($for == 'shopmania' || $for == 'nur_kz') {
            if ($for == 'nur_kz') {
                $categories_delimiter = ' | ';
            } else {
                $categories_delimiter = ' > ';
            }
            if (!in_array($product_info['categories_id'], array_keys($all_categories))) {
                $parent_categories = array($product_info['categories_id']);
                tep_get_parents($parent_categories, $product_info['categories_id']);
                $parent_categories = array_reverse($parent_categories);
                $categories_names = array_map('tep_get_category_name', $parent_categories);
                $category_tree_string = implode($categories_delimiter, $categories_names);
                $all_categories[$category_info['categories_id']] = $category_tree_string;
            } else {
                $category_tree_string = $all_categories[$category_info['categories_id']];
            }
            //		list($product_info['categories_name']) = explode(' > ', $category_tree_string);
            $product_info['categories_name'] = $product_info['products_types_name'] . $categories_delimiter . $category_tree_string;
        }
        if ($for == 'amazon_uk') {
            $product_info['products_currency'] = 'GBP';
        } else {
            $product_info['products_currency'] = DEFAULT_CURRENCY;
        }
        if (strpos($for, 'amazon') !== false) {
            $product_info['products_price'] = str_replace(',', '.', sprintf("%01.2f", round($product_info['products_cost'] * 1.8 * $currencies->get_value($product_info['products_currency']), 1) + 1.2));
            $product_info['products_weight'] = str_replace(',', '.', round($product_info['products_weight'], 2));
            $product_info['products_model'] = preg_replace('/[^\\dX]/', '', $product_info['products_model']);
            if (strlen($product_info['products_name']) > 500) {
                $product_info['products_name'] = substr($product_info['products_name'], 0, 500);
            }
            if ($product_info['authors_name'] == '') {
                $product_info['authors_name'] = 'unknown';
            }
        } elseif ($for == 'ebay') {
            if (tep_not_null($product_info['authors_name'])) {
                $product_info['products_name'] .= ' by ' . $product_info['authors_name'];
            }
            $product_info['products_price'] = str_replace(',', '.', round($product_info['products_price'] * $currencies->get_value($product_info['products_currency']), $currencies->get_decimal_places($product_info['products_currency'])));
            $product_info['products_model'] = preg_replace('/[^\\dX]/', '', $product_info['products_model']);
        } else {
            $product_info['products_price'] = str_replace('.', ',', round($product_info['products_price'] * $currencies->get_value($product_info['products_currency']), $currencies->get_decimal_places($product_info['products_currency'])));
        }
    } else {
        if (!in_array($currency, array('RUR', 'EUR', 'USD', 'UAH'))) {
            $product_info['products_currency'] = 'RUR';
            $product_info['products_price'] = str_replace(',', '.', round($product_info['products_price'], $currencies->get_decimal_places($product_info['products_currency'])));
        } else {
            $product_info['products_currency'] = str_replace('RUB', 'RUR', DEFAULT_CURRENCY);
            $product_info['products_price'] = str_replace(',', '.', round($product_info['products_price'] * $currencies->get_value($product_info['products_currency']), $currencies->get_decimal_places($product_info['products_currency'])));
        }
    }
    if (tep_not_null($product_info['products_image'])) {
        //	  $product_info['products_image_big'] = tep_href_link(DIR_WS_IMAGES . 'big/' . $product_info['products_image'], '', 'NONSSL', false);
        $product_info['products_image_big'] = 'http://85.236.24.26/big/' . $product_info['products_image'];
        if (strpos($for, 'amazon') !== false || $for == 'ebay') {
            $product_info['products_image'] = $product_info['products_image_big'];
        } else {
            //		$product_info['products_image'] = tep_href_link(DIR_WS_IMAGES . 'thumbs/' . $product_info['products_image'], '', 'NONSSL', false);
            $product_info['products_image'] = 'http://85.236.24.26/thumbs/' . $product_info['products_image'];
            //		$product_info['products_image'] = str_replace(HTTP_SERVER, 'http://images.setbook.ru', $product_info['products_image']);
        }
    }
    $product_info['products_buy'] = tep_href_link(FILENAME_SHOPPING_CART, 'action=buy_now&product_id=' . $product_info['products_id'], 'NONSSL', false);
    $product_info['products_quantity'] = '';
    $product_info['is_audio'] = false;
    if (in_array($product_info['categories_id'], $categories_audio)) {
        $product_info['is_audio'] = true;
    }
    if (ALLOW_SHOW_AVAILABLE_IN == 'true' && tep_not_null($HTTP_GET_VARS['limit']) || SHOP_ID == 4) {
    } elseif ($product_info['products_listing_status'] == 1) {
        $product_info['products_available_in'] = 1;
    } else {
        $product_info['products_available_in'] = 10;
    }
    reset($product_info);
    while (list($k, $v) = each($product_info)) {
        $v = str_replace($from1, $to, str_replace($from, $to, $v));
        if (in_array($k, array('products_name', 'products_description'))) {
            $v = preg_replace('/\\s{2,}/', ' ', preg_replace('/[^_\\/\\w\\d\\#\\&(\\)\\-\\[\\]\\.",;]/', ' ', $v));
        }
        if ($pricelist_type == 'csv') {
            $product_info[$k] = strip_tags(tep_html_entity_decode($v));
        } else {
            $product_info[$k] = htmlspecialchars(strip_tags(tep_html_entity_decode($v)), ENT_QUOTES);
        }
    }
    //	print_r($product_info); die;
    return $product_info;
}
Exemple #6
0
        $authors_name = tep_transliterate($authors['authors_name']);
        $check_query = tep_db_query("select count(*) as total from " . TABLE_AUTHORS . " where authors_id = '" . (int) $authors_id . "' and language_id = '" . (int) $lang_id . "'");
        $check = tep_db_fetch_array($check_query);
        if ($check['total'] == 0) {
            $authors_description = '';
            reset($fields);
            while (list(, $field) = each($fields)) {
                if (tep_not_null($authors[$field])) {
                    ${$field} = tep_get_translation($authors[$field]);
                } else {
                    ${$field} = '';
                }
            }
            $letter_query = tep_db_query("select authors_letter from " . TABLE_AUTHORS . " where authors_id = '" . (int) $authors_id . "' and language_id = '" . (int) $languages_id . "'");
            $letter = tep_db_fetch_array($letter_query);
            $sql = "replace into " . TABLE_AUTHORS . " (authors_id, authors_code, authors_letter, authors_name, authors_description, language_id, authors_image, authors_status, authors_path, sort_order, date_added, last_modified) select authors_id, authors_code, '" . tep_db_input(tep_transliterate($letter['authors_letter'])) . "', '" . tep_db_input($authors_name) . "', '" . tep_db_input($authors_description) . "', '" . (int) $lang_id . "', authors_image, authors_status, authors_path, sort_order, date_added, last_modified from " . TABLE_AUTHORS . " where authors_id = '" . (int) $authors_id . "' and language_id = '" . (int) $languages_id . "'";
            tep_db_query($sql);
        }
        $content_type = 'author';
        $content_id = $authors_id;
        $check_query = tep_db_query("select count(*) as total from " . TABLE_METATAGS . " where language_id = '" . (int) $lang_id . "' and content_type = '" . tep_db_input($content_type) . "' and content_id = '" . (int) $content_id . "'");
        $check = tep_db_fetch_array($check_query);
        if ($check['total'] == 0) {
            $metatags_page_title = $common_array[$lang_code]['authors'] . '. ' . $authors_name . (substr($authors_name, -1) != '.' ? '.' : '') . ' ' . $common_array[$lang_code]['bookshop'] . ' Setbook.';
            $metatags_title = $authors_name;
            $metatags_keywords = $authors_name;
            $metatags_description = $common_array[$lang_code]['authors'] . '. ' . $authors_name . (substr($authors_name, -1) != '.' ? '.' : '');
            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) $lang_id . "', '" . tep_db_input($content_type) . "', '" . (int) $content_id . "')");
        }
    }
}
 function get_products()
 {
     global $languages_id;
     $this->get_customer_discount();
     if (!is_array($this->contents)) {
         return false;
     }
     $max_available_in = 0;
     $products_array = array();
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         $products_query = tep_db_query("select * from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'");
         if ($products = tep_db_fetch_array($products_query)) {
             $product_description_info_query = tep_db_query("select products_name, products_description, manufacturers_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int) $products_id . "' and language_id = '" . (int) $languages_id . "'");
             $product_description_info = tep_db_fetch_array($product_description_info_query);
             if (!is_array($product_description_info)) {
                 $product_description_info = array();
             }
             if (DEFAULT_LANGUAGE_ID == 1) {
                 $product_description_en_info_query = tep_db_query("select products_name, products_description, manufacturers_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int) $products_id . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "' and products_name <> ''");
                 $product_description_en_info = tep_db_fetch_array($product_description_en_info_query);
                 if (!is_array($product_description_en_info)) {
                     $product_description_en_info = array();
                 }
                 if (tep_not_null($product_description_en_info['products_name'])) {
                     $product_description_info['products_name'] = $product_description_en_info['products_name'];
                 } else {
                     $product_description_info['products_name'] = tep_transliterate($product_description_info['products_name']);
                 }
                 if (tep_not_null($product_description_en_info['products_description'])) {
                     $product_description_info['products_description'] = $product_description_en_info['products_description'];
                 } else {
                     $product_description_info['products_description'] = tep_transliterate($product_description_info['products_description']);
                 }
             }
             $manufacturers_name = $product_description_info['manufacturers_name'];
             if ($products['products_types_id'] == 1) {
                 $manufacturer_info_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int) $products['manufacturers_id'] . "' and languages_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
                 $manufacturer_info = tep_db_fetch_array($manufacturer_info_query);
                 $manufacturers_name = $manufacturer_info['manufacturers_name'];
             }
             $author_info_query = tep_db_query("select authors_name from " . TABLE_AUTHORS . " where authors_id = '" . (int) $products['authors_id'] . "' and language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
             $author_info = tep_db_fetch_array($author_info_query);
             if (!is_array($author_info)) {
                 $author_info = array();
             }
             $products = array_merge($products, $product_description_info, $author_info);
             $prid = $products['products_id'];
             $products_price = $products['products_price'];
             $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int) $prid . "' and status = '1' and specials_new_products_price > '0' order by specials_date_added desc limit 1");
             if (tep_db_num_rows($specials_query)) {
                 $specials = tep_db_fetch_array($specials_query);
                 $products_price = $specials['specials_new_products_price'];
             } elseif ($this->customer_discount['type'] == 'purchase' && $products['products_purchase_cost'] > 0) {
                 $products_price = $products['products_purchase_cost'] * (1 + $this->customer_discount['value'] / 100);
             }
             $products_tax = tep_get_tax_rate($products['products_tax_class_id']);
             $products_array[] = array('id' => $products_id, 'name' => (tep_not_null($products['authors_name']) ? $products['authors_name'] . ': ' : '') . $products['products_name'], 'description' => $products['products_description'], 'model' => $products['products_model'], 'code' => $products['products_code'], 'image' => $products['products_image'], 'manufacturer' => $manufacturers_name, 'year' => $products['products_year'], 'type' => $products['products_types_id'], 'periodicity' => $products['products_periodicity'], 'periodicity_min' => $products['products_periodicity_min'], 'available_in' => $products['products_available_in'], 'pack' => $products['products_pack'], 'price' => $products_price, 'filename' => $products['products_filename'], 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'warranty' => $products['products_warranty'], 'final_price' => tep_add_tax($products_price, $products_tax), 'tax_class_id' => $products['products_tax_class_id']);
             if ($products['products_available_in'] > 0 && $products['products_available_in'] > $max_available_in) {
                 $max_available_in = $products['products_available_in'];
             }
         }
     }
     $this->info['delivery_transfer'] = $max_available_in;
     return $products_array;
 }