} $strCategory .= $arSection["NAME"]; } $arSectionPaths[IntVal($ar_elems["IBLOCK_SECTION_ID"])] = PrepareString($strCategory); } $minPrice = 0; for ($i = 0, $intPCount = count($arPTypes); $i < $intPCount; $i++) { if (strlen($ar_elems["CATALOG_CURRENCY_" . $arPTypes[$i]]) <= 0) { continue; } $tmpPrice = Round(CCurrencyRates::ConvertCurrency($ar_elems["CATALOG_PRICE_" . $arPTypes[$i]], $ar_elems["CATALOG_CURRENCY_" . $arPTypes[$i]], "USD"), 2); if ($minPrice <= 0 || $minPrice > $tmpPrice) { $minPrice = $tmpPrice; } } if ($minPrice <= 0) { continue; } @fwrite($fp, "http://" . COption::GetOptionString("main", "server_name", $SERVER_NAME) . str_replace("//", "/", $ar_elems["DETAIL_PAGE_URL"]) . "\t" . $ar_elems["~NAME"] . "\t" . PrepareString($ar_elems["~PREVIEW_TEXT"], true) . "\t" . $strImage . "\t" . $arSectionPaths[IntVal($ar_elems["IBLOCK_SECTION_ID"])] . "\t" . $minPrice . "\n"); } @fclose($fp); } } CCatalogDiscountSave::Enable(); if ($bTmpUserCreated) { unset($USER); if (isset($USER_TMP)) { $USER = $USER_TMP; unset($USER_TMP); } }
function dbSave_tofile($repertoire, $linebyline = 0, $savemysql_size = 256) { global $dbname, $name, $MSos, $crlf, $crlf2; @set_time_limit(600); $date_jour = date(adm_translate("dateforop")); $date_op = date("ymd"); $filename = $dbname . "-" . $date_op; $tables = sql_list_tables($dbname); $num_tables = sql_num_rows($tables); if ($num_tables == 0) { echo " " . adm_translate("Aucune table n'a été trouvée") . "\n"; } else { if (!isset($repertoire) or $repertoire == "") { $repertoire = "."; } if (!is_dir($repertoire)) { @umask("0000"); @mkdir($repertoire, 0777); $fp = fopen($repertoire . "/index.html", 'w'); fclose($fp); } $heure_jour = date("H:i"); $data0 = "# ========================================================{$crlf}" . "# {$crlf}" . "# Sauvegarde de la base de données : " . $dbname . " {$crlf}" . "# Effectuée le " . $date_jour . " : " . $heure_jour . " par " . $name . " {$crlf}" . "# {$crlf}" . "# ========================================================{$crlf}"; $data1 = ""; $ifile = 0; while ($row = sql_fetch_row($tables)) { $table = $row[0]; $data1 .= "{$crlf}" . "# --------------------------------------------------------{$crlf}" . "# {$crlf}" . "# Structure de la table '" . $table . "' {$crlf}" . "# {$crlf}{$crlf}"; $data1 .= get_table_def($table) . "{$crlf}{$crlf}" . "# {$crlf}" . "# Contenu de la table '" . $table . "' {$crlf}" . "# {$crlf}{$crlf}"; $result = sql_query("SELECT * FROM {$table}"); $count_line = sql_num_fields($result); while ($row = sql_fetch_row($result)) { $schema_insert = "INSERT INTO {$table} VALUES ("; for ($j = 0; $j < $count_line; $j++) { if (!isset($row[$j])) { $schema_insert .= " NULL"; } else { if ($row[$j] != "") { $schema_insert .= " '" . PrepareString($row[$j]) . "'"; } else { $schema_insert .= " ''"; } } if ($j < $count_line - 1) { $schema_insert .= ","; } } $schema_insert .= ");{$crlf}"; $data1 .= $schema_insert; if ($linebyline == 1) { if (strlen($data1) > $savemysql_size * 1024) { send_tofile($data0 . $data1, $repertoire, $filename . "-" . sprintf("%03d", $ifile), "sql", $MSos); $data1 = ""; $ifile++; } } } $data1 .= "{$crlf}{$crlf}" . "# --------------------------------------------------------{$crlf}"; if ($linebyline == 0) { if (strlen($data1) > $savemysql_size * 1024) { send_tofile($data0 . $data1, $repertoire, $filename . "-" . sprintf("%03d", $ifile), "sql", $MSos); $data1 = ""; $ifile++; } } } if (strlen($data1) > 0) { send_tofile($data0 . $data1, $repertoire, $filename . "-" . sprintf("%03d", $ifile), "sql", $MSos); $data1 = ""; $ifile++; } } }