function zen_remove_product($product_id, $ptc = 'true') { global $db; $product_image = $db->Execute("select products_image\n from " . TABLE_PRODUCTS . "\n where products_id = '" . (int) $product_id . "'"); $duplicate_image = $db->Execute("select count(*) as total\n from " . TABLE_PRODUCTS . "\n where products_image = '" . zen_db_input($product_image->fields['products_image']) . "'"); if ($duplicate_image->fields['total'] < 2 and $product_image->fields['products_image'] != '') { $products_image = $product_image->fields['products_image']; $products_image_extension = substr($products_image, strrpos($products_image, '.')); $products_image_base = ereg_replace($products_image_extension, '', $products_image); $filename_medium = 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extension; $filename_large = 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension; if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image->fields['products_image'])) { @unlink(DIR_FS_CATALOG_IMAGES . $product_image->fields['products_image']); if ($https_product_image = zen_get_https_location(DIR_FS_CATALOG_IMAGES . $product_image->fields['products_image'])) { @unlink($https_product_image); } } if (file_exists(DIR_FS_CATALOG_IMAGES . $filename_medium)) { @unlink(DIR_FS_CATALOG_IMAGES . $filename_medium); if ($https_product_image = zen_get_https_location(DIR_FS_CATALOG_IMAGES . $filename_medium)) { @unlink($https_product_image); } } if (file_exists(DIR_FS_CATALOG_IMAGES . $filename_large)) { @unlink(DIR_FS_CATALOG_IMAGES . $filename_large); if ($https_product_image = zen_get_https_location(DIR_FS_CATALOG_IMAGES . $filename_large)) { @unlink($https_product_image); } } } $db->Execute("delete from " . TABLE_SPECIALS . "\n where products_id = '" . (int) $product_id . "'"); $db->Execute("delete from " . TABLE_PRODUCTS . "\n where products_id = '" . (int) $product_id . "'"); // if ($ptc == 'true') { $db->Execute("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . "\n where products_id = '" . (int) $product_id . "'"); // } $db->Execute("delete from " . TABLE_PRODUCTS_DESCRIPTION . "\n where products_id = '" . (int) $product_id . "'"); $db->Execute("delete from " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . "\n where products_id = '" . (int) $product_id . "'"); zen_products_attributes_download_delete($product_id); $db->Execute("delete from " . TABLE_PRODUCTS_ATTRIBUTES . "\n where products_id = '" . (int) $product_id . "'"); $db->Execute("delete from " . TABLE_CUSTOMERS_BASKET . "\n where products_id = '" . (int) $product_id . "'"); $db->Execute("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . "\n where products_id = '" . (int) $product_id . "'"); $product_reviews = $db->Execute("select reviews_id\n from " . TABLE_REVIEWS . "\n where products_id = '" . (int) $product_id . "'"); while (!$product_reviews->EOF) { $db->Execute("delete from " . TABLE_REVIEWS_DESCRIPTION . "\n where reviews_id = '" . (int) $product_reviews->fields['reviews_id'] . "'"); $product_reviews->MoveNext(); } $db->Execute("delete from " . TABLE_REVIEWS . "\n where products_id = '" . (int) $product_id . "'"); $db->Execute("delete from " . TABLE_FEATURED . "\n where products_id = '" . (int) $product_id . "'"); $db->Execute("delete from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . "\n where products_id = '" . (int) $product_id . "'"); }
break; case 'deleteconfirm': // demo active test if (zen_admin_demo()) { $_GET['action'] = ''; $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution'); zen_redirect(zen_href_link(FILENAME_MANUFACTURERS, 'page=' . $_GET['page'])); } $manufacturers_id = zen_db_prepare_input($_GET['mID']); if (isset($_POST['delete_image']) && $_POST['delete_image'] == 'on') { $manufacturer = $db->Execute("select manufacturers_image\r\n from " . TABLE_MANUFACTURERS . "\r\n where manufacturers_id = '" . (int) $manufacturers_id . "'"); $image_location = DIR_FS_CATALOG_IMAGES . $manufacturer->fields['manufacturers_image']; if (file_exists($image_location)) { @unlink($image_location); } if ($https_image_location = zen_get_https_location($image_location)) { if (file_exists($https_image_location)) { @unlink($https_image_location); } } } $db->Execute("delete from " . TABLE_MANUFACTURERS . "\r\n where manufacturers_id = '" . (int) $manufacturers_id . "'"); $db->Execute("delete from " . TABLE_MANUFACTURERS_INFO . "\r\n where manufacturers_id = '" . (int) $manufacturers_id . "'"); if (isset($_POST['delete_products']) && $_POST['delete_products'] == 'on') { $products = $db->Execute("select products_id\r\n from " . TABLE_PRODUCTS . "\r\n where manufacturers_id = '" . (int) $manufacturers_id . "'"); while (!$products->EOF) { zen_remove_product($products->fields['products_id']); $products->MoveNext(); } } else { $db->Execute("update " . TABLE_PRODUCTS . "\r\n set manufacturers_id = ''\r\n where manufacturers_id = '" . (int) $manufacturers_id . "'");
function save($overwrite = true) { global $messageStack; if (!$overwrite and file_exists($this->destination . $this->filename)) { $messageStack->add_session(TEXT_IMAGE_OVERWRITE_WARNING . $this->filename, 'caution'); return true; } else { if (substr($this->destination, -1) != '/') { $this->destination .= '/'; } if (move_uploaded_file($this->file['tmp_name'], $this->destination . $this->filename)) { chmod($this->destination . $this->filename, $this->permissions); if ($https_destination = zen_get_https_location($this->destination . $this->filename)) { if (copy($this->destination . $this->filename, $https_destination)) { chmod($https_destination, $this->permissions); } } if ($this->message_location == 'direct') { $messageStack->add(sprintf(SUCCESS_FILE_SAVED_SUCCESSFULLY, $this->filename), 'success'); } else { $messageStack->add_session(sprintf(SUCCESS_FILE_SAVED_SUCCESSFULLY, $this->filename), 'success'); } return true; } else { if ($this->message_location == 'direct') { $messageStack->add(ERROR_FILE_NOT_SAVED, 'error'); } else { $messageStack->add_session(ERROR_FILE_NOT_SAVED, 'error'); } return false; } } }
} else { $db->Execute("update " . TABLE_BANNERS . "\r\n set date_scheduled = null\r\n where banners_id = '" . (int) $banners_id . "'"); } zen_redirect(zen_href_link(FILENAME_BANNER_MANAGER, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'bID=' . $banners_id)); } else { $action = 'new'; } break; case 'deleteconfirm': $banners_id = zen_db_prepare_input($_GET['bID']); if (isset($_POST['delete_image']) && $_POST['delete_image'] == 'on') { $banner = $db->Execute("select banners_image\r\n from " . TABLE_BANNERS . "\r\n where banners_id = '" . (int) $banners_id . "'"); if (is_file(DIR_FS_CATALOG_IMAGES . $banner->fields['banners_image'])) { if (is_writeable(DIR_FS_CATALOG_IMAGES . $banner->fields['banners_image'])) { unlink(DIR_FS_CATALOG_IMAGES . $banner->fields['banners_image']); if ($https_banners_image = zen_get_https_location(DIR_FS_CATALOG_IMAGES . $banner->fields['banners_image'])) { @unlink($https_banners_image); } } else { $messageStack->add_session(ERROR_IMAGE_IS_NOT_WRITEABLE, 'error'); } } else { $messageStack->add_session(ERROR_IMAGE_DOES_NOT_EXIST, 'error'); } } $db->Execute("delete from " . TABLE_BANNERS . "\r\n where banners_id = '" . (int) $banners_id . "'"); $db->Execute("delete from " . TABLE_BANNERS_HISTORY . "\r\n where banners_id = '" . (int) $banners_id . "'"); if (function_exists('imagecreate') && zen_not_null($banner_extension)) { if (is_file(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banners_id . '.' . $banner_extension)) { if (is_writeable(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banners_id . '.' . $banner_extension)) { unlink(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banners_id . '.' . $banner_extension);