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; }
function tep_upload_order($order_id, $delimiter = ',', $upload_dir = '') { if (empty($upload_dir)) { $upload_dir = UPLOAD_DIR . 'orders1/'; } // $order_info_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); // if (tep_db_num_rows($order_info_query) < 1) return false; $order_info = tep_db_fetch_array($order_info_query); $insert_id = $order_info['orders_id']; $insert_id = $order_id; $order = new order($insert_id); $shop_info_query = tep_db_query("select shops_url, shops_ssl, shops_prefix, shops_database from " . TABLE_SHOPS . " where shops_id = '" . (int) $order->info['shops_id'] . "'"); $shop_info = tep_db_fetch_array($shop_info_query); $domain_zone = $shop_info['shops_prefix']; $payment_modules = tep_get_payment_modules($order->info['shops_id']); $shipping_modules = tep_get_shipping_modules($order->info['shops_id']); $order_file = $upload_dir . $domain_zone . $insert_id . '.csv'; if (!file_exists($order_file)) { $fp = fopen($order_file, 'w'); $order_history_link = ($order->info['enabled_ssl'] == '1' && tep_not_null($shop_info['shops_ssl']) ? $shop_info['shops_ssl'] : $shop_info['shops_url']) . '/account_history_info.php?order_id=' . $insert_id; $order_total_sum = 0; $order_shipping_sum = 0; $order_discount_sum = 0; reset($order->totals); while (list(, $order_total) = each($order->totals)) { if ($order_total['class'] == 'ot_total') { $order_total_sum = $order_total['value']; } elseif ($order_total['class'] == 'ot_shipping') { $order_shipping_sum = $order_total['value']; $order_shipping_title = $order_total['title']; } elseif (($order_total['class'] == 'ot_discount' || $order_total['class'] == 'ot_custom') && $order_total['value'] < 0) { $order_discount_sum = $order_total['value']; } } $order_payment_id = $order->info['payment_method_class']; if (empty($order_payment_id)) { reset($payment_modules); $payment_found = false; while (list($k, $v) = each($payment_modules)) { if (strpos($v, $order->info['payment_method']) !== false) { $order_payment_id = $k; break; } } if (empty($order_payment_id)) { $order_payment_id = $order->info['payment_method']; } } $order_shipping_id = $order->delivery['delivery_method_class']; if (empty($order_shipping_id)) { reset($shipping_modules); $shipping_found = false; while (list($k, $v) = each($shipping_modules)) { if (strpos($v, $order_shipping_title) !== false) { $order_shipping_id = $k; break; } } if (empty($order_shipping_id)) { $order_shipping_id = $order_shipping_title; } } $self_delivery_id = $order->delivery['delivery_self_address_id']; if (tep_not_null($order->delivery['delivery_self_address']) && (int) $self_delivery_id <= 0) { $shop_info_query = tep_db_query("select shops_database from " . TABLE_SHOPS . " where shops_id = '" . (int) $order->info['shops_id'] . "'"); $shop_info = tep_db_fetch_array($shop_info_query); tep_db_select_db($shop_info['shops_database']); $self_delivery_query = tep_db_query("select self_delivery_id, self_delivery_cost, self_delivery_free, entry_suburb as suburb, entry_city as city, entry_street_address as street_address, entry_telephone as telephone, self_delivery_description from " . TABLE_SELF_DELIVERY . " where 1 order by city, street_address"); while ($self_delivery = tep_db_fetch_array($self_delivery_query)) { $self_delivery_address = tep_address_format($order->delivery['format_id'], $self_delivery, 1, '', ', '); if (strpos($order->delivery['delivery_self_address'], $self_delivery_address) !== false) { $self_delivery_id = $self_delivery['self_delivery_id']; break; } } tep_db_select_db(DB_DATABASE); if ($self_delivery_id == 0) { $self_delivery_id = $order->info['self_delivery']; } } $date_purchased = preg_replace('/(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/', '$3.$2.$1 $4:$5:$6', $order->info['date_purchased']); $date_purchased = preg_replace('/\\s{2,}/', ' ', $date_purchased); $is_europe = ''; $europe_check_query = tep_db_query("select count(*) as total from setbook_eu." . TABLE_COUNTRIES . " where countries_name like '" . tep_db_input($order->delivery['country']) . "' or countries_ru_name like '" . tep_db_input($order->delivery['country']) . "' or countries_iso_code_2 like '" . tep_db_input($order->delivery['country']) . "' or countries_iso_code_3 like '" . tep_db_input($order->delivery['country']) . "'"); $europe_check = tep_db_fetch_array($europe_check_query); if ($europe_check['total'] > 0) { $is_europe = 'e'; } $order_delivery_country_code = ''; $country_code_info_query = tep_db_query("select countries_iso_code_2 from " . $shop_info['shops_database'] . "." . TABLE_COUNTRIES . " where countries_name = '" . tep_db_input($order->delivery['country']) . "' or countries_ru_name = '" . tep_db_input($order->delivery['country']) . "'"); $country_code_info = tep_db_fetch_array($country_code_info_query); $order_delivery_country_code = $country_code_info['countries_iso_code_2']; if ($order_delivery_country_code == '') { $order_delivery_country = strtolower($order->delivery['country']); $all_countries_file = UPLOAD_DIR . 'csv/all_countries.csv'; $fc = fopen($all_countries_file, 'r'); while ((list($country_name, $country_ru_name, $country_iso_code_2, $country_iso_code_3) = fgetcsv($fc, 40000, ";")) !== FALSE) { $country_name = strtolower($country_name); $country_ru_name = strtolower($country_ru_name); $country_iso_code_3 = strtolower($country_iso_code_3); if ($order_delivery_country == $country_name || $order_delivery_country == $country_ru_name || $order_delivery_country == $country_iso_code_3) { $order_delivery_country_code = $country_iso_code_2; break; } } fclose($fc); } if ($order_delivery_country_code == '') { $fc = fopen($all_countries_file, 'r'); while ((list($country_name, $country_ru_name, $country_iso_code_2, $country_iso_code_3) = fgetcsv($fc, 40000, ";")) !== FALSE) { $country_name = strtolower($country_name); $country_ru_name = strtolower($country_ru_name); if (strpos($country_name, $order_delivery_country) !== false || strpos($country_ru_name, $order_delivery_country) !== false || strpos($country_iso_code_3, $order_delivery_country) !== false) { $order_delivery_country_code = $country_iso_code_2; break; } } fclose($fc); } $common_data = array($insert_id, $date_purchased, $order->info['shops_id'], $order->customer['id'], $order->customer['email_address'], $order->delivery['name'], '', '', $order_payment_id, $order_shipping_id, str_replace(',', '.', $order_shipping_sum), $order->info['currency'], str_replace(',', '.', $order->info['currency_value']), tep_html_entity_decode($order->delivery['state']), tep_html_entity_decode($order->delivery['suburb']), tep_html_entity_decode($order->delivery['city']), $order->delivery['postcode'], tep_html_entity_decode($order->delivery['street_address']), $order->delivery['telephone'], tep_html_entity_decode($order->info['comments']), $self_delivery_id, $order_history_link, str_replace(',', '.', $order_total_sum), str_replace(',', '.', abs($order_discount_sum)), tep_html_entity_decode($order->customer['company']), $order->customer['company_inn'], $order->customer['company_kpp'], $order->customer['company_address_corporate'], $is_europe, $order->info['delivery_transfer_days'], $order->info['code'], $order->delivery['country'], tep_html_entity_decode($order_delivery_country_code), $order->customer['company_corporate']); fputcsvsafe($fp, $common_data, $delimiter); // tep_db_query("update " . TABLE_ORDERS . " set payment_method_class = '" . tep_db_input($order_payment_id) . "', delivery_method_class = '" . tep_db_input($order_shipping_id) . "', delivery_self_address_id = '" . (int)$self_delivery_id . "' where orders_id = '" . (int)$insert_id . "'"); reset($order->products); while (list(, $product) = each($order->products)) { $product_code = (int) str_replace('bbk', '', $product['code']); $common_data = array($product['type'], $product_code, $product['qty'], str_replace(',', '.', $product['final_price']), $product['id'], $product['seller_code'], $product['name'], tep_get_products_name($product['id']), $product['code'], $product['warranty']); fputcsvsafe($fp, $common_data, $delimiter); } fclose($fp); } }
function send_mail($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject, $html) { $from_email_address = trim(implode('', array_map('trim', explode("\n", $from_email_address)))); $from_email_name = trim(implode('', array_map('trim', explode("\n", $from_email_name)))); $text = tep_html_entity_decode($text); $html = $this->get_template_params(trim($html)); if ($this->debug) { echo $email_subject; echo $html; } if (tep_not_null($to_email_address)) { // Instantiate a new mail object $message = new email(); // Build the text version $text = strip_tags($html); $message->add_html($html, $text); // Send message $message->build_message(); if ($this->send) { $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject); } } }
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; }
} $products_name = ''; if (tep_not_null($product_info['authors_name'])) { $products_name .= $product_info['authors_name'] . ': '; } $products_name .= $product_info['products_name']; $products[$product_info['products_id']] = array('qty' => $products_qty, 'id' => $product_info['products_id'], 'name' => $products_name, 'model' => $product_info['products_model'], 'code' => $products_code, 'weight' => $product_info['products_weight'], 'type' => $products_type_id, 'tax' => 0, 'price' => $products_price, 'final_price' => $products_price, 'tracking_number' => $tracking_number); } } $email_text = ''; $temp_string = ''; reset($products); while (list($product_id, $product) = each($products)) { #проверяем на добавление новых товаров if (!in_array($product_id, array_keys($old_products))) { $temp_string .= sprintf(EMAIL_CRON_TEXT_PRODUCTS_ADDED, tep_html_entity_decode($product['name']), $product['qty']) . "\n"; $sql_queries[] = "insert into " . TABLE_ORDERS_PRODUCTS . " (orders_id, products_id, products_model, products_code, products_weight, products_name, products_price, final_price, products_quantity, products_year, products_types_id, manufacturers_name, tracking_number) select '" . (int) $update_order_id . "', products_id, products_model, products_code, products_weight, if (authors_name<>'', concat_ws(': ', authors_name, products_name), products_name), '" . tep_db_input($product['price']) . "', '" . tep_db_input($product['final_price']) . "', '" . (int) $product['qty'] . "', products_year, products_types_id, manufacturers_name, '" . tep_db_input($product['tracking_number']) . "' from " . TABLE_PRODUCTS_INFO . " where products_id = '" . (int) $product_id . "';\n"; $old_products[$product_id] = array('id' => $product_id, 'name' => $product['name'], 'qty' => $product['qty'], 'type' => $product['type'], 'price' => $product['price'], 'final_price' => $product['final_price'], 'tracking_number' => $product['tracking_number']); } } reset($old_products); while (list($product_id, $product) = each($old_products)) { // проверяем на удаление заказанных товаров if (!in_array($product_id, array_keys($products))) { $temp_string .= sprintf(EMAIL_CRON_TEXT_PRODUCTS_DELETED, $product['name']) . "\n"; $sql_queries[] = "delete from " . TABLE_ORDERS_PRODUCTS . " where products_id = '" . (int) $product_id . "' and orders_id = '" . (int) $update_order_id . "';\n"; unset($old_products[$product_id]); } elseif ($product['qty'] != $products[$product_id]['qty'] || $product['price'] != $products[$product_id]['price'] || $product['tracking_number'] != $products[$product_id]['tracking_number']) { // проверяем на изменение кол-ва/цены заказанных товаров if ($product['qty'] != $products[$product_id]['qty'] || $product['price'] != $products[$product_id]['price']) { $temp_string .= sprintf(EMAIL_CRON_TEXT_PRODUCTS_UPDATED, $product['name'], $products[$product_id]['qty']) . "\n";
if (SHOP_ID == 9) { $delivery_country_info_query = tep_db_query("select entry_country_id from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . (int) $sendto . "'"); $delivery_country_info = tep_db_fetch_array($delivery_country_info_query); $delivery_country_id = $delivery_country_info['entry_country_id']; $europe_country_check_query = tep_db_query("select count(*) as total from setbook_net." . TABLE_COUNTRIES . " where countries_id = '" . (int) $delivery_country_id . "'"); $europe_country_check = tep_db_fetch_array($europe_country_check_query); if ($europe_country_check['total'] > 0) { $is_europe = 'e'; } } tep_order_log($insert_id, 'Creating csv file for order'); $delimiter = ','; $date_purchased = preg_replace('/\\s+/', ' ', preg_replace('/(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/', '$3.$2.$1 $4:$5:$6', $order->info['date_purchased'])); $order_file = UPLOAD_DIR . 'temp_orders/' . SHOP_PREFIX . $insert_id . '.csv'; $fp = fopen($order_file, 'w'); $common_data = array($insert_id, $date_purchased, SHOP_ID, $is_dummy_account == true ? '0' : $customer_id, $order->customer['email_address'], $order->delivery['name'], '', '', $payment, $order_shipping_title, str_replace(',', '.', $order_shipping_sum), $order->info['currency'], str_replace(',', '.', $order->info['currency_value']), tep_html_entity_decode($order->delivery['state']), tep_html_entity_decode($order->delivery['suburb']), tep_html_entity_decode($order->delivery['city']), $order->delivery['postcode'], tep_html_entity_decode($order->delivery['street_address']), $order->delivery['telephone'], tep_html_entity_decode($order->info['comments']), $self_delivery_id, tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false), str_replace(',', '.', $order_total_sum), str_replace(',', '.', abs($order_discount_sum)), tep_not_null($order->customer['company_full']) ? tep_html_entity_decode($order->customer['company_full']) : tep_html_entity_decode($order->customer['company']), $order->customer['company_inn'], $order->customer['company_kpp'], $order->customer['company_address_corporate'], $is_europe, $order_delivery_transfer, $order->info['code'], tep_html_entity_decode($order->delivery['country']), tep_html_entity_decode($order_delivery_country_code), $order->customer['company_corporate']); fputcsvsafe($fp, $common_data, $delimiter); tep_order_log($insert_id, 'Order is saved to CSV file'); tep_db_query("update " . TABLE_ORDERS . " set " . (empty($order->info['code']) ? "orders_code = orders_id, " : "") . "payment_method_class = '" . tep_db_input($payment) . "', delivery_method = '" . tep_db_input($order_shipping_method) . "', delivery_method_class = '" . tep_db_input($order_shipping_title) . "', delivery_self_address = '" . tep_db_input($self_delivery_address) . "', delivery_self_address_id = '" . (int) $self_delivery_id . "' where orders_id = '" . (int) $insert_id . "'"); reset($order->products); while (list(, $product) = each($order->products)) { $product_code = (int) str_replace('bbk', '', $product['code']); $common_data = array($product['type'], $product_code, $product['qty'], str_replace(',', '.', $product['final_price']), $product['id'], '', $product['name'], tep_get_products_info($product['id']), $product['code'], $product['warranty']); fputcsvsafe($fp, $common_data, $delimiter); } fclose($fp); tep_order_log($insert_id, 'Order products are saved and file is closed'); copy($order_file, str_replace('temp_orders/', 'orders1/', $order_file)); unlink($order_file); tep_order_log($insert_id, 'Creating archive order'); tep_db_query("insert into " . TABLE_ARCHIVE_ORDERS . " select * from " . TABLE_ORDERS . " where orders_id = '" . (int) $insert_id . "'");
function tep_get_translation($string) { $string = stripslashes(strip_tags(tep_html_entity_decode(trim($string), ENT_QUOTES))); if (empty($string)) { return; } $max_length = 100; $pieces = array(); if (strlen($string) > $max_length) { for ($i = 0, $j = 0; $i < strlen($string); $i++) { $pieces[$j] .= $string[$i]; if (in_array($string[$i], array('.', '!', '?', ',')) && strlen($pieces[$j]) > $max_length) { $j++; } } } else { $pieces[] = $string; } $tpieces = array(); reset($pieces); while (list(, $piece) = each($pieces)) { $url = 'http://translate.google.ru/?hl=ru&layout=2&eotf=0&sl=ru&tl=en&q=' . urlencode($piece); $url = 'http://www.webproxyonline.info/browse.php?u=' . urlencode($url); // $url = 'http://www.nedproxy.com/browse.php?u=' . urlencode($url); $result = tep_request_html($url, 'GET'); $result = mb_convert_encoding($result, 'CP1251', 'UTF-8'); preg_match('/<span id=result_box[^>]+>(.+)<div id="translit"/', $result, $regs); $tpieces[] = tep_db_prepare_input(strip_tags($regs[1])); } $translation = implode(' ', $tpieces); return array('page' => $result, 'translation' => $translation); }