$prev_file_query = tep_db_query("select authors_image from " . TABLE_AUTHORS . " where authors_id = '" . (int) $authors_id . "'"); $prev_file = tep_db_fetch_array($prev_file_query); if (tep_not_null($prev_file['authors_image']) && $prev_file['authors_image'] != $upload->filename) { @unlink(DIR_FS_CATALOG_IMAGES . $prev_file['authors_image']); } if (AUTHOR_IMAGE_WIDTH > 0 || AUTHOR_IMAGE_HEIGHT > 0) { tep_create_thumb(DIR_FS_CATALOG_IMAGES . $upload->filename, '', AUTHOR_IMAGE_WIDTH, AUTHOR_IMAGE_HEIGHT); if (!is_dir(DIR_FS_CATALOG_IMAGES . 'authors/thumbs')) { mkdir(DIR_FS_CATALOG_IMAGES . 'authors/thumbs', 0777); } tep_create_thumb(DIR_FS_CATALOG_IMAGES . $upload->filename, DIR_FS_CATALOG_IMAGES . str_replace('authors/', 'authors/thumbs/', $upload->filename), 50, 70); } tep_db_query("update " . TABLE_AUTHORS . " set authors_image = '" . $upload->filename . "' where authors_id = '" . (int) $authors_id . "'"); } } tep_update_blocks($authors_id, 'author'); tep_redirect(tep_href_link(FILENAME_AUTHORS, 'search=' . urlencode($search) . '&page=' . $HTTP_GET_VARS['page'] . '&aID=' . $authors_id)); break; case 'deleteconfirm': $authors_id = tep_db_prepare_input($HTTP_GET_VARS['aID']); if (isset($HTTP_POST_VARS['delete_image']) && $HTTP_POST_VARS['delete_image'] == 'on') { $author_query = tep_db_query("select authors_image from " . TABLE_AUTHORS . " where authors_id = '" . (int) $authors_id . "'"); $author = tep_db_fetch_array($author_query); $image_location = DIR_FS_CATALOG . DIR_WS_CATALOG_IMAGES . $author['authors_image']; if (file_exists($image_location)) { @unlink($image_location); } } tep_remove_author($authors_id); if (isset($HTTP_POST_VARS['delete_products']) && $HTTP_POST_VARS['delete_products'] == 'on') { $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where authors_id = '" . (int) $authors_id . "'");
$description = str_replace('\\"', '"', $description); $description = str_replace("\\\\'", "\\'", $description); $description = str_replace('="' . str_replace('http://', 'http://www.', HTTP_SERVER) . '/', '="/', $description); $description = str_replace('="' . HTTP_SERVER . '/', '="/', $description); $description = str_replace(' - ', ' – ', $description); $description = str_replace(' — ', ' – ', $description); $sql_data_array = array('manufacturers_name' => tep_db_prepare_input($manufacturers_name_array[$language_id]), 'manufacturers_description' => $description, 'manufacturers_url' => tep_db_prepare_input($manufacturers_url_array[$language_id])); if ($action == 'insert') { $insert_sql_data = array('manufacturers_id' => $manufacturers_id, 'languages_id' => $language_id); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_MANUFACTURERS_INFO, $sql_data_array); } elseif ($action == 'save') { tep_db_perform(TABLE_MANUFACTURERS_INFO, $sql_data_array, 'update', "manufacturers_id = '" . (int) $manufacturers_id . "' and languages_id = '" . (int) $language_id . "'"); } } tep_update_blocks($manufacturers_id, 'manufacturer'); tep_redirect(tep_href_link(FILENAME_MANUFACTURERS, 'search=' . urlencode($search) . '&page=' . $HTTP_GET_VARS['page'] . '&mID=' . $manufacturers_id)); break; case 'deleteconfirm': $manufacturers_id = tep_db_prepare_input($HTTP_GET_VARS['mID']); if (isset($HTTP_POST_VARS['delete_image']) && $HTTP_POST_VARS['delete_image'] == 'on') { $manufacturer_query = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int) $manufacturers_id . "'"); $manufacturer = tep_db_fetch_array($manufacturer_query); $image_location = DIR_FS_CATALOG . DIR_WS_CATALOG_IMAGES . $manufacturer['manufacturers_image']; if (file_exists($image_location)) { @unlink($image_location); } } tep_remove_manufacturer($manufacturers_id); if (isset($HTTP_POST_VARS['delete_products']) && $HTTP_POST_VARS['delete_products'] == 'on') { $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where manufacturers_id = '" . (int) $manufacturers_id . "'");
$new_filename = $boards_categories_id . $ext; $upload->filename = 'categories/' . $new_filename; if ($upload->upload('image', DIR_FS_CATALOG_IMAGES)) { if (CATEGORY_IMAGE_WIDTH > 0 || CATEGORY_IMAGE_HEIGHT > 0) { tep_create_thumb(DIR_FS_CATALOG_IMAGES . $upload->filename, '', CATEGORY_IMAGE_WIDTH, CATEGORY_IMAGE_HEIGHT); } $prev_file_query = tep_db_query("select image from " . TABLE_BOARDS_CATEGORIES . " where boards_categories_id = '" . (int) $boards_categories_id . "'"); $prev_file = tep_db_fetch_array($prev_file_query); 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']);
while (list(, $linked_id) = each($products_linked)) { if ((int) $linked_id > 0 && $linked_id != $products_id) { tep_db_query("insert into " . TABLE_PRODUCTS_LINKED . " (products_id, linked_id) values ('" . (int) $products_id . "', '" . (int) $linked_id . "')"); } } $information_linked = $HTTP_POST_VARS['information_linked']; if (!is_array($information_linked)) { $information_linked = array(); } tep_db_query("delete from " . TABLE_PRODUCTS_TO_INFORMATION . " where products_id = '" . (int) $products_id . "'"); while (list(, $linked_id) = each($information_linked)) { if ((int) $linked_id > 0) { tep_db_query("insert into " . TABLE_PRODUCTS_TO_INFORMATION . " (products_id, information_id) values ('" . (int) $products_id . "', '" . (int) $linked_id . "')"); } } tep_update_blocks($products_id, 'product'); $images_query = tep_db_query("select products_image, products_id from " . TABLE_PRODUCTS . " where products_image <> ''"); while ($images = tep_db_fetch_array($images_query)) { if (!file_exists(DIR_FS_CATALOG_IMAGES . $images['products_image'])) { if (file_exists(DIR_FS_CATALOG_IMAGES_BIG . $images['products_image'])) { tep_create_thumb(DIR_FS_CATALOG_IMAGES_BIG . $images['products_image'], DIR_FS_CATALOG_IMAGES . $images['products_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); } elseif (file_exists(DIR_FS_CATALOG_IMAGES_MIDDLE . $images['products_image'])) { tep_create_thumb(DIR_FS_CATALOG_IMAGES_MIDDLE . $images['products_image'], DIR_FS_CATALOG_IMAGES . $images['products_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); } else { tep_db_query("update " . TABLE_PRODUCTS . " set products_image = '' where products_id = '" . (int) $images['products_id'] . "'"); } } } tep_redirect(tep_href_link(FILENAME_CATEGORIES, tep_get_all_get_params(array('pID', 'action')) . 'pID=' . $products_id)); } }
$description = str_replace("\\\\'", "\\'", $description); $description = str_replace('="' . str_replace('http://', 'http://www.', HTTP_SERVER) . '/', '="/', $description); $description = str_replace('="' . HTTP_SERVER . '/', '="/', $description); $description = str_replace(' - ', ' – ', $description); $description = str_replace(' — ', ' – ', $description); $additional_description = str_replace('\\\\"', '"', $pages_additional_description_array[$language_id]); $additional_description = str_replace('\\"', '"', $additional_description); $additional_description = str_replace("\\\\'", "\\'", $additional_description); $additional_description = str_replace('="' . str_replace('http://', 'http://www.', HTTP_SERVER) . '/', '="/', $additional_description); $additional_description = str_replace('="' . HTTP_SERVER . '/', '="/', $additional_description); $additional_description = str_replace(' - ', ' – ', $additional_description); $additional_description = str_replace(' — ', ' – ', $additional_description); $sql_data_array = array('last_modified' => 'now()', 'pages_name' => tep_db_prepare_input($pages_name_array[$language_id]), 'pages_additional_description' => $additional_description, 'pages_description' => $description); tep_db_perform(TABLE_PAGES, $sql_data_array, 'update', "pages_id = '" . (int) $pages_id . "' and language_id = '" . (int) $languages[$i]['id'] . "'"); } tep_update_blocks($pages_id, 'page'); tep_redirect(tep_href_link(FILENAME_PAGES, 'pID=' . $pages_id)); break; case 'insert_translation': case 'update_translation': $p_query = tep_db_query("select pages_filename from " . TABLE_PAGES . " where pages_id = '" . (int) $HTTP_GET_VARS['pPath'] . "'"); $p = tep_db_fetch_array($p_query); $error = false; if (isset($HTTP_POST_VARS['translation_id'])) { $translation_id = tep_db_prepare_input($HTTP_POST_VARS['translation_id']); } else { $max_id_query = tep_db_query("select max(pages_translation_id) as new_id from " . TABLE_PAGES_TRANSLATION . ""); $max_id = tep_db_fetch_array($max_id_query); $translation_id = (int) $max_id['new_id'] + 1; } if (isset($HTTP_POST_VARS['translation_key'])) {
} $new_filename .= $ext; $upload->filename = 'series/' . $new_filename; if ($upload->upload('series_image', DIR_FS_CATALOG_IMAGES)) { $prev_file_query = tep_db_query("select series_image from " . TABLE_SERIES . " where series_id = '" . (int) $series_id . "'"); $prev_file = tep_db_fetch_array($prev_file_query); if (tep_not_null($prev_file['series_image']) && $prev_file['series_image'] != $upload->filename) { @unlink(DIR_FS_CATALOG_IMAGES . $prev_file['series_image']); } if (SERIE_IMAGE_WIDTH > 0 || SERIE_IMAGE_HEIGHT > 0) { tep_create_thumb(DIR_FS_CATALOG_IMAGES . $upload->filename, '', SERIE_IMAGE_WIDTH, SERIE_IMAGE_HEIGHT); } tep_db_query("update " . TABLE_SERIES . " set series_image = '" . $upload->filename . "' where series_id = '" . (int) $series_id . "'"); } } tep_update_blocks($series_id, 'serie'); tep_redirect(tep_href_link(FILENAME_SERIES, 'search=' . urlencode($search) . '&page=' . $HTTP_GET_VARS['page'] . '&sID=' . $series_id)); break; case 'deleteconfirm': $series_id = tep_db_prepare_input($HTTP_GET_VARS['sID']); if (isset($HTTP_POST_VARS['delete_image']) && $HTTP_POST_VARS['delete_image'] == 'on') { $serie_query = tep_db_query("select series_image from " . TABLE_SERIES . " where series_id = '" . (int) $series_id . "'"); $serie = tep_db_fetch_array($serie_query); $image_location = DIR_FS_CATALOG . DIR_WS_CATALOG_IMAGES . $serie['series_image']; if (file_exists($image_location)) { @unlink($image_location); } } tep_remove_serie($series_id); if (isset($HTTP_POST_VARS['delete_products']) && $HTTP_POST_VARS['delete_products'] == 'on') { $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where series_id = '" . (int) $series_id . "'");
tep_db_perform($database . '.' . TABLE_NEWS, $sql_data_array); } elseif ($action == 'update_news') { tep_db_perform($database . '.' . TABLE_NEWS, $sql_data_array, 'update', "news_id = '" . (int) $news_id . "' and language_id = '" . (int) $language_id . "'"); } if ($products_discount > 0 && $products_discount < 100 && $HTTP_POST_VARS['news_status'] == '1') { tep_db_query("delete from " . $database . "." . TABLE_SPECIALS . " where products_id in ('" . implode("', '", $news_products) . "') and specials_types_id = '5'"); reset($news_products); while (list(, $product_id) = each($news_products)) { $max_id_query = tep_db_query("select max(specials_id) as max_id from " . $database . "." . TABLE_SPECIALS . ""); $max_id = tep_db_fetch_array($max_id_query); $specials_id = (int) $max_id['max_id'] + 1; tep_db_query("insert into " . $database . "." . TABLE_SPECIALS . " (specials_id, specials_types_id, language_id, products_id, specials_first_page, products_image_exists, specials_new_products_price, specials_date_added, expires_date, status) select '" . (int) $specials_id . "', '5', '" . (int) $languages_id . "', products_id, if((products_image_exists='1' and products_listing_status='1'), 1, 0), products_image_exists, (products_price * (1 - " . $products_discount . " / 100)), now(), '" . tep_db_input($expires_date) . "', products_status from " . $database . "." . TABLE_PRODUCTS . " where products_id = '" . (int) $product_id . "'"); } tep_db_query("update " . $database . "." . TABLE_SPECIALS_TYPES . " set specials_last_modified = now() where specials_types_id = '5'"); } tep_update_blocks($news_id, 'news', $database); $t++; } } if ($upload = new upload('', '', '777', array('jpeg', 'jpg', 'gif', 'png'))) { $size = @getimagesize($news_image); if ($size[2] == '3') { $ext = '.png'; } elseif ($size[2] == '2') { $ext = '.jpg'; } else { $ext = '.gif'; } $new_filename = preg_replace('/[^\\d\\w]/i', '', strtolower($news_path)); if (!tep_not_null($new_filename)) { $new_filename = $news_id;
if (!is_array($information_debug)) { $information_debug = array(); } $sql_data_array['information_debug'] = tep_db_prepare_input(implode(';', $information_debug)); } if ($action == 'insert_information') { $insert_sql_data = array('date_added' => 'now()', 'information_id' => $information_id, 'language_id' => $language_id); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_INFORMATION, $sql_data_array); } elseif ($action == 'update_information') { $update_sql_data = array('last_modified' => 'now()'); $sql_data_array = array_merge($sql_data_array, $update_sql_data); tep_db_perform(TABLE_INFORMATION, $sql_data_array, 'update', "information_id = '" . (int) $information_id . "' and language_id = '" . (int) $language_id . "'"); } } tep_update_blocks($information_id, 'information'); reset($sections); while (list(, $sections_id) = each($sections)) { $sections_count_query = tep_db_query("select count(*) as total from " . TABLE_INFORMATION_TO_SECTIONS . " where information_id = '" . (int) $information_id . "' and sections_id = '" . (int) $sections_id . "'"); $sections_count = tep_db_fetch_array($sections_count_query); if ($sections_count['total'] == '0') { tep_db_query("insert into " . TABLE_INFORMATION_TO_SECTIONS . " (information_id, sections_id) values ('" . (int) $information_id . "', '" . (int) $sections_id . "')"); } } tep_db_query("delete from " . TABLE_INFORMATION_TO_SECTIONS . " where information_id = '" . (int) $information_id . "' and sections_id not in ('" . implode("', '", $sections) . "')"); if ($current_section_id == 0 && $information_path == 'index') { tep_db_query("update " . TABLE_INFORMATION_TO_SECTIONS . " set information_default_status = '1' where information_id = '" . (int) $information_id . "' and sections_id = '" . (int) $current_section_id . "'"); } if ($information_default_status == '1') { tep_db_query("update " . TABLE_INFORMATION_TO_SECTIONS . " set information_default_status = '0' where sections_id = '" . (int) $current_section_id . "'"); }