コード例 #1
0
ファイル: orders.php プロジェクト: rabbit-source/setbook.ru
 function tep_get_subcategories(&$subcategories_array, $parent_id = 0)
 {
     $subcategories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where categories_status = '1' and parent_id = '" . (int) $parent_id . "'");
     while ($subcategories = tep_db_fetch_array($subcategories_query)) {
         $subcategories_array[sizeof($subcategories_array)] = $subcategories['categories_id'];
         if ($subcategories['categories_id'] != $parent_id) {
             tep_get_subcategories($subcategories_array, $subcategories['categories_id']);
         }
     }
 }
コード例 #2
0
function generate($HTTP_GET_VARS)
{
    global $languages_id, $all_categories, $currency, $currencies, $categories_audio, $customer_discount, $cart, $breadcrumb;
    $customer_discount = $cart->get_customer_discount();
    if (!is_array($customer_discount)) {
        $customer_discount = array();
    }
    $content = FILENAME_PRICELIST;
    $page = tep_db_query_fetch_array("\n\t\t\tSELECT pages_id, \n\t\t\tpages_name, \n\t\t\tpages_additional_description, \n\t\t\tpages_description \n\t\t\tFROM " . TABLE_PAGES . " \n\t\t\tWHERE pages_filename = '" . tep_db_input(basename($content)) . "' \n\t\t\tAND language_id = '" . (int) $languages_id . "'");
    define('ADDITIONAL_DESCRIPTION', $page['pages_additional_description']);
    $translation_query = tep_db_query("\n\t\t\tSELECT pages_translation_key, \n\t\t\tpages_translation_value \n\t\t\tFROM " . TABLE_PAGES_TRANSLATION . " \n\t\t\tWHERE pages_filename = '" . tep_db_input(basename($content)) . "' \n\t\t\tAND language_id = '" . (int) $languages_id . "'");
    while ($translation = tep_db_fetch_array($translation_query)) {
        define($translation['pages_translation_key'], $translation['pages_translation_value']);
    }
    $breadcrumb->add($page['pages_name'], tep_href_link(FILENAME_PRICELIST));
    $fields_array = array();
    $fields_array['products_model'] = TEXT_CHOOSE_MODEL;
    $fields_array['products_name'] = TEXT_CHOOSE_NAME;
    $fields_array['categories_name'] = TEXT_CHOOSE_CATEGORY;
    $fields_array['authors_name'] = TEXT_CHOOSE_AUTHOR;
    $fields_array['manufacturers_name'] = TEXT_CHOOSE_MANUFACTURER;
    $fields_array['series_name'] = TEXT_CHOOSE_SERIE;
    $fields_array['products_description'] = TEXT_CHOOSE_DESCRIPTION;
    $fields_array['products_price'] = TEXT_CHOOSE_PRICE;
    $fields_array['products_year'] = TEXT_CHOOSE_YEAR;
    $fields_array['products_pages_count'] = TEXT_CHOOSE_PAGES_COUNT;
    $fields_array['products_copies'] = TEXT_CHOOSE_COPIES;
    $fields_array['products_covers_name'] = TEXT_CHOOSE_COVER;
    $fields_array['products_formats_name'] = TEXT_CHOOSE_FORMAT;
    $fields_array['products_image'] = TEXT_CHOOSE_IMAGE;
    $fields_array['products_url'] = TEXT_CHOOSE_URL;
    $fileds_required = array('products_model', 'products_name', 'authors_name', 'products_price', 'manufacturers_name');
    $specials_array = array();
    $specials_types_query = tep_db_query("\n\t\t\tSELECT specials_types_id, \n\t\t\tspecials_types_name \n\t\t\tFROM " . TABLE_SPECIALS_TYPES . " \n\t\t\tWHERE specials_types_status = '1' \n\t\t\tAND specials_types_path <> '' \n\t\t\tAND language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
    while ($specials_types = tep_db_fetch_array($specials_types_query)) {
        $specials_type_check = tep_db_query_fetch_array("\n\t\t\t\tSELECT count(*) as total \n\t\t\t\tFROM " . TABLE_SPECIALS . " \n\t\t\t\tWHERE specials_types_id = '" . (int) $specials_types['specials_types_id'] . "' \n\t\t\t\tAND status = '1'");
        if ($specials_type_check['total'] > 0) {
            $specials_array[$specials_types['specials_types_id']] = $specials_types['specials_types_name'];
        }
    }
    $specials_periods_array = array(array('id' => 'w', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_WEEK), array('id' => '2w', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_2_WEEK), array('id' => 'm', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_MONTH), array('id' => 'h', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_HALF_YEAR));
    $fields = array();
    //здесь была проверка на выдачу определенных полей
    $categories = array();
    //здесь была проверка на выдачу определенных категорий
    $manufacturers = array();
    //здесь была проверка на выдачу определенных издательств
    $specials = array();
    $specials_periods = array();
    ////здесь была проверка на выдачу определенных типов
    $ff = 'xml';
    $status = 'active';
    $compression_method = '';
    //проверить наличие переменной далее
    $type_info_query = tep_db_query("\n\t\t\tSELECT products_types_id, \n\t\t\tproducts_last_modified \n\t\t\tFROM " . TABLE_PRODUCTS_TYPES . " \n\t\t\tWHERE products_types_status = '1'" . (tep_not_null($HTTP_GET_VARS['type']) ? " AND products_types_path = '" . tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['type'])) . "'" : " AND products_types_default_status = '1'") . " limit 1");
    if (tep_db_num_rows($type_info_query) < 1) {
        tep_exit();
    } else {
        $type_info = tep_db_fetch_array($type_info_query);
        $products_types_id = $type_info['products_types_id'];
        $products_last_modified = strtotime($type_info['products_last_modified']);
    }
    $select_string_select = "SELECT distinct p.products_id";
    $select_string_from = " FROM " . TABLE_PRODUCTS_INFO . " p";
    $select_string_where = " WHERE p.products_types_id = '" . (int) $products_types_id . "' AND p.categories_id <> '4990' \n\tAND p.products_status = '1'" . ($status == 'active' ? " AND p.products_listing_status = '1'" : "") . " AND p.products_price > '0'";
    //Формируем список категорий
    $disabled_categories = array();
    $type_categories_check = tep_db_query_fetch_array("\n\t\t\tSELECT categories_id \n\t\t\tFROM " . TABLE_CATEGORIES . " \n\t\t\tWHERE products_types_id = '" . (int) $products_types_id . "'");
    if ($type_categories_check['categories_id'] > 0) {
        $active_categories = array();
    } else {
        $active_categories = array('0');
    }
    $categories_query = tep_db_query("\n\t\t\tSELECT categories_id, \n\t\t\tcategories_xml_status \n\t\t\tFROM " . TABLE_CATEGORIES . " \n\t\t\tWHERE products_types_id = '" . (int) $products_types_id . "' \n\t\t\tAND categories_status = '1' \n\t\t\tORDER BY parent_id");
    while ($categories = tep_db_fetch_array($categories_query)) {
        if ($categories['categories_xml_status'] < 1 && !in_array($categories['categories_id'], $disabled_categories)) {
            $disabled_categories[] = $categories['categories_id'];
            tep_get_subcategories($disabled_categories, $categories['categories_id']);
        } elseif (!in_array($categories['categories_id'], $disabled_categories)) {
            if (!in_array($categories['categories_id'], $active_categories)) {
                $active_categories[] = $categories['categories_id'];
            }
        }
    }
    $select_string_where .= " AND p.categories_id > '0'";
    if (sizeof($disabled_categories) > 0) {
        $select_string_where .= " AND p.categories_id NOT IN ('" . implode("', '", $disabled_categories) . "')";
    }
    //END Формируем список категорий
    $all_categories = array();
    //Здесь была выборка на разные сайты
    $separator = ';';
    $limit_string = "";
    $select_string = $select_string_select . $select_string_from . $select_string_where;
    $select_string .= " GROUP BY p.products_id";
    if ($HTTP_GET_VARS['file'] !== '') {
        $pricelist_filename = $HTTP_GET_VARS['file'];
    }
    //создаем массив символов которые будем менять
    $from = array('<', '>', '&', '"', '&#34;', '&#60;', '&#62;', '&#034;', '&#060;', '&#062;', "\r\n");
    $from1 = array('&amp;lt;', '&amp;gt;', '&amp;amp;', '&amp;quot;', '&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;#039;', ' ');
    //создаем массив символов на которые будем менять
    $to = array('&lt;', '&gt;', '&amp;', '&quot;', '&quot;', '&lt;', '&gt;', '&quot;', '&lt;', '&gt;', '&#039;', ' ');
    unset($pricelist_currency);
    $categories_audio = array();
    tep_get_subcategories($categories_audio, 1104);
    if ($customer_discount['type'] == 'purchase' && empty($for)) {
        $fp = false;
    } else {
        $fp = fopen($pricelist_filename, 'wb');
    }
    $content = '<?xml version="1.0" encoding="windows-1251"?>' . "\n" . '	<price date="' . date("Y-m-d H:i") . '">' . "\n" . '	<name>' . str_replace('&amp;amp;', '&amp;', str_replace($from, $to, STORE_NAME)) . '</name>' . "\n" . '	<url>' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . '</url>' . "\n" . ($content .= '	  <currency code="UAH"/>' . "\n");
    $content .= "<catalog>  \n";
    write_to_file($pricelist_filename, $fp, $content);
    $xml_categories_query = tep_db_query("\n\t\t\tSELECT concat_ws('', '<category id=\"', c.categories_id, '\" parentId=\"', c.parent_id, '\">', cd.categories_name, '</category>') as categories_string \n\t\t\tFROM " . TABLE_CATEGORIES . " c, \n\t\t\t" . TABLE_CATEGORIES_DESCRIPTION . " cd \n\t\t\tWHERE c.products_types_id = '" . (int) $products_types_id . "' \n\t\t\tAND c.categories_status = '1' \n\t\t\tAND c.categories_xml_status = '1' \n\t\t\tAND c.categories_id = cd.categories_id \n\t\t\tAND cd.language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
    while ($xml_categories = tep_db_fetch_array($xml_categories_query)) {
        write_to_file($pricelist_filename, $fp, $xml_categories['categories_string'] . "\n");
        $COUNTER['Categories']++;
    }
    $content = "\t</catalog> \n\t<items> \n";
    write_to_file($pricelist_filename, $fp, $content);
    $temp_filename = UPLOAD_DIR . 'csv/products_' . substr(uniqid(rand()), 0, 10) . '.xml';
    $currency_decimal_places = $currencies->get_decimal_places($products_currency);
    $currency_value = $currencies->get_value($products_currency);
    if ($products_types_id == 1) {
        $xml_string = "concat_ws('', '<item id=\"', p.products_id, '\"><url>', '" . HTTP_SERVER . "', p.products_url, '</url><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><categoryId>', p.categories_id, '</categoryId><picture>', if(p.products_image,concat_ws('','http://85.236.24.26/thumbs/',p.products_image),''), '</picture><delivery>true</delivery><author>', p.authors_name, '</author><name>', p.products_name, '</name><publisher>', p.manufacturers_name, '</publisher><series>', p.series_name, '</series><year>', p.products_year, '</year><ISBN>', p.products_model, '</ISBN><language>" . $language . "</language><binding>', p.products_formats_name, '</binding><page_extent>', p.products_pages_count, '</page_extent><description>', replace(p.products_description,'\n',if((locate(products_description, '<br')>0 or locate(products_description, '<p')>0),' ','<br />')), '</description>" . (!in_array(DOMAIN_ZONE, array('ru', 'ua', 'by', 'kz')) ? "<sales_notes>отправка по факту оплаты</sales_notes>" : "") . "<downloadable>false</downloadable></item>') as products_string";
    } else {
        $xml_string = "concat_ws('', '<item id=\"', p.products_id, '\"><url>', '" . HTTP_SERVER . "', p.products_url, '</url><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><categoryId>', p.categories_id, '</categoryId><picture>', if(p.products_image,concat_ws('','http://85.236.24.26/thumbs/',p.products_image),''), '</picture><delivery>true</delivery><name>', p.products_name, '</name><vendor>', p.manufacturers_name, '</vendor><description>', replace(p.products_description,'\n',if((locate(products_description, '<br')>0 or locate(products_description, '<p')>0),' ','<br />')), '</description>" . (!in_array(DOMAIN_ZONE, array('ru', 'ua', 'by', 'kz')) ? "<sales_notes>отправка по факту оплаты</sales_notes>" : "") . "<downloadable>', if((p.products_filename is null), 'false', 'true'), '</downloadable></item>') as products_string";
    }
    $xml_query_row = str_replace("SELECT distinct p.products_id FROM " . TABLE_PRODUCTS_INFO . " p", "SELECT " . $xml_string . " FROM " . TABLE_PRODUCTS_INFO . " p", $select_string);
    $xml_query_row = str_replace("WHERE ", "WHERE 1 and p.categories_id not in ('" . implode("','", $categories_audio) . "') and ", $xml_query_row);
    if (strpos($xml_query_row, 'order by') !== false) {
        $xml_query_row = substr($xml_query_row, 0, strpos($xml_query_row, 'order by'));
    }
    if (strpos($xml_query_row, ' limit ') === false) {
        $xml_query_row .= $limit_string;
    }
    $query = tep_db_query($xml_query_row);
    while ($row = tep_db_fetch_array($query)) {
        $t_str = $row['products_string'];
        $t_str = preg_replace('/<series>(.*)<\\/series>/ie', "'<series>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</series>'", $t_str);
        $t_str = preg_replace('/<description>(.*)<\\/description>/ie', "'<description>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</description>'", $t_str);
        $t_str = preg_replace('/<name>(.*)<\\/name>/ie', "'<name>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</name>'", $t_str);
        write_to_file($pricelist_filename, $fp, $t_str . "\n");
        $COUNTER['Offers']++;
    }
    $content = '	</items>' . "\n" . '  </price>' . "\n";
    write_to_file($pricelist_filename, $fp, $content);
    if ($fp) {
        fclose($fp);
    }
    return $COUNTER;
}
コード例 #3
0
         $specials[] = tep_string_to_int($HTTP_POST_VARS['special_' . $i]);
     }
 }
 $status = $HTTP_POST_VARS['status'];
 $products_to_load = array();
 $subcategories_products = array();
 $manufacturers_products = array();
 $specials_products = array();
 $products_selected = false;
 $subcategories_array = array();
 $eval_string = '';
 if (sizeof($categories) > 0) {
     reset($categories);
     while (list(, $category_id) = each($categories)) {
         $subcategories_array[] = $category_id;
         tep_get_subcategories($subcategories_array, $category_id);
     }
     $eval_string .= '$subcategories_products, ';
 }
 $manufacturers_array = array();
 if (sizeof($manufacturers) > 0) {
     reset($manufacturers);
     while (list(, $manufacturer_name) = each($manufacturers)) {
         $manufacturer_name = trim(preg_replace('/\\s+/', ' ', $manufacturer_name));
         if (tep_not_null($manufacturer_name)) {
             $manufacturer_info_query = tep_db_query("select manufacturers_id from " . TABLE_MANUFACTURERS_INFO . " where (manufacturers_name like '%" . str_replace(' ', "%' and manufacturers_name like '%", $manufacturer_name) . "%') and languages_id = '" . (int) $languages_id . "'");
             while ($manufacturer_info = tep_db_fetch_array($manufacturer_info_query)) {
                 $manufacturers_array[] = $manufacturer_info['manufacturers_id'];
             }
         }
     }
コード例 #4
0
ファイル: boards.php プロジェクト: rabbit-source/setbook.ru
                     if (tep_not_null($prev_file['image']) && $prev_file['image'] != $upload->filename) {
                         @unlink(DIR_FS_CATALOG_IMAGES . $prev_file['image']);
                     }
                     tep_db_query("update " . TABLE_BOARDS_CATEGORIES . " set image = '" . $upload->filename . "' where boards_categories_id = '" . (int) $boards_categories_id . "'");
                 }
             }
         }
         tep_update_blocks($boards_categories_id, 'boards_category');
         tep_redirect(tep_href_link(FILENAME_BOARDS, 'tPath=' . $tPath . '&cPath=' . $cPath . '&cID=' . $boards_categories_id));
     }
     break;
 case 'delete_category_confirm':
     if (isset($HTTP_POST_VARS['boards_categories_id'])) {
         $boards_categories_id = tep_db_prepare_input($HTTP_POST_VARS['boards_categories_id']);
         $categories = array($boards_categories_id);
         tep_get_subcategories($categories, $boards_categories_id, TABLE_BOARDS_CATEGORIES);
         tep_remove_board_category($categories);
     }
     tep_redirect(tep_href_link(FILENAME_BOARDS, 'tPath=' . $tPath . '&cPath=' . $cPath));
     break;
 case 'update':
     $boards_id = tep_db_prepare_input($HTTP_GET_VARS['bID']);
     $boards_status = tep_db_prepare_input($HTTP_POST_VARS['boards_status']);
     $customers_name = tep_db_prepare_input($HTTP_POST_VARS['customers_name']);
     $customers_telephone = tep_db_prepare_input($HTTP_POST_VARS['customers_telephone']);
     $customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);
     $customers_other_contacts = tep_db_prepare_input($HTTP_POST_VARS['customers_other_contacts']);
     $customers_country = tep_db_prepare_input($HTTP_POST_VARS['customers_country']);
     $customers_state = tep_db_prepare_input($HTTP_POST_VARS['customers_state']);
     $customers_city = tep_db_prepare_input($HTTP_POST_VARS['customers_city']);
     $boards_price = str_replace(',', '.', (double) $HTTP_POST_VARS['boards_price']);
