if (isset($matches[2]) && $matches[3] == 'gz') { $file_excel_name = "core/temp/file.csv.gz"; $method_parse = 1; } else { $file_excel_name = "core/temp/file.csv"; $method_parse = 0; } if (file_exists($file_excel_name)) { unlink($file_excel_name); } $res = @move_uploaded_file($_FILES["csv"]["tmp_name"], $file_excel_name); $smarty->assign("file_excel_name", $file_excel_name); } } if (isset($res) && $res) { SetRightsToUploadedFile($file_excel_name); //show import configurator if ($method_parse == 1) { $data = myfgetcsvgz($file_excel_name, $delimiter); } else { $data = myfgetcsv($file_excel_name, $delimiter); } if (!count($data)) { die(ERROR_CANT_READ_FILE); } $data = iconv_deep("windows-1251", "utf-8", $data); $excel_configurator = imGetImportConfiguratorHtmlCode($data); $smarty->assign("excel_import_configurator", $excel_configurator); $smarty->assign("delimiter", $delimiterv); $smarty->assign("currencyISO", $_POST['currencyISO']); } else {
db_query("update " . CATEGORIES_TABLE . " SET picture='" . xEscSQL($filename . "_" . $i . "." . $ext) . "' " . " WHERE categoryID=" . (int) $pid); } else { echo "<div align=\"center\"><span style=\"color: #BB0000\">" . ERROR_FAILED_TO_UPLOAD_FILE . "</span></div>\n"; exit; } } else { echo "<div align=\"center\"><span style=\"color: #BB0000\">" . ERROR_FAILED_TO_UPLOAD_FILE . "</span></div>\n"; exit; } $taskDone2 = true; } } } else { if (is_uploaded_file($_FILES['picture']['tmp_name'])) { if (move_uploaded_file($_FILES['picture']['tmp_name'], "data/category/" . $picture_name)) { SetRightsToUploadedFile("data/category/" . $picture_name); db_query("update " . CATEGORIES_TABLE . " SET picture='" . xEscSQL($picture_name) . "' " . " WHERE categoryID=" . (int) $pid); } else { echo "<div align=\"center\"><span style=\"color: #BB0000\">" . ERROR_FAILED_TO_UPLOAD_FILE . "</span></div>\n"; exit; } } else { echo "<div align=\"center\"><span style=\"color: #BB0000\">" . ERROR_FAILED_TO_UPLOAD_FILE . "</span></div>\n"; exit; } } //remove old picture... Redirect(ADMIN_FILE . "?categoryID=" . $pid . "&eaction=cat"); } Redirect(ADMIN_FILE . "?dpt=catalog&sub=products_categories&categoryID=" . $pid . "&expandCat=" . $pid); } else {
function AddProduct($categoryID, $name, $Price, $description, $in_stock, $brief_description, $list_price, $product_code, $sort_order, $ProductIsProgram, $eproduct_filename, $eproduct_available_days, $eproduct_download_times, $weight, $meta_description, $meta_keywords, $free_shipping, $min_order_amount, $shipping_freight, $classID, $currencyID, $opt_margin, $sef, $title, $updateGCV = 1) { // special symbol prepare if ($free_shipping) { $free_shipping = 1; } else { $free_shipping = 0; } if ($classID == null) { $classID = "NULL"; } if ($min_order_amount == 0) { $min_order_amount = 1; } if (!$ProductIsProgram) { $eproduct_filename = ""; } if ($eproduct_filename != "") { if (trim($_FILES[$eproduct_filename]["name"]) != "") { if ($_FILES[$eproduct_filename]["size"] != 0) { $r = move_uploaded_file($_FILES[$eproduct_filename]["tmp_name"], "core/files/" . $_FILES[$eproduct_filename]["name"]); } $eproduct_filename = trim($_FILES[$eproduct_filename]["name"]); SetRightsToUploadedFile("core/files/" . $eproduct_filename); } } if (trim($name) == "") { $name = "?"; } $sql = ' INSERT INTO ' . PRODUCTS_TABLE . ' SET categoryID = ' . (int) $categoryID . ', name = "' . xToText(trim($name)) . '", description = "' . xEscSQL($description) . '", customers_rating = 0, Price = "' . number_format($Price, 2, '.', '') . '", in_stock = ' . (int) $in_stock . ', customer_votes = 0, items_sold = 0, enabled = 1, brief_description = "' . xEscSQL($brief_description) . '", list_price = "' . number_format($list_price, 2, '.', '') . '", product_code = "' . xToText(trim($product_code)) . '", sort_order = ' . (int) $sort_order . ', date_added = "' . xEscSQL(get_current_time()) . '", eproduct_filename = "' . xEscSQL($eproduct_filename) . '", eproduct_available_days = ' . (int) $eproduct_available_days . ', eproduct_download_times = ' . (int) $eproduct_download_times . ', weight = "' . (double) $weight . '", meta_description = "' . xToText(trim($meta_description)) . '", meta_keywords = "' . xToText(trim($meta_keywords)) . '", free_shipping = ' . (int) $free_shipping . ', min_order_amount = ' . (int) $min_order_amount . ', shipping_freight = "' . number_format($shipping_freight, 2, '.', '') . '", classID = ' . (int) $classID . ', currencyID = ' . (int) $currencyID . ', opt_margin = ' . (int) $opt_margin . ', sef = "' . xToText(trim($sef)) . '", title = "' . xToText(trim($title)) . '"'; db_query($sql); $insert_id = db_insert_id(); if ($updateGCV == 1 && CONF_UPDATE_GCV == '1') { update_psCount(1); } return $insert_id; }
function Rendernames($tempname, $folder) { $new_tempname = ""; if (isset($_FILES[$tempname]) && $_FILES[$tempname]["size"] > 0) { $picture_name = strtolower(str_replace(" ", "_", $_FILES[$tempname]["name"])); $pos = strrpos($picture_name, "."); $name = substr($picture_name, 0, $pos); $ext = substr($picture_name, $pos + 1); if (file_exists($folder . $picture_name)) { $taskDone = false; for ($i = 1; $i < 500 && $taskDone == false; $i++) { if (!file_exists($folder . $name . "_" . $i . "." . $ext)) { if (is_uploaded_file($_FILES[$tempname]['tmp_name'])) { if (move_uploaded_file($_FILES[$tempname]['tmp_name'], $folder . $name . "_" . $i . "." . $ext)) { SetRightsToUploadedFile($folder . $name . "_" . $i . "." . $ext); $new_tempname = $name . "_" . $i . "." . $ext; } } $taskDone = true; } } } else { if (is_uploaded_file($_FILES[$tempname]['tmp_name'])) { if (move_uploaded_file($_FILES[$tempname]['tmp_name'], $folder . $picture_name)) { SetRightsToUploadedFile($folder . $picture_name); $new_tempname = $picture_name; } } } } return $new_tempname; }
update_psCount(1); } } elseif (isset($_POST["import_db_file"])) { if (CONF_BACKEND_SAFEMODE) { Redirect(ADMIN_FILE . "?dpt=catalog&sub=dbsync&safemode=yes"); } @set_time_limit(0); //upload file if (isset($_FILES["db_file"]) && $_FILES["db_file"]["name"]) { $db_name = "core/temp/" . $_FILES["db_file"]["name"]; if (file_exists($db_name)) { unlink($db_name); } $res = @move_uploaded_file($_FILES["db_file"]["tmp_name"], $db_name); if ($res) { SetRightsToUploadedFile($db_name); $masterfef = $_FILES["db_file"]["name"]; include_once 'core/classes/class.dump.php'; $SK = new dumper(); $SK->SET['masterfef'] = $_FILES["db_file"]["name"]; $SK->restore(); unlink($db_name); $smarty->assign("sync_successful", 1); } else { $smarty->assign("sync_successful", 0); } } else { $smarty->assign("sync_successful", 0); } $smarty->assign("sync_action", "import"); } elseif (isset($_POST["full_export"])) {