* @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: product.php 4279 2006-08-26 03:31:29Z drbyte $
 */
require 'includes/application_top.php';
require DIR_WS_MODULES . 'prod_cat_header_code.php';
$action = isset($_GET['action']) ? $_GET['action'] : '';
if (zen_not_null($action)) {
    ///////////////////// BEGIN GOOGLEBASE /////////////////////////////
    require_once DIR_FS_CATALOG_MODULES . 'googlebase/googlebase.php';
    if ($action == 'delete_product_confirm') {
        $gb = new googlebase();
        #echo $action.'<br>'.zen_db_insert_id(); die;
        if (zen_not_null($_POST['products_id'])) {
            $gb->handleProductModification($action, $_POST['products_id']);
        }
    }
    ///////////////////// END GOOGLEBASE /////////////////////////////
    switch ($action) {
        case 'setflag':
            if ($_GET['flag'] == '0' || $_GET['flag'] == '1') {
                if (isset($_GET['pID'])) {
                    zen_set_product_status($_GET['pID'], $_GET['flag']);
                }
            }
            zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&pID=' . $_GET['pID'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
            break;
        case 'delete_product_confirm':
            $delete_linked = 'true';
            if ($_POST['delete_linked'] == 'delete_linked_no') {
        $k = max($oiheight / $small_height, $oiwidth / $small_width);
        //use smallest size
        $small_width = round($oiwidth / $k);
        $small_height = round($oiheight / $k);
        $k = max($oiheight / $medium_height, $oiwidth / $medium_width);
        //use smallest size
        $medium_width = round($oiwidth / $k);
        $medium_height = round($oiheight / $k);
        $large_width = $oiwidth;
        $large_height = $oiheight;
        $products_image = zen_get_products_image((int) $products_id);
        $products_image_extension = substr($products_image, strrpos($products_image, '.'));
        $products_image_base = ereg_replace($products_image_extension, '', $products_image);
        $filename_medium = DIR_FS_CATALOG . DIR_WS_IMAGES . 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . '.' . $fname[2];
        $filename_large = DIR_FS_CATALOG . DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . '.' . $fname[2];
        // ImageMagick
        if (IMAGE_MANAGER_HANDLER == '1') {
            copy($src, $filename_large);
            copy($src, $filename_medium);
            exec(DIR_IMAGEMAGICK . "mogrify -geometry " . $large_width . " " . $filename_large);
            exec(DIR_IMAGEMAGICK . "mogrify -geometry " . $medium_width . " " . $filename_medium);
            exec(DIR_IMAGEMAGICK . "mogrify -geometry " . $small_width . " " . $filename_small);
        }
    }
    ////////////////// BEGIN GOOGLEBASE /////////////////////////
    require_once DIR_FS_CATALOG_MODULES . 'googlebase/googlebase.php';
    $gb = new googlebase();
    $gb->handleProductModification($action, $products_id);
    ////////////////// END GOOGLEBASE /////////////////////////
    zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
}