コード例 #5
0
    $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id";
}
// EOF Separate Pricing Per Customer
if (DISPLAY_PRICE_WITH_TAX == 'true' && (tep_not_null($pfrom) || tep_not_null($pto))) {
    if (!tep_session_is_registered('customer_country_id')) {
        $customer_country_id = STORE_COUNTRY;
        $customer_zone_id = STORE_ZONE;
    }
    $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int) $customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int) $customer_zone_id . "')";
}
$from_str .= ", " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";
$where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int) $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id ";
if (isset($_GET['categories_id']) && tep_not_null($_GET['categories_id'])) {
    if (isset($_GET['inc_subcat']) && $_GET['inc_subcat'] == '1') {
        $subcategories_array = array();
        tep_get_subcategories($subcategories_array, $_GET['categories_id']);
        $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int) $_GET['categories_id'] . "'";
        for ($i = 0, $n = sizeof($subcategories_array); $i < $n; $i++) {
            $where_str .= " or p2c.categories_id = '" . (int) $subcategories_array[$i] . "'";
        }
        $where_str .= ")";
    } else {
        $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . (int) $languages_id . "' and p2c.categories_id = '" . (int) $_GET['categories_id'] . "'";
    }
}
if (isset($_GET['manufacturers_id']) && tep_not_null($_GET['manufacturers_id'])) {
    $where_str .= " and m.manufacturers_id = '" . (int) $_GET['manufacturers_id'] . "'";
}
if (isset($search_keywords) && sizeof($search_keywords) > 0) {
    $where_str .= " and (";
    for ($i = 0, $n = sizeof($search_keywords); $i < $n; $i++) {
コード例 #6
0
function generate($HTTP_GET_VARS)
{
    global $languages_id, $all_categories, $currency, $currencies, $categories_audio, $customer_discount, $cart, $breadcrumb;
    $customer_discount = $cart->get_customer_discount();
    if (!is_array($customer_discount)) {
        $customer_discount = array();
    }
    $content = FILENAME_PRICELIST;
    $page = tep_db_query_fetch_array("\n\t\t\tSELECT pages_id, \n\t\t\tpages_name, \n\t\t\tpages_additional_description, \n\t\t\tpages_description \n\t\t\tFROM " . TABLE_PAGES . " \n\t\t\tWHERE pages_filename = '" . tep_db_input(basename($content)) . "' \n\t\t\tAND language_id = '" . (int) $languages_id . "'");
    define('ADDITIONAL_DESCRIPTION', $page['pages_additional_description']);
    $translation_query = tep_db_query("\n\t\t\tSELECT pages_translation_key, \n\t\t\tpages_translation_value \n\t\t\tFROM " . TABLE_PAGES_TRANSLATION . " \n\t\t\tWHERE pages_filename = '" . tep_db_input(basename($content)) . "' \n\t\t\tAND language_id = '" . (int) $languages_id . "'");
    while ($translation = tep_db_fetch_array($translation_query)) {
        define($translation['pages_translation_key'], $translation['pages_translation_value']);
    }
    $breadcrumb->add($page['pages_name'], tep_href_link(FILENAME_PRICELIST));
    $fields_array = array();
    $fields_array['products_model'] = TEXT_CHOOSE_MODEL;
    $fields_array['products_name'] = TEXT_CHOOSE_NAME;
    $fields_array['categories_name'] = TEXT_CHOOSE_CATEGORY;
    $fields_array['authors_name'] = TEXT_CHOOSE_AUTHOR;
    $fields_array['manufacturers_name'] = TEXT_CHOOSE_MANUFACTURER;
    $fields_array['series_name'] = TEXT_CHOOSE_SERIE;
    $fields_array['products_description'] = TEXT_CHOOSE_DESCRIPTION;
    $fields_array['products_price'] = TEXT_CHOOSE_PRICE;
    $fields_array['products_year'] = TEXT_CHOOSE_YEAR;
    $fields_array['products_pages_count'] = TEXT_CHOOSE_PAGES_COUNT;
    $fields_array['products_copies'] = TEXT_CHOOSE_COPIES;
    $fields_array['products_covers_name'] = TEXT_CHOOSE_COVER;
    $fields_array['products_formats_name'] = TEXT_CHOOSE_FORMAT;
    $fields_array['products_image'] = TEXT_CHOOSE_IMAGE;
    $fields_array['products_url'] = TEXT_CHOOSE_URL;
    $fileds_required = array('products_model', 'products_name', 'authors_name', 'products_price', 'manufacturers_name');
    $specials_array = array();
    $specials_types_query = tep_db_query("\n\t\t\tSELECT specials_types_id, \n\t\t\tspecials_types_name \n\t\t\tFROM " . TABLE_SPECIALS_TYPES . " \n\t\t\tWHERE specials_types_status = '1' \n\t\t\tAND specials_types_path <> '' \n\t\t\tAND language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
    while ($specials_types = tep_db_fetch_array($specials_types_query)) {
        $specials_type_check = tep_db_query_fetch_array("\n\t\t\t\tSELECT count(*) as total \n\t\t\t\tFROM " . TABLE_SPECIALS . " \n\t\t\t\tWHERE specials_types_id = '" . (int) $specials_types['specials_types_id'] . "' \n\t\t\t\tAND status = '1'");
        if ($specials_type_check['total'] > 0) {
            $specials_array[$specials_types['specials_types_id']] = $specials_types['specials_types_name'];
        }
    }
    $specials_periods_array = array(array('id' => 'w', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_WEEK), array('id' => '2w', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_2_WEEK), array('id' => 'm', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_MONTH), array('id' => 'h', 'text' => ENTRY_PRICELIST_SPECIALS_LAST_HALF_YEAR));
    $fields = array();
    //здесь была проверка на выдачу определенных полей
    $categories = array();
    //здесь была проверка на выдачу определенных категорий
    $manufacturers = array();
    //здесь была проверка на выдачу определенных издательств
    $specials = array();
    $specials_periods = array();
    ////здесь была проверка на выдачу определенных типов
    $ff = 'xml';
    $status = 'active';
    $compression_method = '';
    //проверить наличие переменной далее
    $type_info_query = tep_db_query("SELECT products_types_id, products_last_modified FROM " . TABLE_PRODUCTS_TYPES . " WHERE products_types_status = '1'" . (tep_not_null($HTTP_GET_VARS['type']) ? " and products_types_path = '" . tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['type'])) . "'" : " and products_types_default_status = '1'") . " limit 1");
    if (tep_db_num_rows($type_info_query) < 1) {
        tep_exit();
    } else {
        $type_info = tep_db_fetch_array($type_info_query);
        $products_types_id = $type_info['products_types_id'];
        $products_last_modified = strtotime($type_info['products_last_modified']);
    }
    $select_string_select = "SELECT distinct p.products_id";
    $select_string_from = " FROM " . TABLE_PRODUCTS_INFO . " p";
    $select_string_where = " WHERE p.products_types_id = '" . (int) $products_types_id . "' and p.categories_id <> '4990' and p.products_status = '1'" . ($status == 'active' ? " and p.products_listing_status = '1'" : "") . " and p.products_price > '0'";
    if (sizeof($categories) > 0) {
        $subcategories_array = array();
        reset($categories);
        while (list(, $category_id) = each($categories)) {
            $subcategories_array[] = $category_id;
            tep_get_subcategories($subcategories_array, $category_id);
        }
        $select_string_where .= " and p.categories_id in ('" . implode("', '", $subcategories_array) . "')";
    } else {
        $disabled_categories = array();
        $type_categories_check_query = tep_db_query("SELECT categories_id FROM " . TABLE_CATEGORIES . " WHERE products_types_id = '" . (int) $products_types_id . "'");
        $type_categories_check = tep_db_fetch_array($type_categories_check_query);
        if ($type_categories_check['categories_id'] > 0) {
            $active_categories = array();
        } else {
            $active_categories = array('0');
        }
        $categories_query = tep_db_query("SELECT categories_id, categories_xml_status FROM " . TABLE_CATEGORIES . " WHERE products_types_id = '" . (int) $products_types_id . "' and categories_status = '1' order by parent_id");
        while ($categories = tep_db_fetch_array($categories_query)) {
            if ($categories['categories_xml_status'] < 1 && !in_array($categories['categories_id'], $disabled_categories)) {
                $disabled_categories[] = $categories['categories_id'];
                tep_get_subcategories($disabled_categories, $categories['categories_id']);
            } elseif (!in_array($categories['categories_id'], $disabled_categories)) {
                if (!in_array($categories['categories_id'], $active_categories)) {
                    $active_categories[] = $categories['categories_id'];
                }
            }
        }
        $select_string_where .= " and p.categories_id > '0'";
        if (sizeof($disabled_categories) > 0) {
            $select_string_where .= " and p.categories_id not in ('" . implode("', '", $disabled_categories) . "')";
        }
    }
    //	if ($customer_id==2) { echo $select_string_where; die; }
    $manufacturers_array = array();
    unset($manufacturers_string);
    if (sizeof($manufacturers) > 0) {
        $manufacturers_string = '';
        reset($manufacturers);
        while (list(, $manufacturer_name) = each($manufacturers)) {
            $manufacturer_name = tep_db_prepare_input(preg_replace('/\\s+/', ' ', $manufacturer_name));
            if (tep_not_null($manufacturer_name)) {
                $manufacturers_string .= (tep_not_null($manufacturers_string) ? " or " : "") . "(manufacturers_name like '%" . str_replace(' ', "%' and manufacturers_name like '%", $manufacturer_name) . "%')";
            }
        }
        unset($manufacturers_products);
        if ($products_types_id == 1) {
            $manufacturers_query = tep_db_query("SELECT distinct manufacturers_id FROM " . TABLE_MANUFACTURERS_INFO . " WHERE " . $manufacturers_string . "");
            while ($manufacturers_row = tep_db_fetch_array($manufacturers_query)) {
                $manufacturers_array[] = $manufacturers_row['manufacturers_id'];
            }
            //		$select_string_where .= " and p.manufacturers_id in ('" . implode("', '", $manufacturers_array) . "')";
            $manufacturers_products_query = tep_db_query("SELECT products_id FROM " . TABLE_PRODUCTS . " WHERE products_status = '1' and manufacturers_id in ('" . implode("', '", $manufacturers_array) . "')");
            while ($manufacturers_products_array = tep_db_fetch_array($manufacturers_products_query)) {
                $manufacturers_products[] = $manufacturers_products_array['products_id'];
            }
            $select_string_where .= " and p.products_id in ('" . implode("', '", $manufacturers_products) . "')";
        } else {
            $select_string_where .= " and (" . str_replace('manufacturers_name', 'p.manufacturers_name', $manufacturers_string) . ")";
        }
    }
    if (sizeof($specials) > 0) {
        $specials_products = array();
        reset($specials);
        while (list($j, $specials_type_id) = each($specials)) {
            if ($specials_periods[$j] == 'h') {
                $period = time() - 60 * 60 * 24 * 183;
            } elseif ($specials_periods[$j] == 'm') {
                $period = time() - 60 * 60 * 24 * 30;
            } elseif ($specials_periods[$j] == '2w') {
                $period = time() - 60 * 60 * 24 * 14;
            } else {
                $period = time() - 60 * 60 * 24 * 7;
            }
            //		$select_string_from .= ", " . TABLE_SPECIALS . " s" . $j . "";
            //		$select_string_where .= " and p.products_id = s" . $j . ".products_id and s" . $j . ".status = '1' and s" . $j . ".specials_types_id = '" . $specials_type_id . "' and date_format(s" . $j . ".specials_date_added, '%Y-%m-%d') >= '" . date('Y-m-d', $period) . "'";
            $specials_products_query = tep_db_query("SELECT products_id FROM " . TABLE_SPECIALS . " WHERE status = '1' and specials_types_id = '" . $specials_type_id . "' and date_format(specials_date_added, '%Y-%m-%d') >= '" . date('Y-m-d', $period) . "'");
            while ($specials_products_array = tep_db_fetch_array($specials_products_query)) {
                $specials_products[] = $specials_products_array['products_id'];
            }
            $select_string_where .= " and p.products_id in ('" . implode("', '", $specials_products) . "')";
        }
    }
    if (strpos($for, 'amazon') !== false) {
        $select_string_where .= " and p.products_covers_id > '0' and p.products_year > '0' and p.products_image_exists = '1' and p.products_formats_id > '0'";
    } elseif ($for == 'ebay' || $for == 'nur_kz') {
        $select_string_where .= " and p.products_image_exists = '1'";
    }
    $all_categories = array();
    if ($for == 'shopmania') {
        $separator = '|';
    } elseif (strpos($for, 'amazon') !== false) {
        $separator = "\t";
    } elseif ($for == 'ebay') {
        $separator = ',';
    } else {
        $separator = ';';
    }
    $limit_string = "";
    $select_string = $select_string_select . $select_string_from . $select_string_where;
    if (tep_not_null($HTTP_GET_VARS['limit'])) {
        $limit_query = urldecode($HTTP_GET_VARS['limit']);
        list($limit_from, $limit_to) = explode(',', $limit_query);
        $limit_from = (double) trim($limit_from);
        $limit_to = (double) trim($limit_to);
        if ($limit_from >= 0 && $limit_from < 1 && $limit_to > 0 && $limit_to <= 1) {
            $products_count_query_raw = str_replace('SELECT distinct p.products_id FROM', 'SELECT count(distinct p.products_id) as total FROM', $select_string);
            $products_count_query_raw = str_replace("FROM " . TABLE_PRODUCTS . " p", "FROM " . TABLE_PRODUCTS_INFO . " p", $select_string);
            $products_count_query = tep_db_query($products_count_query_raw);
            //		$products_count_row = tep_db_fetch_array($products_count_query);
            $products_count = tep_db_num_rows($products_count_query);
            $limit_from = ceil($products_count * $limit_from);
            $limit_to = ceil($products_count * $limit_to);
            $limit_string = " limit " . $limit_from . ", " . ($limit_to - $limit_from);
            $select_string .= " group by p.products_id" . $limit_string;
        } else {
            $select_string .= " group by p.products_id";
        }
    } else {
        $select_string .= " group by p.products_id";
    }
    //	if ( (tep_not_null($eval_string) && sizeof($products_to_load)==0) || $products_query_numrows==0) {
    //	  $messageStack->add('header', ENTRY_CORPORATE_FORM_PRODUCTS_FOUND_ERROR);
    //	} else {
    set_time_limit(0);
    $pricelist_link = tep_href_link(FILENAME_PRICELIST, tep_get_all_get_params(array('result_uri', 'overwrite_existing_file')), 'NONSSL', false);
    if (substr($pricelist_link, -5) == '&amp;') {
        do {
            $pricelist_link = substr($pricelist_link, 0, -5);
        } while (substr($pricelist_link, -5) != '&amp;');
    }
    if (strpos($pricelist_link, '&amp;&amp;') !== false) {
        do {
            $pricelist_link = str_replace('&amp;&amp;', '&amp;;', $pricelist_link);
        } while (strpos($pricelist_link, '&amp;&amp;') == false);
    }
    $pricelist_check_query = tep_db_query("SELECT pricelists_id, pricelists_filename FROM " . TABLE_PRICELISTS . " WHERE pricelists_url = '" . tep_db_input($pricelist_link) . "'");
    if (tep_db_num_rows($pricelist_check_query) > 0) {
        $pricelist_check = tep_db_fetch_array($pricelist_check_query);
        $pricelist_filename = $pricelist_check['pricelists_filename'];
    } else {
        tep_db_query("insert into " . TABLE_PRICELISTS . " (pricelists_url, date_added) values ('" . tep_db_input($pricelist_link) . "', now())");
        $pricelist_id = tep_db_insert_id();
        $pricelist_filename = 'prices/price' . $pricelist_id . '.' . ($ff == 'csv' && strpos($for, 'amazon') !== false ? 'txt' : $ff);
        tep_db_query("update " . TABLE_PRICELISTS . " set pricelists_filename = '" . tep_db_input($pricelist_filename) . "' WHERE pricelists_id = '" . (int) $pricelist_id . "'");
    }
    if ($HTTP_GET_VARS['file'] !== '') {
        $pricelist_filename = $HTTP_GET_VARS['file'];
    }
    $name = basename($pricelist_filename);
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
        $name = str_replace('.', '%2e', $name);
    }
    //	  tep_session_close();
    //	  ob_end_clean();
    /*
    	  header('HTTP/1.1 200 OK');
    	  header('Expires: Mon, 26 Nov 1962 00:00:00 GMT');
    	  header('Last-Modified: ' . gmdate('D,d M Y H:i:s', $products_last_modified) . ' GMT');
    	  if ($_SERVER['REQUEST_METHOD'] =='HEAD') { tep_exit(); }
    	  header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
    	  header('Pragma: no-cache');
    	  header('Content-Description: File Transfer');
    	  header('Content-Type: application/force-download');
    	  header('Content-Type: application/octet-stream');
    	  header('Content-Type: application/download');
    	  header('Content-Disposition: attachment; filename="' . $name . '"');
    	  header('Content-Transfer-Encoding: binary');
    	  header('Connection: Keep-Alive');
    	  header('Keep-Alive: timeout=60, max=300'); 
    */
    if (file_exists($pricelist_filename) && $HTTP_GET_VARS['overwrite_existing_file'] != 'yes' && $customer_discount['type'] != 'purchase') {
        clearstatcache();
        if (filemtime($pricelist_filename) >= $products_last_modified) {
            tep_db_query("update " . TABLE_PRICELISTS . " set last_modified = now(), pricelists_downloads_count = pricelists_downloads_count + 1 WHERE pricelists_id = '" . (int) $pricelist_check['pricelists_id'] . "'");
            //header('Content-Length: ' . (string)(filesize($pricelist_filename)));
            $fp = fopen($pricelist_filename, 'r');
            while (($line = fgets($fp, 65536)) !== false) {
                echo $line;
            }
            fclose($fp);
            //		  readfile($pricelist_filename);
            die;
        } else {
            unlink($pricelist_filename);
        }
    }
    /*
    	  if (!isset($argv)) {
    		system('php ' . DIR_FS_CATALOG . FILENAME_PRICELIST . ' ' . implode(' ', explode('&', tep_get_all_get_params(array(tep_session_name())))) . ' > /dev/null &');
    		do {
    		  sleep(10);
    		} while (!is_readable($pricelist_filename));
    
    		  sleep(5);
    		  readfile($pricelist_filename);
    
    //		if ($ff = fopen($pricelist_filename, 'r')) {
    //		  fpassthru($fp);
    //		  $k = 0;
    //		  while( (!feof($ff)) && (connection_status()==0) ) {
    //			echo fread($ff, 1024*8);
    //			flush();
    //		  }
    //		  fclose($ff);
    //		}
    		die();
    	  }
    */
    //создаем массив символов которые будем менять
    $from = array('<', '>', '&', '"', '&#34;', '&#60;', '&#62;', '&#034;', '&#060;', '&#062;', "\r\n");
    $from1 = array('&amp;lt;', '&amp;gt;', '&amp;amp;', '&amp;quot;', '&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;#039;', ' ');
    //создаем массив символов на которые будем менять
    $to = array('&lt;', '&gt;', '&amp;', '&quot;', '&quot;', '&lt;', '&gt;', '&quot;', '&lt;', '&gt;', '&#039;', ' ');
    unset($pricelist_currency);
    $categories_audio = array();
    tep_get_subcategories($categories_audio, 1104);
    if ($customer_discount['type'] == 'purchase' && empty($for)) {
        $fp = false;
    } else {
        $fp = fopen($pricelist_filename, 'wb');
    }
    if ($ff == 'csv') {
        if ($for == 'shopmania') {
            $fields_array = array('categories_name' => 'Категория', 'manufacturers_name' => 'Изготовитель', 'products_model' => 'Модель', 'products_id' => 'Торговый Код', 'products_name' => 'Имя продукта', 'products_description' => 'Описание продукции', 'products_url' => 'URL продукта', 'products_image' => 'URL изображения продукта', 'products_price' => 'Цена', 'products_currency' => 'Валюта');
            $fields = array_keys($fields_array);
        } elseif ($for == 'nur_kz') {
            //		Категория	Название товара	Производитель	Цена	Количество на складе	Ссылка на фотографию	Ссылка для покупки товара	Краткое описание	Полное описание	Ссылка на фотографию (уменьшенное фото)	Активность(товар активен если поле не пустое)
            $fields_array = array('categories_name' => 'Категория', 'products_name' => 'Название товара', 'manufacturers_name' => 'Производитель', 'products_price' => 'Цена', 'value::100' => 'Количество на складе', 'products_image_big' => 'Ссылка на фотографию', 'products_url' => 'Ссылка для покупки товара', 'products_description_short' => 'Краткое описание', 'products_description' => 'Полное описание', 'products_image' => 'Ссылка на фотографию (уменьшенное фото)', 'value::1' => 'Активность(товар активен если поле не пустое)');
            $fields = array_keys($fields_array);
            reset($fields);
            $temp_array = array();
            while (list(, $field_id) = each($fields)) {
                //			if ($field_id=='products_price') $temp_array[] = $fields_array[$field_id] . ' (' . DEFAULT_CURRENCY . ')';
                //			else
                $temp_array[] = $fields_array[$field_id];
            }
            write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
        } elseif (strpos($for, 'amazon') !== false) {
            if ($for == 'amazon_uk') {
                $fields_array = array('products_id' => 'sku', 'authors_name' => 'Author', 'products_name' => 'Title', 'manufacturers_name' => 'publisher', 'products_year' => 'pub-date', 'products_covers_name' => 'Binding', 'products_price' => 'Price', 'products_model' => 'product-id', 'value::"2"' => 'Product-id-type', 'value::100' => 'Quantity', 'value::1' => 'Item-condition', 'value::"In fact it\'s a new product! NOTE: The book is in Russian!!! Will be delivered within 2-3 weeks over Europe and within 3-4 weeks elsewhere. Please note that ordered books are shipped out from our warehouse in Moscow to our warehouse in Germany and then they are dispatched from Germany to the customers. Because we have to clear customs, some orders may take longer to reach the customers."' => 'Item-note', 'value::6' => 'Will-ship-internationally', 'value::N' => 'Expedited-shipping', 'products_image' => 'Main-image-url', '09' => 'Package-height', '10' => 'Package-width', '11' => 'Package-length', '12' => 'Package-length-unit-of-measure', 'products_weight' => 'Package-weight', 'value::kg' => 'Package-weight-unit-of-measure', 'value::russian' => 'Language', '13' => 'Illustrator', '14' => 'Edition', '15' => 'Subject', 'value::a' => 'Add-delete', '17' => 'fulfillment-center-id');
            } else {
                $fields_array = array('products_id' => 'sku', 'authors_name' => 'Author', 'products_name' => 'Title', 'manufacturers_name' => 'publisher', 'products_year' => 'pub-date', 'products_covers_name' => 'Binding', 'products_price' => 'Price', 'products_model' => 'product-id', 'value::"2"' => 'Product-id-type', 'value::100' => 'Quantity', 'value::11' => 'Item-condition', '02' => 'Item-note', '03' => 'Expedited-shipping', 'value::2' => 'Will-ship-internationally', 'products_image' => 'Main-image-url', '04' => 'main-offer-image', '05' => 'offer-image1', '06' => 'offer-image2', '07' => 'offer-image3', '08' => 'offer-image4', '09' => 'Package-height', '10' => 'Package-width', '11' => 'Package-length', '12' => 'Package-length-unit-of-measure', 'products_weight' => 'Package-weight', 'value::kg' => 'Package-weight-unit-of-measure', 'value::russian' => 'Language', '13' => 'Illustrator', '14' => 'Edition', '15' => 'Subject', 'value::a' => 'Add-delete', '17' => 'fulfillment-center-id', '18' => 'Dust-jacket', '19' => 'Signed-by');
            }
            $fields = array_keys($fields_array);
            reset($fields_array);
            $temp_array = array();
            while (list($field_id, $field_name) = each($fields_array)) {
                $temp_array[] = $field_name;
            }
            write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
        } elseif ($for == 'ebay') {
            $fields_array = array('value::Add' => '*Action(SiteID=US|Country=US|Currency=USD|Version=403|CC=UTF-8)', '20' => 'Product:UPC', 'products_model' => 'Product:ISBN', '00' => 'Product:ProductReferenceID', '01' => 'Product:IncludePreFilledItemInformation', '02' => 'Product:IncludeStockPhotoURL', '03' => 'Product:ReturnSearchResultsOnDuplicates', 'products_name' => 'Title', 'products_description' => 'Description', 'value::1000' => '*ConditionID', 'products_image' => 'PicURL', 'value::100' => '*Quantity', 'value::StoresFixedPrice' => '*Format', 'products_price' => '*StartPrice', '04' => 'BuyItNowPrice', '05' => 'ReservePrice', 'value::30' => '*Duration', '06' => 'ImmediatePayRequired', 'value::Boston,MA,USA' => '*Location', '07' => 'GalleryType', 'value::1' => 'PayPalAccepted', 'value::claudia.lokshina@gmail.com' => 'PayPalEmailAddress', 'value::- Book must be returned within 3 days. - Refund will be given as MoneyBack. - Seller pays for return shipping.' => 'PaymentInstructions', 'categories_name' => 'StoreCategory', '09' => 'ShippingDiscountProfileID', '10' => 'ShippingService-1:Option', '11' => 'ShippingService-1:Cost', '12' => 'ShippingService-1:Priority', '13' => 'ShippingService-1:ShippingSurcharge', '14' => 'ShippingService-2:Option', '15' => 'ShippingService-2:Cost', '16' => 'ShippingService-2:Priority', '17' => 'ShippingService-2:ShippingSurcharge', 'value::10' => '*DispatchTimeMax', '18' => 'CustomLabel', 'value::ReturnsAccepted' => '*ReturnsAcceptedOption', 'value::MoneyBack' => 'RefundOption', 'value::Days_3' => 'ReturnsWithinOption', 'value::Seller' => 'ShippingCostPaidBy', '19' => 'AdditionalDetails');
            $fields = array_keys($fields_array);
            reset($fields_array);
            $temp_array = array();
            while (list($field_id, $field_name) = each($fields_array)) {
                $temp_array[] = $field_name;
            }
            write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
        } else {
            reset($fields);
            $temp_array = array();
            while (list(, $field_id) = each($fields)) {
                if ($field_id == 'products_price') {
                    $temp_array[] = $fields_array[$field_id] . ' (' . DEFAULT_CURRENCY . ')';
                } else {
                    $temp_array[] = $fields_array[$field_id];
                }
            }
            write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
        }
        $products_query = tep_db_query($select_string);
        $products_query_numrows = tep_db_num_rows($products_query);
        while ($products = tep_db_fetch_array($products_query)) {
            $product_info = tep_get_full_product_info($products['products_id']);
            if (strpos($for, 'amazon') !== false) {
                if (strlen($product_info['products_model']) > 14 || strlen($product_info['products_model']) < 9) {
                    $product_info = array();
                }
            }
            if (sizeof($product_info) > 0) {
                reset($fields);
                $temp_array = array();
                while (list(, $field_id) = each($fields)) {
                    switch ($field_id) {
                        case 'products_currency':
                            $temp_array[] = str_replace('RUR', 'RUB', $product_info['products_currency']);
                            break;
                        case 'products_id':
                            $temp_array[] = $product_info['products_id'];
                            break;
                        case 'products_model':
                            $temp_array[] = $product_info['products_model'];
                            break;
                        case 'products_name':
                            $temp_array[] = $product_info['products_name'];
                            break;
                        case 'products_description':
                            $temp_array[] = $product_info['products_description'];
                            break;
                        case 'products_description_short':
                            $temp_array[] = $product_info['products_description_short'];
                            break;
                        case 'categories_name':
                            $temp_array[] = $product_info['categories_name'];
                            break;
                        case 'authors_name':
                            $temp_array[] = $product_info['authors_name'];
                            break;
                        case 'products_price':
                            $temp_array[] = $product_info['products_price'];
                            break;
                        case 'manufacturers_name':
                            $temp_array[] = $product_info['manufacturers_name'];
                            break;
                        case 'series_name':
                            $temp_array[] = $product_info['series_name'];
                            break;
                        case 'products_pages_count':
                            $temp_array[] = $product_info['products_pages_count'];
                            break;
                        case 'products_year':
                            $temp_array[] = $product_info['products_year'];
                            break;
                        case 'products_copies':
                            $temp_array[] = $product_info['products_copies'];
                            break;
                        case 'products_covers_name':
                            $temp_array[] = $product_info['products_covers_name'];
                            break;
                        case 'products_formats_name':
                            $temp_array[] = $product_info['products_formats_name'];
                            break;
                        case 'products_url':
                            $temp_array[] = $product_info['products_url'];
                            break;
                        case 'products_image':
                            $temp_array[] = $product_info['products_image'];
                            break;
                        case 'products_image_big':
                            $temp_array[] = $product_info['products_image_big'];
                            break;
                        case 'products_buy_now':
                            $temp_array[] = $product_info['products_buy'];
                            break;
                        case 'products_quantity':
                            $temp_array[] = $product_info['products_quantity'];
                            break;
                        case 'products_weight':
                            $temp_array[] = $product_info['products_weight'];
                            break;
                        case 'products_width':
                            $temp_array[] = $product_info['products_width'];
                            break;
                        case 'products_height':
                            $temp_array[] = $product_info['products_height'];
                            break;
                        case 'products_width_height_measure':
                            $temp_array[] = $product_info['products_width_height_measure'];
                            break;
                        default:
                            $field_value = '';
                            if (substr($field_id, 0, 7) == 'value::') {
                                list(, $field_value) = explode('value::', $field_id);
                                $field_value = preg_replace('/^"2"$/', '2', $field_value);
                            }
                            $temp_array[] = $field_value;
                            break;
                    }
                }
                if ($for == 'shopmania') {
                    $string = implode($separator, $temp_array) . "\n";
                    echo $string;
                    fwrite($fp, $string);
                } elseif (strpos($for, 'amazon') !== false) {
                    clearstatcache();
                    $string = implode($separator, $temp_array) . "\n";
                    echo $string;
                    fwrite($fp, $string);
                } elseif ($for == 'ebay') {
                    clearstatcache();
                    if (filesize($pricelist_filename) > '1500000') {
                        fclose($fp);
                        tep_exit();
                    } else {
                        write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
                    }
                } else {
                    if ($for == 'nur_kz' && empty($temp_array[8])) {
                    } else {
                        write_to_file($pricelist_filename, $fp, tep_get_csv_string($temp_array, $separator));
                    }
                }
            }
        }
    } else {
        if ($for == 'cenometr') {
            $content = '<?xml version="1.0" encoding="windows-1251"?>' . "\n" . '<!DOCTYPE cenometr SYSTEM "cenometr.dtd">' . "\n" . '<cenometr date="' . date('Y-m-d H:i', $products_last_modified) . '">' . "\n" . '  <shop>' . "\n" . '	<name>' . str_replace('&amp;amp;', '&amp;', str_replace($from, $to, STORE_NAME)) . '</name>' . "\n" . '	<url>' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . '</url>' . "\n" . '	<logo>' . HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_TEMPLATES . 'images/logo.gif</logo>' . "\n" . '	<offers>' . "\n";
            write_to_file($pricelist_filename, $fp, $content);
            $products_currency = 'RUR';
        } else {
            $content = '<?xml version="1.0" encoding="windows-1251"?>' . "\n" . '<!DOCTYPE yml_catalog SYSTEM "shops.dtd">' . "\n" . '<yml_catalog date="' . date('Y-m-d H:i', $products_last_modified) . '">' . "\n" . '  <shop>' . "\n" . '	<name>' . str_replace('&amp;amp;', '&amp;', str_replace($from, $to, STORE_NAME)) . '</name>' . "\n" . '	<company>' . str_replace('&amp;amp;', '&amp;', str_replace($from, $to, STORE_OWNER)) . '</company>' . "\n" . '	<url>' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . '</url>' . "\n" . '	<currencies>' . "\n";
            if ($currency == 'UAH') {
                $products_currency = 'UAH';
                $curs_query = tep_db_query("SELECT * FROM " . TABLE_CURRENCIES . " WHERE code in ('" . $currency . "')");
                while ($curs = tep_db_fetch_array($curs_query)) {
                    $content .= '	  <currency id="' . $curs['code'] . '" rate="1" />' . "\n";
                }
            } elseif (!in_array($currency, array('RUR', 'EUR', 'USD', 'UAH'))) {
                $products_currency = 'RUR';
                $curs_query = tep_db_query("SELECT * FROM " . TABLE_CURRENCIES . " WHERE code in ('RUR')");
                while ($curs = tep_db_fetch_array($curs_query)) {
                    $content .= '	  <currency id="' . $curs['code'] . '" rate="1" />' . "\n";
                }
            } else {
                $products_currency = 'RUR';
                $curs_query = tep_db_query("SELECT * FROM " . TABLE_CURRENCIES . " WHERE code in ('RUR', '" . $currency . "')");
                while ($curs = tep_db_fetch_array($curs_query)) {
                    $content .= '	  <currency id="' . $curs['code'] . '" rate="' . str_replace(',', '.', round(1 / $curs['value'], 4)) . '" />' . "\n";
                }
            }
            $content .= '	</currencies>' . "\n" . '	<categories>' . "\n";
            write_to_file($pricelist_filename, $fp, $content);
            $xml_categories_query = tep_db_query("SELECT concat_ws('', '<category id=\"', c.categories_id, '\" parentId=\"', c.parent_id, '\">', cd.categories_name, '</category>') as categories_string FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.products_types_id = '" . (int) $products_types_id . "' and c.categories_status = '1' and c.categories_xml_status = '1' and c.categories_id = cd.categories_id and cd.language_id = '" . (int) DEFAULT_LANGUAGE_ID . "'");
            while ($xml_categories = tep_db_fetch_array($xml_categories_query)) {
                write_to_file($pricelist_filename, $fp, $xml_categories['categories_string'] . "\n");
                $COUNTER['Categories']++;
            }
            $content = '	</categories>' . "\n" . '	<offers>' . "\n";
            write_to_file($pricelist_filename, $fp, $content);
        }
        $temp_filename = UPLOAD_DIR . 'csv/products_' . substr(uniqid(rand()), 0, 10) . '.xml';
        $currency_decimal_places = $currencies->get_decimal_places($products_currency);
        $currency_value = $currencies->get_value($products_currency);
        if ($products_types_id == 1) {
            if ($for == 'cenometr') {
                $xml_string = "concat_ws('', '<offer><name>', p.products_name, '</name><url>', '" . HTTP_SERVER . "', p.products_url, '</url><picture>', if(p.products_image,concat_ws('','http://85.236.24.26/thumbs/',p.products_image),''), '</picture><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><barcode>', replace(group_concat(p2m.products_model_1), ',', '</barcode><barcode>'), '</barcode></offer>') as products_string";
                $select_string = str_replace(" FROM " . TABLE_PRODUCTS_INFO . " p", " FROM " . TABLE_PRODUCTS_INFO . " p, " . TABLE_PRODUCTS_TO_MODELS . " p2m", $select_string);
                $select_string = str_replace(" and p.products_status = '1'", " and p.categories_id > '0' and p.products_status = '1' and p.products_id = p2m.products_id", $select_string);
            } else {
                //			if ($languages_id!=DEFAULT_LANGUAGE_ID) {
                //			  $xml_string = "concat_ws('', '<offer id=\"', p.products_id, '\" type=\"book\" available=\"', if((p.products_listing_status=1" . (tep_not_null($HTTP_GET_VARS['limit']) ? " and p.products_available_in<=2" : "") . "),'true','false'), '\"><url>', '" . HTTP_SERVER . "', p.products_url, '</url><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><currencyId>" . $products_currency . "</currencyId><categoryId>', p.categories_id, '</categoryId><picture>', if(p.products_image,concat_ws('','" . HTTP_SERVER . DIR_WS_IMAGES . "thumbs/',p.products_image),''), '</picture><delivery>true</delivery><author>', a.authors_name, '</author><name>', pd.products_name, '</name><publisher>', mi.manufacturers_name, '</publisher><series>', s.series_name, '</series><year>', p.products_year, '</year><ISBN>', p.products_model, '</ISBN><language>" . $language . "</language><binding>', p.products_formats_name, '</binding><page_extent>', p.products_pages_count, '</page_extent><description>', replace(pd.products_description,'\n',if((locate(pd.products_description, '<br')>0 or locate(pd.products_description, '<p')>0),' ','<br />')), '</description>" . (!in_array(DOMAIN_ZONE, array('ru', 'ua', 'by', 'kz')) ? "<sales_notes>отправка по факту оплаты</sales_notes>" : "") . "<downloadable>false</downloadable></offer>') as products_string";
                //			} else {
                $xml_string = "concat_ws('', '<offer id=\"', p.products_id, '\" type=\"book\" available=\"', if((p.products_listing_status=1" . (tep_not_null($HTTP_GET_VARS['limit']) ? " and p.products_available_in<=2" : "") . "),'true','false'), '\"><url>', '" . HTTP_SERVER . "', p.products_url, '</url><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><currencyId>" . $products_currency . "</currencyId><categoryId>', p.categories_id, '</categoryId><picture>', if(p.products_image,concat_ws('','http://85.236.24.26/thumbs/',p.products_image),''), '</picture><delivery>true</delivery><author>', p.authors_name, '</author><name>', p.products_name, '</name><publisher>', p.manufacturers_name, '</publisher><series>', p.series_name, '</series><year>', p.products_year, '</year><ISBN>', p.products_model, '</ISBN><language>" . $language . "</language><binding>', p.products_formats_name, '</binding><page_extent>', p.products_pages_count, '</page_extent><description>', replace(p.products_description,'\n',if((locate(products_description, '<br')>0 or locate(products_description, '<p')>0),' ','<br />')), '</description>" . (!in_array(DOMAIN_ZONE, array('ru', 'ua', 'by', 'kz')) ? "<sales_notes>отправка по факту оплаты</sales_notes>" : "") . "<downloadable>false</downloadable></offer>') as products_string";
                //			}
            }
        } else {
            $xml_string = "concat_ws('', '<offer id=\"', p.products_id, '\" available=\"', if((p.products_listing_status=1" . (tep_not_null($HTTP_GET_VARS['limit']) ? " and p.products_available_in<=2" : "") . "),'true','false'), '\"><url>', '" . HTTP_SERVER . "', p.products_url, '</url><price>', replace(round(p.products_price*" . $currency_value . "," . $currency_decimal_places . "),',','.'), '</price><currencyId>" . $products_currency . "</currencyId><categoryId>', p.categories_id, '</categoryId><picture>', if(p.products_image,concat_ws('','http://85.236.24.26/thumbs/',p.products_image),''), '</picture><delivery>true</delivery><name>', p.products_name, '</name><vendor>', p.manufacturers_name, '</vendor><description>', replace(p.products_description,'\n',if((locate(products_description, '<br')>0 or locate(products_description, '<p')>0),' ','<br />')), '</description>" . (!in_array(DOMAIN_ZONE, array('ru', 'ua', 'by', 'kz')) ? "<sales_notes>отправка по факту оплаты</sales_notes>" : "") . "<downloadable>', if((p.products_filename is null), 'false', 'true'), '</downloadable></offer>') as products_string";
        }
        $xml_query_row = str_replace("SELECT distinct p.products_id FROM " . TABLE_PRODUCTS_INFO . " p", "SELECT " . $xml_string . " FROM " . TABLE_PRODUCTS_INFO . " p", $select_string);
        $xml_query_row = str_replace("WHERE ", "WHERE 1 and p.categories_id not in ('" . implode("','", $categories_audio) . "') and ", $xml_query_row);
        if (strpos($xml_query_row, 'order by') !== false) {
            $xml_query_row = substr($xml_query_row, 0, strpos($xml_query_row, 'order by'));
        }
        if (strpos($xml_query_row, ' limit ') === false) {
            $xml_query_row .= $limit_string;
        }
        //		write_to_file($pricelist_filename, $fp,  $xml_query_row . " into outfile '" . $temp_filename . "'"); die;
        //		if ($customer_id==2) { echo $xml_query_row; die; }
        //		echo $xml_query_row; die;
        $query = tep_db_query($xml_query_row);
        while ($row = tep_db_fetch_array($query)) {
            $t_str = $row['products_string'];
            $t_str = preg_replace('/<series>(.*)<\\/series>/ie', "'<series>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</series>'", $t_str);
            $t_str = preg_replace('/<description>(.*)<\\/description>/ie', "'<description>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</description>'", $t_str);
            $t_str = preg_replace('/<name>(.*)<\\/name>/ie', "'<name>' . htmlspecialchars(preg_replace('/[^_\\\\/\\s\\w\\d\\#\\&(\\)\\-\\[\\]\\.\",;]/', '', strip_tags(tep_html_entity_decode('\$1'))), ENT_QUOTES) . '</name>'", $t_str);
            write_to_file($pricelist_filename, $fp, $t_str . "\n");
            $COUNTER['Offers']++;
        }
        if ($for == 'cenometr') {
            $content = '	</offers>' . "\n" . '  </shop>' . "\n" . '</cenometr>' . "\n";
        } else {
            $content = '	</offers>' . "\n" . '  </shop>' . "\n" . '</yml_catalog>' . "\n";
        }
        write_to_file($pricelist_filename, $fp, $content);
    }
    if ($fp) {
        fclose($fp);
    }
    return $COUNTER;
}
コード例 #7
0
            $fp = fopen($products_cache_filename, 'r');
            while (!feof($fp)) {
                $subcategories_products[] = trim(fgets($fp, 16));
            }
            fclose($fp);
        }
        if (!is_array($subcategories_products)) {
            $subcategories_products = array();
        }
        if (!isset($products_to_search)) {
            $listing_number_of_rows = sizeof($subcategories_products);
        }
    } else {
        $subcategories = array($show_category_id);
        if (isset($show_subcategories_products) && $show_subcategories_products == true) {
            tep_get_subcategories($subcategories, $show_category_id);
        }
        $subcategories_list_query = tep_db_query("select distinct products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id in ('" . implode("', '", $subcategories) . "')");
        while ($subcategories_list = tep_db_fetch_array($subcategories_list_query)) {
            $subcategories_products[] = $subcategories_list['products_id'];
        }
    }
    if (isset($products_to_search) && is_array($products_to_search)) {
        $products_to_search = array_intersect($products_to_search, $subcategories_products);
    } else {
        $products_to_search = $subcategories_products;
    }
}
if (isset($products_to_search) && is_array($products_to_search)) {
    $listing_sql_where .= " and p.products_id in ('" . implode("', '", $products_to_search) . "')";
}
コード例 #8
0
ファイル: general.php プロジェクト: itnovator/oscommerce_cvs
function tep_get_subcategories(&$subcategories_array, $parent_id = 0)
{
    global $osC_Database;
    $Qsubcategories = $osC_Database->query('select categories_id from :table_categories where parent_id = :parent_id');
    $Qsubcategories->bindTable(':table_categories', TABLE_CATEGORIES);
    $Qsubcategories->bindInt(':parent_id', $parent_id);
    $Qsubcategories->execute();
    while ($Qsubcategories->next()) {
        $subcategories_array[sizeof($subcategories_array)] = $Qsubcategories->valueInt('categories_id');
        if ($Qsubcategories->valueInt('categories_id') != $parent_id) {
            tep_get_subcategories($subcategories_array, $Qsubcategories->valueInt('categories_id'));
        }
    }
}
コード例 #9
0
     $update_products_params = true;
 }
 if ((int) $HTTP_POST_VARS['categories_id'] == 0 && (int) $HTTP_POST_VARS['manufacturers_id'] == 0 && (int) $HTTP_POST_VARS['series_id'] == 0 && (int) $HTTP_POST_VARS['products_types_id'] == 0) {
     $messageStack->add(ERROR_NO_PARAMETERS_SELECTED, 'error');
 } elseif ($update_products_prices == false && $update_products_params == false) {
     $messageStack->add(ERROR_NO_VALUES_SELECTED, 'error');
 } else {
     $sql = "select distinct p.products_id" . ($update_products_prices ? ", p." . tep_db_input($HTTP_POST_VARS['price_from']) . " as products_price" : '') . " from " . TABLE_PRODUCTS . " p";
     if (tep_not_null($HTTP_POST_VARS['categories_id'])) {
         $sql .= ", " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ";
     }
     $sql .= " where";
     if (tep_not_null($HTTP_POST_VARS['categories_id'])) {
         $subcategories = array($HTTP_POST_VARS['categories_id']);
         if ($HTTP_POST_VARS['inc_sub']) {
             tep_get_subcategories($subcategories, $HTTP_POST_VARS['categories_id']);
         }
         $subcategories = array_map("tep_string_to_int", $subcategories);
         $sql .= " p.products_id = p2c.products_id and p2c.categories_id in ('" . implode("', '", $subcategories) . "')";
     }
     if (tep_not_null($HTTP_POST_VARS['manufacturers_id'])) {
         $sql .= " and p.manufacturers_id = '" . (int) $HTTP_POST_VARS['manufacturers_id'] . "'";
     }
     if (tep_not_null($HTTP_POST_VARS['series_id'])) {
         $sql .= " and p.series_id = '" . (int) $HTTP_POST_VARS['series_id'] . "' ";
     }
     if (tep_not_null($HTTP_POST_VARS['products_types_id'])) {
         $sql .= " and p.products_types_id = '" . (int) $HTTP_POST_VARS['products_types_id'] . "' ";
     }
     $updated = 0;
     $products_query = tep_db_query($sql);
コード例 #10
0
             sleep(1);
             tep_redirect(tep_href_link(FILENAME_PRODUCTS_UPLOAD));
         }
     } else {
         $error = sprintf(ERROR_NO_FILE_UPLOAD, $filename_gz);
         if (isset($argv)) {
             $error = mb_convert_encoding($error, 'UTF-8', 'CP1251');
             die($error);
         } else {
             $messageStack->add($error, 'error');
         }
     }
 }
 if ($action == 'upload_products' || $action == 'upload_products_new' || $action == 'upload_other_products' || $action == 'small_upload') {
     $categories_audio = array();
     tep_get_subcategories($categories_audio, $categories_audio_top_id);
     $in_shops = array();
     if ($action == 'upload_other_products') {
         $filename_gz = UPLOAD_DIR . $upload_csv_dir . 'Tovar.csv.gz';
     } elseif ($action == 'upload_products_new') {
         $filename_gz = UPLOAD_DIR . $upload_csv_dir . 'Books1.csv.gz';
     } else {
         $filename_gz = UPLOAD_DIR . $upload_csv_dir . 'Books.csv.gz';
     }
     if ($action == 'upload_products_new') {
         $file_to_include = DIR_WS_INCLUDES . 'upload/products_1.php';
     } else {
         $file_to_include = DIR_WS_INCLUDES . 'upload/products.php';
     }
     if (tep_db_table_exists(DB_DATABASE, TABLE_TEMP_PRODUCTS)) {
         $messageStack->add(WARNING_UPDATE_IN_PROGRESS, 'warning');
コード例 #11
0
ファイル: general.php プロジェクト: Akofelaz/oscommerce2
function tep_get_subcategories(&$subcategories_array, $parent_id = 0)
{
    $OSCOM_Db = Registry::get('Db');
    $Qsub = $OSCOM_Db->prepare('select categories_id from :table_categories where parent_id = :parent_id');
    $Qsub->bindInt(':parent_id', $parent_id);
    $Qsub->execute();
    while ($Qsub->fetch()) {
        $subcategories_array[sizeof($subcategories_array)] = $Qsub->valueInt('categories_id');
        if ($Qsub->valueInt('categories_id') != $parent_id) {
            tep_get_subcategories($subcategories_array, $Qsub->valueInt('categories_id'));
        }
    }
}
コード例 #12
0
                         @unlink(DIR_FS_CATALOG_IMAGES . $prev_file['categories_image']);
                     }
                     tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . $upload->filename . "' where categories_id = '" . (int) $categories_id . "'");
                 }
             }
         }
         tep_update_blocks($categories_id, 'category');
         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 . '&cID=' . $categories_id));
     }
     break;
 case 'delete_category_confirm':
     if (isset($HTTP_POST_VARS['categories_id'])) {
         $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
         $categories = array($categories_id);
         tep_get_subcategories($categories, $categories_id);
         $products = array();
         $products_delete = array();
         if ($HTTP_POST_VARS['delete_category_products'] == '1') {
             for ($i = 0, $n = sizeof($categories); $i < $n; $i++) {
                 $product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int) $categories[$i]['id'] . "'");
                 while ($product_ids = tep_db_fetch_array($product_ids_query)) {
                     $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id'];
                 }
             }
             reset($products);
             while (list($key, $value) = each($products)) {
                 $category_ids = '';
                 for ($i = 0, $n = sizeof($value['categories']); $i < $n; $i++) {
                     $category_ids .= "'" . (int) $value['categories'][$i] . "', ";
                 }
コード例 #13
0
     if (defined('FEATURED_PRODUCTS_SPECIALS_ONLY') and FEATURED_PRODUCTS_SPECIALS_ONLY == 'true') {
         $query .= 'FROM ' . TABLE_SPECIALS . ' s LEFT JOIN ' . TABLE_PRODUCTS . ' p ON s.products_id = p.products_id ';
     } else {
         $query .= 'FROM ' . TABLE_PRODUCTS . ' p LEFT JOIN ' . TABLE_SPECIALS . ' s ON p.products_id = s.products_id ';
     }
     if ($current_page && $current_page == FILENAME_DEFAULT) {
         $query .= 'LEFT JOIN ' . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id AND pd.language_id = '" . $languages_id . "'\n\t\tLEFT JOIN " . TABLE_FEATURED . " f ON p.products_id = f.products_id\n\t\tWHERE p.products_status = '1' AND f.status = '1' order by rand({$mtm}) DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS_HOME;
     } else {
         $query .= 'LEFT JOIN ' . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id AND pd.language_id = '" . $languages_id . "'\n\t\tLEFT JOIN " . TABLE_FEATURED . " f ON p.products_id = f.products_id\n\t\tWHERE p.products_status = '1' AND f.status = '1' order by rand({$mtm}) DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS;
     }
     $featured_products_query = tep_db_query($query);
     $title = TABLE_HEADING_FEATURED_PRODUCTS;
 } else {
     $title = sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name);
     $subcategories_array = array();
     tep_get_subcategories($subcategories_array, $featured_products_category_id);
     $featured_products_category_id_list = tep_array_values_to_string($subcategories_array);
     if ($featured_products_category_id_list == '') {
         $featured_products_category_id_list .= $featured_products_category_id;
     } else {
         $featured_products_category_id_list .= ',' . $featured_products_category_id;
     }
     if (defined('FEATURED_PRODUCTS_SUB_CATEGORIES') and FEATURED_PRODUCTS_SUB_CATEGORIES == 'true') {
         // current catID as starting value
         $cats[] = $new_products_category_id;
         // put cat-IDs of all cats nested in current branch into $cats array,
         // go through all subbranches
         for ($i = 0; $i < count($cats); $i++) {
             $categorie_query = tep_db_query('SELECT `categories_id` FROM ' . TABLE_CATEGORIES . " WHERE parent_id = '" . (int) $cats[$i] . "'");
             while ($categorie = tep_db_fetch_array($categorie_query)) {
                 $cats[] = $categorie['categories_id'];
コード例 #14
0
ファイル: block_55.php プロジェクト: rabbit-source/setbook.ru
     if ($product_check_status['products_status'] == '1') {
         $linked_products_array[] = $linked['linked_id'];
     }
 }
 $linked_categories = array();
 $parent_categories = array();
 $product_categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int) $products_id . "'");
 while ($product_categories = tep_db_fetch_array($product_categories_query)) {
     $parent_categories[] = $product_categories['categories_id'];
     tep_get_parents($parent_categories, $product_categories['categories_id']);
 }
 $linked_query = tep_db_query("select cl.linked_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_LINKED . " cl where 1 and c.categories_status = '1' and c.categories_id = cl.linked_id and cl.categories_id in ('" . implode("', '", $parent_categories) . "')");
 if (tep_db_num_rows($linked_query) > 0 || sizeof($linked_products_array) > 0) {
     while ($linked = tep_db_fetch_array($linked_query)) {
         $linked_categories[] = $linked['linked_id'];
         tep_get_subcategories($linked_categories, $linked['linked_id']);
     }
     reset($linked_categories);
     shuffle($linked_categories);
     while (list(, $linked_categories_id) = each($linked_categories)) {
         $linked_products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int) $linked_categories_id . "'");
         while ($linked_products = tep_db_fetch_array($linked_products_query)) {
             $product_check_status_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int) $linked_products['products_id'] . "'");
             $product_check_status = tep_db_fetch_array($product_check_status_query);
             if ($product_check_status['products_status'] == '1' && $linked_products['products_id'] != $products_id) {
                 $linked_products_array[] = $linked_products['products_id'];
                 if (sizeof($linked_products_array) >= $limit) {
                     break;
                 }
             }
         }
