function RedirectProtected($url) { if (CONF_PROTECTED_CONNECTION == '1') { Redirect(correct_URL(CONF_FULL_SHOP_URL, "https") . $url); //redirect to HTTPS part of the website } else { Redirect($url); } //relative URL }
function _exportProducts($f, $rate, $export_product_name, $categories_select) { if (!count($categories_select)) { return 0; } include_once "core/classes/class.html2text.php"; include_once "core/classes/class.htmlparser.php"; fputs($f, " <offers>\n"); //товары с нулевым остатком на складе if (isset($_POST["yandex_dont_export_negative_stock"])) { $clause = " and in_stock>0"; } else { $clause = ""; } //какое описание экспортировать if ($_POST["yandex_export_description"] == 1) { $dsc = "description"; $dsc_q = ", " . $dsc; } else { if ($_POST["yandex_export_description"] == 2) { $dsc = "brief_description"; $dsc_q = ", " . $dsc; } else { $dsc = ""; $dsc_q = ""; } } $clause .= " and categoryID IN (" . implode(", ", xEscSQL($categories_select)) . ")"; $sql = ' SELECT productID, name, Price, categoryID, default_picture' . $dsc_q . ', in_stock, uri, uri_opt_val ' . convert_prices() . ' FROM ' . PRODUCTS_TABLE . ' WHERE enabled=1' . $clause; $q = db_query($sql); $store_url = correct_URL(CONF_FULL_SHOP_URL); while ($product = db_fetch_row($q)) { $price_row = priceRow($product); $url = $store_url . fu_make_url($product); fputs($f, " <offer available=\"" . ($product['in_stock'] || !CONF_CHECKSTOCK ? 'true' : 'false') . "\" id=\"" . $product["productID"] . "\">\n"); fputs($f, " <url>" . $url . "</url>\n"); //fputs($f, " <price>" . roundf($product["Price"] * $rate) . "</price>\n"); fputs($f, " <price>" . $price_row['Price_base'] . "</price>\n"); fputs($f, " <currencyId>RUR</currencyId>\n"); fputs($f, " <categoryId>" . $product["categoryID"] . "</categoryId>\n"); if ($product["default_picture"] != NULL) { $pic_clause = " and photoID=" . (int) $product["default_picture"]; } else { $pic_clause = ""; } $q1 = db_query("select filename, thumbnail from " . PRODUCT_PICTURES . " where productID=" . (int) $product["productID"] . $pic_clause); $pic_row = db_fetch_row($q1); if ($pic_row) { if (strlen($pic_row["filename"]) && file_exists("data/small/" . $pic_row["filename"])) { fputs($f, " <picture>" . $store_url . "data/small/" . str_replace(' ', '%20', _deleteHTML_Elements($pic_row["filename"])) . "</picture>\n"); } else { if (strlen($pic_row["thumbnail"]) && file_exists("data/medium/" . $pic_row["thumbnail"])) { fputs($f, " <picture>" . $store_url . "data/medium/" . str_replace(' ', '%20', _deleteHTML_Elements($pic_row["thumbnail"])) . "</picture>\n"); } } } switch ($export_product_name) { default: case 'only_name': $_NameAddi = ''; break; case 'path_and_name': $_NameAddi = ''; $_t = catCalculatePathToCategory($product['categoryID']); foreach ($_t as $__t) { if ($__t['categoryID'] != 1) { $_NameAddi .= $__t['name'] . ':'; } } break; } $product["name"] = _deleteHTML_Elements($_NameAddi . $product["name"]); fputs($f, " <name>" . $product["name"] . "</name>\n"); if (strlen($dsc) > 0) { $product_dsc = new Html2Text($product[$dsc], 10000); $product_dsc = $product_dsc->convert(); fputs($f, " <description>" . _deleteHTML_Elements($product_dsc) . "</description>\n"); } else { fputs($f, " <description></description>\n"); } fputs($f, " </offer>\n"); } fputs($f, " </offers>\n"); }