コード例 #15
0
    $select_str .= ", SUM(tr.tax_rate) as tax_rate ";
}
$from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id";
if (DISPLAY_PRICE_WITH_TAX == 'true' && (tep_not_null($pfrom) || tep_not_null($pto))) {
    if (!tep_session_is_registered('customer_country_id')) {
        $customer_country_id = STORE_COUNTRY;
        $customer_zone_id = STORE_ZONE;
    }
    $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int) $customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int) $customer_zone_id . "')";
}
$from_str .= ", " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";
$where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int) $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id ";
if (isset($HTTP_GET_VARS['categories_id']) && tep_not_null($HTTP_GET_VARS['categories_id'])) {
    if (isset($HTTP_GET_VARS['inc_subcat']) && $HTTP_GET_VARS['inc_subcat'] == '1') {
        $subcategories_array = array();
        tep_get_subcategories($subcategories_array, $HTTP_GET_VARS['categories_id']);
        $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int) $HTTP_GET_VARS['categories_id'] . "'";
        for ($i = 0, $n = sizeof($subcategories_array); $i < $n; $i++) {
            $where_str .= " or p2c.categories_id = '" . (int) $subcategories_array[$i] . "'";
        }
        $where_str .= ")";
    } else {
        $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . (int) $languages_id . "' and p2c.categories_id = '" . (int) $HTTP_GET_VARS['categories_id'] . "'";
    }
}
if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
    $where_str .= " and m.manufacturers_id = '" . (int) $HTTP_GET_VARS['manufacturers_id'] . "'";
}
if (isset($search_keywords) && sizeof($search_keywords) > 0) {
    $where_str .= " and (";
    for ($i = 0, $n = sizeof($search_keywords); $i < $n; $i++) {
コード例 #16
0
 //			echo fread($ff, 1024*8);
 //			flush();
 //		  }
 //		  fclose($ff);
 //		}
 		die();
 	  }
 */
 //создаем массив символов которые будем менять
 $from = array('<', '>', '&', '"', '&#34;', '&#60;', '&#62;', '&#034;', '&#060;', '&#062;', "\r\n");
 $from1 = array('&amp;lt;', '&amp;gt;', '&amp;amp;', '&amp;quot;', '&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;quot;', '&amp;lt;', '&amp;gt;', '&amp;#039;', ' ');
 //создаем массив символов на которые будем менять
 $to = array('&lt;', '&gt;', '&amp;', '&quot;', '&quot;', '&lt;', '&gt;', '&quot;', '&lt;', '&gt;', '&#039;', ' ');
 unset($pricelist_currency);
 $categories_audio = array();
 tep_get_subcategories($categories_audio, 1104);
 if ($customer_discount['type'] == 'purchase' && empty($for)) {
     $fp = false;
 } else {
     $fp = fopen($pricelist_filename, 'wb');
 }
 if ($ff == 'csv') {
     if ($for == 'shopmania') {
         $fields_array = array('categories_name' => 'Категория', 'manufacturers_name' => 'Изготовитель', 'products_model' => 'Модель', 'products_id' => 'Торговый Код', 'products_name' => 'Имя продукта', 'products_description' => 'Описание продукции', 'products_url' => 'URL продукта', 'products_image' => 'URL изображения продукта', 'products_price' => 'Цена', 'products_currency' => 'Валюта');
         $fields = array_keys($fields_array);
     } elseif ($for == 'nur_kz') {
         //		Категория	Название товара	Производитель	Цена	Количество на складе	Ссылка на фотографию	Ссылка для покупки товара	Краткое описание	Полное описание	Ссылка на фотографию (уменьшенное фото)	Активность(товар активен если поле не пустое)
         $fields_array = array('categories_name' => 'Категория', 'products_name' => 'Название товара', 'manufacturers_name' => 'Производитель', 'products_price' => 'Цена', 'value::100' => 'Количество на складе', 'products_image_big' => 'Ссылка на фотографию', 'products_url' => 'Ссылка для покупки товара', 'products_description_short' => 'Краткое описание', 'products_description' => 'Полное описание', 'products_image' => 'Ссылка на фотографию (уменьшенное фото)', 'value::1' => 'Активность(товар активен если поле не пустое)');
         $fields = array_keys($fields_array);
         reset($fields);
         $temp_array = array();
コード例 #17
0
ファイル: general.php プロジェクト: rabbit-source/setbook.ru
function tep_update_all_shops($products_types_id = '')
{
    global $temp_tables, $in_shops, $currencies, $languages_id;
    $products_types_default_status = $products_types_id == 1 ? 1 : 0;
    if (!is_array($in_shops)) {
        $in_shops = array();
    }
    $temp_currencies = array();
    $filename_currencies_gz = UPLOAD_DIR . 'CSV/kurs.csv.gz';
    $filename_currencies = str_replace('.gz', '', $filename_currencies_gz);
    if (file_exists($filename_currencies_gz)) {
        $gz = @gzopen($filename_currencies_gz, 'r');
        $ff = @fopen($filename_currencies, 'w');
        if ($gz && $ff) {
            while ($string = gzgets($gz, 1024)) {
                fwrite($ff, $string);
            }
            fclose($ff);
            gzclose($gz);
        } elseif (file_exists($filename_currencies)) {
            @unlink($filename_currencies);
        }
    }
    if (file_exists($filename_currencies)) {
        $fp = fopen($filename_currencies, 'r');
        while ((list($currency_code, $currency_value) = fgetcsv($fp, 64, ';')) !== FALSE) {
            if ((double) $currency_value > 0) {
                $temp_currencies[$currency_code] = str_replace(',', '.', trim($currency_value));
            }
        }
        fclose($fp);
        unlink($filename_currencies);
    }
    if (sizeof($temp_currencies) == 0) {
        reset($currencies);
        while (list($currency_code, $currency_info) = each($currencies)) {
            $temp_currencies[$currency_code] = $currency_info['value'];
        }
    }
    $deleted_products = array();
    $filename_deleted_gz = UPLOAD_DIR . 'CSV/Deleted.csv.gz';
    $filename_deleted = str_replace('.gz', '', $filename_deleted_gz);
    if (file_exists($filename_deleted_gz)) {
        $gz = @gzopen($filename_deleted_gz, 'r');
        $ff = @fopen($filename_deleted, 'w');
        if ($gz && $ff) {
            while ($string = gzgets($gz, 1024)) {
                fwrite($ff, $string);
            }
            fclose($ff);
            gzclose($gz);
        } elseif (file_exists($filename_deleted)) {
            @unlink($filename_deleted);
        }
    }
    if (file_exists($filename_deleted)) {
        $fp = fopen($filename_deleted, 'r');
        while ((list($deleted_code, $deleted_type_id) = fgetcsv($fp, 64, ';')) !== FALSE) {
            if ((int) $deleted_code > 0) {
                $deleted_product_info_query = tep_db_query("select products_id from " . TABLE_TEMP_PRODUCTS . " where products_code = 'bbk" . sprintf('%010d', $deleted_code) . "' and products_types_id = '" . (int) $deleted_type_id . "'");
                $deleted_product_info = tep_db_fetch_array($deleted_product_info_query);
                $deleted_products[] = $deleted_product_info['products_id'];
            }
        }
        fclose($fp);
        unlink($filename_deleted);
    }
    $shops_query = tep_db_query("select * from " . TABLE_SHOPS . " where shops_database <> ''" . (sizeof($in_shops) > 0 ? " and (shops_default_status = '1' or shops_id in ('" . implode("', '", $in_shops) . "'))" : "") . " order by shops_default_status");
    while ($shops = tep_db_fetch_array($shops_query)) {
        list($shop_currency) = explode(',', $shops['shops_currency']);
        $shop_db = tep_db_input($shops['shops_database']);
        if (tep_not_null($shop_db)) {
            tep_db_select_db($shop_db);
            reset($temp_tables);
            while (list($step, $temp_table) = each($temp_tables)) {
                if ($shops['shops_default_status'] == '0') {
                    tep_db_query("drop table if exists " . $shop_db . ".temp_" . $temp_table);
                    if (tep_db_table_exists(DB_DATABASE, 'temp_' . $temp_table)) {
                        tep_db_query("create table " . $shop_db . ".temp_" . $temp_table . " like " . DB_DATABASE . ".temp_" . $temp_table);
                        tep_db_query("insert into " . $shop_db . ".temp_" . $temp_table . " select * from " . DB_DATABASE . ".temp_" . $temp_table);
                    } else {
                        tep_db_query("create table " . $shop_db . "." . $temp_table . " like " . DB_DATABASE . "." . $temp_table);
                        tep_db_query("insert into " . $shop_db . "." . $temp_table . " select * from " . DB_DATABASE . "." . $temp_table);
                    }
                }
            }
            tep_db_query("update " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " set products_status = '1' where products_types_id > '1' and products_id in (select products_id from " . DB_DATABASE . "." . TABLE_PRODUCTS_TO_SHOPS . " where shops_id = '" . (int) $shops['shops_id'] . "' and products_status = '1')");
            tep_db_query("update " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " set products_status = '0' where products_id in (select products_id from " . DB_DATABASE . "." . TABLE_PRODUCTS_TO_SHOPS . " where shops_id = '" . (int) $shops['shops_id'] . "' and products_status = '0')");
            /*
            		if ((int)$products_types_default_status==0) {
            		  $unused_categories_array = array();
            		  $unused_categories_query = tep_db_query("select categories_id from " . $shop_db . "." . TABLE_CATEGORIES . " where products_types_id = '" . (int)$products_types_id . "' and categories_status = '1'");
            	 	  while ($unused_categories = tep_db_fetch_array($unused_categories_query)) {
            			$subcategories_array = $unused_categories['categories_id'];
            			tep_get_subcategories($subcategories_array, $unused_categories['categories_id']);
            			$products_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " p where p.products_types_id = '" . (int)$products_types_id . "' and p2c.products_id = p.products_id and p.products_status = '1'");
            			$products_check = tep_db_fetch_array($products_check_query);
            			if ($products_check['total']==0) $unused_categories_array[] = (int)$unused_categories['categories_id'];
            		  }
            		  if (sizeof($unused_categories_array) > 0) tep_db_query("update " . $shop_db . "." . TABLE_CATEGORIES . " set categories_status = '0' where categories_id in ('" . implode("', '", $unused_categories_array) . "'))");
            		}
            */
            $unused_categories_array = array();
            $unused_categories_query = tep_db_query("select categories_id from " . $shop_db . "." . TABLE_CATEGORIES . " where categories_status = '0' and products_types_id in (select products_types_id from " . $shop_db . "." . TABLE_PRODUCTS_TYPES . " where products_types_status = '1')");
            while ($unused_categories = tep_db_fetch_array($unused_categories_query)) {
                $unused_categories_array[] = $unused_categories['categories_id'];
                tep_get_subcategories($unused_categories_array, $unused_categories['categories_id']);
            }
            if (sizeof($unused_categories_array) > 0) {
                tep_db_query("update " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " set products_status = '0' where products_id in (select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id in ('" . implode("', '", $unused_categories_array) . "'))");
            }
            tep_update_shops_prices($shops['shops_id'], '', 'temp');
            reset($deleted_products);
            while (list(, $deleted_product_id) = each($deleted_products)) {
                tep_db_query("update " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " set products_status = '0' where products_id = '" . (int) $deleted_product_id . "'");
            }
            tep_db_query("update " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " set products_listing_status = '0', products_xml_status = '0' where products_price = '0'");
            tep_db_query("update " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " set products_price = '0' where products_listing_status = '0'");
            if ($shops['shops_default_status'] == '0') {
                tep_db_query("delete from " . $shop_db . "." . TABLE_TEMP_SPECIALS . " where specials_types_id = '5'");
            } else {
                tep_db_query("update " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " set products_available_in = '1' where products_id in (select products_id from " . $shop_db . "." . TABLE_TEMP_SPECIALS . " where specials_types_id = '5' and status = '1')");
            }
            tep_db_query("update " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " set products_available_in = '0' where products_filename is not null");
            tep_db_query("update " . $shop_db . "." . TABLE_TEMP_SPECIALS . " s, " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " p set s.status = p.products_status, s.products_image_exists = p.products_image_exists, s.specials_first_page = if((p.products_image_exists and p.products_listing_status), '1', '0') where s.products_id = p.products_id");
            tep_db_query("update " . $shop_db . "." . TABLE_TEMP_SPECIALS . " set specials_first_page = if((products_image_exists and status), '1', '0') where specials_types_id = '4'");
            tep_db_query("update " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " p, " . $shop_db . "." . TABLE_TEMP_PRODUCTS_INFO . " pi set pi.products_code = p.products_code, pi.products_model = p.products_model, pi.products_image = p.products_image, pi.products_filename = p.products_filename, pi.products_price = p.products_price, pi.products_last_modified = p.products_last_modified, pi.products_available_in = p.products_available_in, pi.products_weight = p.products_weight, pi.products_year = p.products_year, pi.products_pages_count = p.products_pages_count, pi.products_copies = p.products_copies, pi.products_status = p.products_status, pi.products_listing_status = p.products_listing_status, pi.products_types_id = p.products_types_id where pi.products_id = p.products_id");
            //		tep_db_query("delete from " . $shop_db . "." . TABLE_TEMP_SPECIALS . " where status = '1' and now() >= expires_date and expires_date > 0");
            $specials_query = tep_db_query("select specials_id, products_id, specials_new_products_price from " . $shop_db . "." . TABLE_TEMP_SPECIALS . " where specials_new_products_price > '0'");
            while ($specials = tep_db_fetch_array($specials_query)) {
                $product_info_query = tep_db_query("select products_price, products_status from " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " where products_id = '" . (int) $specials['products_id'] . "'");
                $product_info = tep_db_fetch_array($product_info_query);
                if ($product_info['products_price'] <= $specials['specials_new_products_price'] || $product_info['products_status'] == '0') {
                    tep_db_query("delete from " . $shop_db . "." . TABLE_TEMP_SPECIALS . " where specials_id = '" . (int) $specials['specials_id'] . "'");
                }
            }
            $specials_query = tep_db_query("select specials_id, products_id from " . $shop_db . "." . TABLE_TEMP_SPECIALS . " where specials_types_id = '4'");
            while ($specials = tep_db_fetch_array($specials_query)) {
                $product_info_query = tep_db_query("select products_listing_status, products_price from " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " where products_id = '" . (int) $specials['products_id'] . "'");
                $product_info = tep_db_fetch_array($product_info_query);
                if ($product_info['products_price'] > '0' && $product_info['products_listing_status'] == '1') {
                    tep_db_query("delete from " . $shop_db . "." . TABLE_TEMP_SPECIALS . " where specials_id = '" . (int) $specials['specials_id'] . "'");
                }
            }
            // сортировка по умолчанию (сначала спецпредложения с картинками, потом спецпредложения без картинок, потом книги с картинками, потом все остальное)
            $max_specials_date_query = tep_db_query("select max(specials_date_added) as specials_date_added from " . $shop_db . "." . TABLE_TEMP_SPECIALS . " where status = '1'");
            $max_specials_date_row = tep_db_fetch_array($max_specials_date_query);
            $max_specials_date = strtotime($max_specials_date_row['specials_date_added']);
            $min_specials_date_added = date('Y-m-d', $max_specials_date - 60 * 60 * 24 * 7);
            tep_db_query("update " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " p left join " . $shop_db . "." . TABLE_TEMP_SPECIALS . " s on (s.products_id = p.products_id and s.specials_types_id in ('1', '2') and s.specials_date_added >= '" . tep_db_input($min_specials_date_added) . "') set p.sort_order = (if(p.products_listing_status=1, 8, 0) + if(s.specials_types_id, if(s.specials_types_id=1, 4, if(s.specials_types_id=2, 3, 0)), 0) + if(p.products_image_exists=1, 2, 0))");
            reset($temp_tables);
            while (list($step, $temp_table) = each($temp_tables)) {
                if (tep_db_table_exists($shop_db, 'temp_' . $temp_table)) {
                    if ($temp_table == TABLE_PRODUCTS && $products_types_default_status == 1) {
                        /*
                        			  $basket_products_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where shops_id = '" . (int)$shops['shops_id'] . "'");
                        			  while ($basket_products = tep_db_fetch_array($basket_products_query)) {
                        				$check_old_status_query = tep_db_query("slect products_status, products_listing_status from " . $shop_db . "." . TABLE_PRODUCTS . " where products_id = '" . (int)$basket_products['products_id'] . "'");
                        				$check_old_status = tep_db_fetch_array($check_old_status_query);
                        
                        				$check_new_status_query = tep_db_query("slect products_status, products_listing_status from " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " where products_id = '" . (int)$basket_products['products_id'] . "'");
                        				$check_new_status = tep_db_fetch_array($check_new_status_query);
                        
                        				if ($check_new_status['products_status'] == '0') {
                        				  // удаляем из корзин товары, которых нет на сайте
                        				  tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where shops_id = '" . (int)$shops['shops_id'] . "' and products_id = '" . (int)$basket_products['products_id'] . "'");
                        				} elseif ($check_old_status['products_listing_status'] == '1' && $check_new_status['products_listing_status'] == '0') {
                        				  // переносим из корзин в отложенные товары
                        				  tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '1', customers_basket_type = 'postpone' where shops_id = '" . (int)$shops['shops_id'] . "' and products_id = '" . (int)$basket_products['products_id'] . "'");
                        				}
                        			  }
                        */
                        $lang_id = $languages_id;
                        if ($shop_db == 'setbook_org' || $shop_db == 'easternowl' || $shop_db == 'insellbooks') {
                            $lang_id = 1;
                        }
                        $shop_name_info_query = tep_db_query("select configuration_value from " . $shop_db . "." . TABLE_CONFIGURATION . " where configuration_key = 'STORE_NAME'");
                        $shop_name_info = tep_db_fetch_array($shop_name_info_query);
                        $shop_name = $shop_name_info['configuration_value'];
                        $shop_email_info_query = tep_db_query("select configuration_value from " . $shop_db . "." . TABLE_CONFIGURATION . " where configuration_key = 'STORE_OWNER_EMAIL_ADDRESS'");
                        $shop_email_info = tep_db_fetch_array($shop_email_info_query);
                        $shop_email = $shop_email_info['configuration_value'];
                        $shop_phone_info_query = tep_db_query("select configuration_value from " . $shop_db . "." . TABLE_CONFIGURATION . " where configuration_key = 'STORE_OWNER_PHONE_NUMBER'");
                        $shop_phone_info = tep_db_fetch_array($shop_phone_info_query);
                        $shop_phone = $shop_phone_info['configuration_value'];
                        $notify_products_query = tep_db_query("select customers_basket_id, products_id, customers_id, customers_basket_notify_url, customers_basket_notify from " . TABLE_CUSTOMERS_BASKET . " where shops_id = '" . (int) $shops['shops_id'] . "' and customers_basket_notify > '0'");
                        while ($notify_products = tep_db_fetch_array($notify_products_query)) {
                            $new_info_query = tep_db_query("select products_status, products_listing_status, products_price, authors_id from " . $shop_db . "." . TABLE_TEMP_PRODUCTS . " where products_id = '" . (int) $notify_products['products_id'] . "'");
                            $new_info = tep_db_fetch_array($new_info_query);
                            $old_info_query = tep_db_query("select products_status, products_listing_status, products_price, authors_id from " . $shop_db . "." . TABLE_PRODUCTS . " where products_id = '" . (int) $notify_products['products_id'] . "'");
                            $old_info = tep_db_fetch_array($old_info_query);
                            $product_name_info_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int) $notify_products['products_id'] . "' and language_id = '" . (int) $lang_id . "'");
                            $product_name_info = tep_db_fetch_array($product_name_info_query);
                            if (!is_array($product_name_info)) {
                                $product_name_info = array();
                            }
                            $author_info_query = tep_db_query("select authors_name from " . TABLE_AUTHORS . " where authors_id = '" . (int) $new_info['authors_id'] . "' and language_id = '" . (int) $lang_id . "'");
                            $author_info = tep_db_fetch_array($author_info_query);
                            if (!is_array($author_info)) {
                                $author_info = array();
                            }
                            if ($lang_id == 1) {
                                $product_email_name = $product_name_info['products_name'] . (tep_not_null($author_info['authors_name']) ? ' by ' . $author_info['authors_name'] : '');
                            } else {
                                $product_email_name = (tep_not_null($author_info['authors_name']) ? $author_info['authors_name'] . ': ' : '') . $product_name_info['products_name'];
                            }
                            $new_status = $new_info['products_listing_status'];
                            $new_price = $new_info['products_price'];
                            $old_status = $old_info['products_listing_status'];
                            $old_price = $old_info['products_price'];
                            $customer_info_query = tep_db_query("select customers_firstname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int) $notify_products['customers_id'] . "'");
                            $customer_info = tep_db_fetch_array($customer_info_query);
                            $notification_body = '';
                            $notification_subject = '';
                            $notification_warning = '';
                            if ($notify_products['customers_basket_notify'] == '1') {
                                // о появлении в продаже
                                if ($new_status == '1') {
                                    if ($lang_id == 1) {
                                        $notification_body = EMAIL_NOTIFICATION_BODY_EN_1;
                                        $notification_subject = EMAIL_NOTIFICATION_SUBJECT_EN_1;
                                        $notification_warning = EMAIL_NOTIFICATION_WARNING_EN_1;
                                    } else {
                                        $notification_body = EMAIL_NOTIFICATION_BODY_1;
                                        $notification_subject = EMAIL_NOTIFICATION_SUBJECT_1;
                                        $notification_warning = EMAIL_NOTIFICATION_WARNING_1;
                                    }
                                }
                            } elseif ($notify_products['customers_basket_notify'] == '2') {
                                // о снижении цены
                                if ($new_price > 0 && $new_price < $old_price) {
                                    if ($lang_id == 1) {
                                        $notification_body = EMAIL_NOTIFICATION_BODY_EN_2;
                                        $notification_subject = EMAIL_NOTIFICATION_SUBJECT_EN_2;
                                        $notification_warning = EMAIL_NOTIFICATION_WARNING_EN_2;
                                    } else {
                                        $notification_body = EMAIL_NOTIFICATION_BODY_2;
                                        $notification_subject = EMAIL_NOTIFICATION_SUBJECT_2;
                                        $notification_warning = EMAIL_NOTIFICATION_WARNING_2;
                                    }
                                }
                            }
                            if (tep_not_null($notification_body)) {
                                $email_notification_body = str_replace('{{product_link}}', $notify_products['customers_basket_notify_url'], sprintf($notification_body, $customer_info['customers_firstname'], $product_email_name)) . "\n\n" . EMAIL_NOTIFICATION_SEPARATOR . "\n" . sprintf($notification_warning, $shop_name);
                                $message = new email(array('X-Mailer: ' . $shop_name));
                                $text = strip_tags($email_notification_body);
                                if ($shops['shops_email_use_html'] < 1) {
                                    $message->add_text($text);
                                } else {
                                    ob_start();
                                    include DIR_FS_CATALOG . 'images/mail/email_header_1.php';
                                    echo trim($email_notification_body);
                                    include DIR_FS_CATALOG . 'images/mail/email_footer_1.php';
                                    $email_text_html = ob_get_clean();
                                    $email_text_html = str_replace(array('<title></title>', '{{HTTP_SERVER}}', '{{STORE_NAME}}', '{{STORE_OWNER_PHONE_NUMBER}}'), array('<title>' . sprintf($notification_subject, $shop_name) . '</title>', $shops['shops_url'], $shop_name, $shop_phone), $email_text_html);
                                    $message->add_html($email_text_html, $text);
                                }
                                $message->build_message();
                                $message->send($customer_info['customers_firstname'], $customer_info['customers_email_address'], $shop_name, $shop_email, sprintf($notification_subject, $shop_name));
                                tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_notify = '0', customers_basket_notify_url = null where customers_basket_id = '" . (int) $notify_products['customers_basket_id'] . "'");
                            }
                        }
                    }
                    tep_db_query("drop table " . $shop_db . "." . $temp_table . "");
                    tep_db_query("alter table " . $shop_db . ".temp_" . $temp_table . " rename as " . $shop_db . "." . $temp_table . "");
                    if ($shop_db == 'setbook_ua') {
                        tep_db_query("update " . $shop_db . "." . TABLE_CURRENCIES . " set value = '" . tep_db_input($temp_currencies[$shop_currency]) . "', last_updated = now() where code = '" . tep_db_input($shop_currency) . "'");
                    }
                }
            }
            if ($shops['shops_default_status'] == '1') {
                tep_db_query("delete from " . TABLE_SEARCH_KEYWORDS_TO_PRODUCTS . "");
                tep_db_query("delete from " . TABLE_SEARCH_KEYWORDS . "");
                tep_db_query("update " . TABLE_SPECIALS_TYPES . " set specials_last_modified = now()");
            }
            if ($products_types_default_status == 1) {
                tep_db_query("update " . $shop_db . "." . TABLE_PRODUCTS_TYPES . " set products_last_modified = now() where products_types_id = '1'");
            } else {
                tep_db_query("update " . $shop_db . "." . TABLE_PRODUCTS_TYPES . " set products_last_modified = now() where products_types_id > '1'");
            }
            if ($shop_db == 'setbook_us' || $shop_db == 'setbook_biz') {
                tep_db_query("replace into " . $shop_db . "." . TABLE_METATAGS . " (metatags_page_title, metatags_title, metatags_keywords, metatags_description, language_id, content_type, content_id) select concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_page_title, ' Russian books.'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_title, '. Russian books.'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_keywords, ' Russian books.'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_description, ' Russian books.'), " . DB_DATABASE . "." . TABLE_METATAGS . ".language_id, " . DB_DATABASE . "." . TABLE_METATAGS . ".content_type, " . DB_DATABASE . "." . TABLE_METATAGS . ".content_id from " . DB_DATABASE . "." . TABLE_METATAGS . " where " . DB_DATABASE . "." . TABLE_METATAGS . ".content_type in ('author', 'category', 'manufacturer',  'product', 'serie', 'type');");
                tep_db_query("update " . $shop_db . "." . TABLE_METATAGS . " mt, " . $shop_db . "." . TABLE_PRODUCTS . " p set mt.metatags_page_title = replace(mt.metatags_page_title, 'Russian books', 'Russian magazines'), mt.metatags_title = replace(mt.metatags_title, 'Russian books', 'Russian magazines'), mt.metatags_keywords = replace(mt.metatags_keywords, 'Russian books', 'Russian magazines'), mt.metatags_description = replace(mt.metatags_description, 'Russian books', 'Russian magazines') where mt.content_type = 'product' and mt.content_id = p.products_id and p.products_types_id = '2'");
                tep_db_query("update " . $shop_db . "." . TABLE_METATAGS . " mt, " . $shop_db . "." . TABLE_PRODUCTS . " p set mt.metatags_page_title = replace(mt.metatags_page_title, 'Russian books', 'Russian magazines'), mt.metatags_title = replace(mt.metatags_title, 'Russian books', 'Russian souvenirs. Matreshka'), mt.metatags_keywords = replace(mt.metatags_keywords, 'Russian books', 'Russian magazines'), mt.metatags_description = replace(mt.metatags_description, 'Russian books', 'Russian souvenirs') where mt.content_type = 'product' and mt.content_id = p.products_id and p.products_types_id = '5'");
            } elseif ($shop_db == 'setbook_eu' || $shop_db == 'setbook_net') {
                tep_db_query("replace into " . $shop_db . "." . TABLE_METATAGS . " (metatags_page_title, metatags_title, metatags_keywords, metatags_description, language_id, content_type, content_id) select concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_page_title, ' Russian books. Russische b&uuml;cher'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_title, '. Russian books.'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_keywords, ' Russian books. Russische b&uuml;cher'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_description, ' Russian books. Russische b&uuml;cher'), " . DB_DATABASE . "." . TABLE_METATAGS . ".language_id, " . DB_DATABASE . "." . TABLE_METATAGS . ".content_type, " . DB_DATABASE . "." . TABLE_METATAGS . ".content_id from " . DB_DATABASE . "." . TABLE_METATAGS . " where " . DB_DATABASE . "." . TABLE_METATAGS . ".content_type in ('author', 'category', 'manufacturer',  'product', 'serie', 'type');");
                tep_db_query("update " . $shop_db . "." . TABLE_METATAGS . " mt, " . $shop_db . "." . TABLE_PRODUCTS . " p set mt.metatags_page_title = replace(mt.metatags_page_title, 'Russian books. Russische b&uuml;cher', 'Russian magazines. Russische Zeitschriften'), mt.metatags_title = replace(mt.metatags_title, 'Russian books', 'Russian magazines'), mt.metatags_keywords = replace(mt.metatags_keywords, 'Russian books', 'Russian magazines'), mt.metatags_description = replace(mt.metatags_description, 'Russian books', 'Russian magazines') where mt.content_type = 'product' and mt.content_id = p.products_id and p.products_types_id = '2'");
            } elseif ($shop_db == 'setbook_ua') {
                tep_db_query("replace into " . $shop_db . "." . TABLE_METATAGS . " (metatags_page_title, metatags_title, metatags_keywords, metatags_description, language_id, content_type, content_id) select replace(" . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_page_title, 'Интернет-магазин Setbook', 'Книжный интернет-магазин в Украине Setbook'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_title, '. Книжный интернет-магазин в Украине Setbook.'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_keywords, ' Украина, книги в Киеве.'),\nconcat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_description, ' Украина, книги в Киеве.'), " . DB_DATABASE . "." . TABLE_METATAGS . ".language_id, " . DB_DATABASE . "." . TABLE_METATAGS . ".content_type, " . DB_DATABASE . "." . TABLE_METATAGS . ".content_id from " . DB_DATABASE . "." . TABLE_METATAGS . " where " . DB_DATABASE . "." . TABLE_METATAGS . ".content_type in ('author', 'category', 'manufacturer',  'product', 'serie', 'type');");
                //		  tep_db_query("update " . $shop_db . "." . TABLE_METATAGS . " mt, " . $shop_db . "." . TABLE_PRODUCTS . " p set mt.metatags_page_title = replace(mt.metatags_page_title, 'Russian books', ''), mt.metatags_title = replace(mt.metatags_title, '', ''), mt.metatags_keywords = replace(mt.metatags_keywords, '', ''), mt.metatags_description = replace(mt.metatags_description, '', '') where mt.content_type = 'product' and mt.content_id = p.products_id and p.products_types_id = '2'");
            } elseif ($shop_db == 'setbook_kz') {
                tep_db_query("replace into " . $shop_db . "." . TABLE_METATAGS . " (metatags_page_title, metatags_title, metatags_keywords, metatags_description, language_id, content_type, content_id) select replace(" . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_page_title, 'Интернет-магазин Setbook', 'Книжный интернет-магазин в Казахстане Setbook'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_title, '. Книжный интернет-магазин в Казахстане Setbook.'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_keywords, ' Казахстан, книги в Алматы, Астане, Караганде.'),\nconcat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_description, ' Казахстан, книги в Алматы, Астане, Караганде.'), " . DB_DATABASE . "." . TABLE_METATAGS . ".language_id, " . DB_DATABASE . "." . TABLE_METATAGS . ".content_type, " . DB_DATABASE . "." . TABLE_METATAGS . ".content_id from " . DB_DATABASE . "." . TABLE_METATAGS . " where " . DB_DATABASE . "." . TABLE_METATAGS . ".content_type in ('author', 'category', 'manufacturer',  'product', 'serie', 'type');");
                //		  tep_db_query("update " . $shop_db . "." . TABLE_METATAGS . " mt, " . $shop_db . "." . TABLE_PRODUCTS . " p set mt.metatags_page_title = replace(mt.metatags_page_title, 'Russian books', ''), mt.metatags_title = replace(mt.metatags_title, '', ''), mt.metatags_keywords = replace(mt.metatags_keywords, '', ''), mt.metatags_description = replace(mt.metatags_description, '', '') where mt.content_type = 'product' and mt.content_id = p.products_id and p.products_types_id = '2'");
            } elseif ($shop_db == 'setbook_by' || $shop_db == 'bookva_by') {
                if ($shop_db == 'setbook_by') {
                    tep_db_query("replace into " . $shop_db . "." . TABLE_METATAGS . " (metatags_page_title, metatags_title, metatags_keywords, metatags_description, language_id, content_type, content_id) select replace(" . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_page_title, 'Интернет-магазин Setbook', 'Интернет-магазин книг в Белоруссии Setbook'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_title, '. Интернет-магазин книг Белоруссии Setbook.'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_keywords, ' Белоруссия, книги в Минске.'), concat_ws('', " . DB_DATABASE . "." . TABLE_METATAGS . ".metatags_description, ' Белоруссия, книги в Минске.'), " . DB_DATABASE . "." . TABLE_METATAGS . ".language_id, " . DB_DATABASE . "." . TABLE_METATAGS . ".content_type, " . DB_DATABASE . "." . TABLE_METATAGS . ".content_id from " . DB_DATABASE . "." . TABLE_METATAGS . " where " . DB_DATABASE . "." . TABLE_METATAGS . ".content_type in ('author', 'category', 'manufacturer',  'product', 'serie', 'type');");
                    //			tep_db_query("update " . $shop_db . "." . TABLE_METATAGS . " mt, " . $shop_db . "." . TABLE_PRODUCTS . " p set mt.metatags_page_title = replace(mt.metatags_page_title, 'Russian books', ''), mt.metatags_title = replace(mt.metatags_title, '', ''), mt.metatags_keywords = replace(mt.metatags_keywords, '', ''), mt.metatags_description = replace(mt.metatags_description, '', '') where mt.content_type = 'product' and mt.content_id = p.products_id and p.products_types_id = '2'");
                }
            }
        }
    }
    tep_db_select_db(DB_DATABASE);
}
コード例 #18
0
function tep_get_subcategories(&$subcategories_array, $parent_id = 0, $table = TABLE_CATEGORIES)
{
    if ($table == TABLE_CATEGORIES) {
        $subcategories_query = tep_db_query("select boards_categories_id as categories_id from " . TABLE_BOARDS_CATEGORIES . " where parent_id = '" . (int) $parent_id . "'");
    } else {
        $subcategories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int) $parent_id . "'");
    }
    while ($subcategories = tep_db_fetch_array($subcategories_query)) {
        $subcategories_array[sizeof($subcategories_array)] = $subcategories['categories_id'];
        if ($subcategories['categories_id'] != $parent_id) {
            tep_get_subcategories($subcategories_array, $subcategories['categories_id'], $table);
        }
    }
}