function smn_delete_store($prefix)
{
    global $languages;
    if ($prefix != '') {
        $DB_tables = array(TABLE_ADMIN, TABLE_CATEGORIES, TABLE_CATEGORIES_DESCRIPTION, TABLE_CONFIGURATION, TABLE_LANGUAGES, TABLE_NEWSLETTERS, TABLE_ORDERS_TRACKING, TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD, TABLE_PRODUCTS_NOTIFICATIONS, TABLE_PRODUCTS_OPTIONS, TABLE_PRODUCTS_OPTIONS_VALUES, TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS, TABLE_REVIEWS, TABLE_REVIEWS_DESCRIPTION, TABLE_TAX_CLASS, TABLE_TAX_RATES, TABLE_GEO_ZONES, TABLE_ZONES_TO_GEO_ZONES, TABLE_ARTICLES, TABLE_WEB_SITE_CONTENT, TABLE_DYNAMIC_PAGE_INDEX, TABLE_SPECIALS, TABLE_STORE_MAIN, TABLE_STORE_COSTS, TABLE_STORE_TO_CATEGORIES, TABLE_STORE_DESCRIPTION, TABLE_STORE_REVIEWS, TABLE_MEMBER_ORDERS);
        //delete all DB table rows associated with the store....
        foreach ($DB_tables as $table_name) {
            smn_db_query("delete from " . $table_name . " WHERE store_id = '" . $prefix . "'");
        }
        //remove products from system
        $product_categories_query = smn_db_query("select products_id from " . TABLE_PRODUCTS . " where store_id = '" . (int) $prefix . "'");
        while ($product_categories = smn_db_fetch_array($product_categories_query)) {
            $product_id = (int) $product_categories['products_id'];
            smn_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            smn_db_query("delete from " . TABLE_PRODUCTS . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            smn_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            smn_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $product_id . "'");
            smn_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            smn_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            smn_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            $product_reviews_query = smn_db_query("select reviews_id from " . TABLE_REVIEWS . " where products_id = '" . $product_id . "'");
            while ($product_reviews = smn_db_fetch_array($product_reviews_query)) {
                smn_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . $product_reviews['reviews_id'] . "' and store_id = '" . (int) $prefix . "'");
            }
            smn_db_query("delete from " . TABLE_REVIEWS . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            if (USE_CACHE == 'true') {
                smn_reset_cache_block('categories');
                smn_reset_cache_block('also_purchased');
            }
        }
        //remove orders from system
        $store_orders_query = smn_db_query("select orders_id from " . TABLE_ORDERS . " where store_id = '" . (int) $prefix . "'");
        while ($store_orders = smn_db_fetch_array($store_orders_query)) {
            smn_db_query("delete from " . TABLE_ORDERS_TRACKING . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
            smn_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
            smn_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
            smn_db_query("delete from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
            smn_db_query("delete from " . TABLE_ORDERS_STATUS_HISTORY . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
            smn_db_query("delete from " . TABLE_ORDERS_TOTAL . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
        }
        //delete the stores image directory and files from the system
        $dir = DIR_FS_CATALOG . 'images/' . $prefix . '_images';
        smn_deldir($dir);
        /*
            //delete any saved orders in the DB tables associated with this store		
           $saved_store_order_query = smn_db_query("select saved_order_id from " . TABLE_SAVED_ORDERS . " WHERE saved_store_id = '". $prefix_id ."'");
           if (smn_db_num_rows($store_query)){	
              while ($saved_store_order = smn_db_fetch_array($saved_store_order_query)){
                 smn_db_query("delete from " . TABLE_SAVED_ORDERS_PRODUCTS . " where saved_order_id = '" . $saved_store_order['saved_order_id'] . "'");
                 smn_db_query("delete from " . TABLE_SAVED_ORDERS_PRODUCTS_ATTRIBUTES . " where saved_order_id = '" . $saved_store_order['saved_order_id'] . "'");
              }
                  
              smn_db_query("delete from " . TABLE_SAVED_ORDERS . " where saved_store_id = '". $prefix_id ."'");
           }*/
    }
    return $store_deleted = 'true';
}
       }
     } elseif ($_POST['copy_as'] == 'duplicate') {
       $product_query = smn_db_query("select store_id, products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
       $product = smn_db_fetch_array($product_query);
       smn_db_query("insert into " . TABLE_PRODUCTS . " (store_id, products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . (int)$store_id . "', '" . smn_db_input($product['products_quantity']) . "', '" . smn_db_input($product['products_model']) . "', '" . smn_db_input($product['products_image']) . "', '" . smn_db_input($product['products_price']) . "',  now(), '" . smn_db_input($product['products_date_available']) . "', '" . smn_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");
       $dup_products_id = smn_db_insert_id();
       $description_query = smn_db_query("select language_id, products_name, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
       while ($description = smn_db_fetch_array($description_query)) {
         smn_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . smn_db_input($description['products_name']) . "', '" . smn_db_input($description['products_description']) . "', '" . smn_db_input($description['products_head_title_tag']) . "', '" . smn_db_input($description['products_head_desc_tag']) . "', '" . smn_db_input($description['products_head_keywords_tag']) . "', '" . smn_db_input($description['products_url']) . "', '0')");
       }    
       smn_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (store_id, products_id, categories_id) values ('" . (int)$store_id . "', '" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
       $products_id = $dup_products_id;
     }
     if (USE_CACHE == 'true') {
       smn_reset_cache_block('categories');
       smn_reset_cache_block('also_purchased');
     }
   }
   smn_redirect(html_entity_decode(smn_href_link(FILENAME_STORE_PRODUCT_CATEGORIES, 'cPath=' . $categories_id . '&ID='.$store_id.'&pID=' . $products_id)));
   break;
 case 'new_product_preview':
     if (! checkVoucherPermissions($store_id, $_POST['products_model'])) {
       $messageStack->add(ERROR_VENDORS_CANT_ADD_VOUCHERS, 'error');
       $allow_insert = 'false';
     } else {
       // copy image only if modified
       $allowed_files_types = array('gif', 'jpg', 'jpeg', 'png');
       $products_image = new upload('products_image');
       $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
       $products_image->set_extensions($allowed_files_types);  
       if ($products_image->parse() && $products_image->save()) {
Example #3
0
  SystemsManager Technologies
  oscMall System Version 4
  http://www.systemsmanager.net
  
  Portions Copyright (c) 2002 osCommerce
  
  This source file is subject to version 2.0 of the GPL license,   
  that is bundled with this package in the file LICENSE. If you
  did not receive a copy of the oscMall System license and are unable 
  to obtain it through the world-wide-web, please send a note to    
  license@systemsmanager.net so we can mail you a copy immediately.
*/
require 'includes/application_top.php';
$action = isset($_GET['action']) ? $_GET['action'] : '';
if (smn_not_null($action)) {
    if ($action == 'reset') {
        smn_reset_cache_block($_GET['block']);
    }
    smn_redirect(smn_href_link(FILENAME_CACHE));
}
// check if the cache directory exists
if (is_dir(DIR_FS_CACHE)) {
    if (!is_writeable(DIR_FS_CACHE)) {
        $messageStack->add(ERROR_CACHE_DIRECTORY_NOT_WRITEABLE, 'error');
    }
} else {
    $messageStack->add(ERROR_CACHE_DIRECTORY_DOES_NOT_EXIST, 'error');
}
$content_page = basename($_SERVER['PHP_SELF']);
require 'templates/default/layout.php';
require DIR_WS_INCLUDES . 'application_bottom.php';
Example #4
0
function smn_remove_product($product_id)
{
    global $store_id;
    $product_image_query = smn_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int) $product_id . "' and store_id = '" . $store_id . "'");
    $product_image = smn_db_fetch_array($product_image_query);
    $duplicate_image_query = smn_db_query("select count(*) as total from " . TABLE_PRODUCTS . " where products_image = '" . smn_db_input($product_image['products_image']) . "' and store_id = '" . $store_id . "'");
    $duplicate_image = smn_db_fetch_array($duplicate_image_query);
    if ($duplicate_image['total'] < 2) {
        if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image['products_image'])) {
            @unlink(DIR_FS_CATALOG_IMAGES . $product_image['products_image']);
        }
    }
    smn_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . (int) $product_id . "' and store_id = '" . $store_id . "'");
    smn_db_query("delete from " . TABLE_PRODUCTS . " where products_id = '" . (int) $product_id . "' and store_id = '" . $store_id . "'");
    smn_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int) $product_id . "' and store_id = '" . $store_id . "'");
    smn_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int) $product_id . "'");
    smn_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int) $product_id . "' and store_id = '" . $store_id . "'");
    smn_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . (int) $product_id . "' and store_id = '" . $store_id . "'");
    smn_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . (int) $product_id . "' and store_id = '" . $store_id . "'");
    $product_reviews_query = smn_db_query("select reviews_id from " . TABLE_REVIEWS . " where products_id = '" . (int) $product_id . "'");
    while ($product_reviews = smn_db_fetch_array($product_reviews_query)) {
        smn_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int) $product_reviews['reviews_id'] . "' and store_id = '" . $store_id . "'");
    }
    smn_db_query("delete from " . TABLE_REVIEWS . " where products_id = '" . (int) $product_id . "' and store_id = '" . $store_id . "'");
    if (USE_CACHE == 'true') {
        smn_reset_cache_block('categories');
        smn_reset_cache_block('also_purchased');
    }
}
Example #5
0
function copy_to_confirm()
{
    if (isset($_POST['list_store_id']) && isset($_POST['store_categories_id'])) {
        $list_store_id = smn_db_prepare_input($_POST['list_store_id']);
        $store_categories_id = smn_db_prepare_input($_POST['store_categories_id']);
        if ($_POST['copy_as'] == 'link') {
            if ($store_categories_id != $current_store_category_id) {
                $check_query = smn_db_query("select count(*) as total from " . TABLE_STORE_TO_CATEGORIES . " where store_id = '" . (int) $list_store_id . "' and store_categories_id = '" . (int) $store_categories_id . "'");
                $check = smn_db_fetch_array($check_query);
                if ($check['total'] < '1') {
                    smn_db_query("insert into " . TABLE_STORE_TO_CATEGORIES . " (store_id, store_categories_id) values ('" . (int) $list_store_id . "', '" . (int) $store_categories_id . "')");
                }
            } else {
                $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');
            }
        } elseif ($_POST['copy_as'] == 'duplicate') {
            $store_query = smn_db_query("select store_image, store_status  from " . TABLE_STORE_MAIN . " where store_id = '" . (int) $list_store_id . "'");
            $store_arr = smn_db_fetch_array($store_query);
            smn_db_query("insert into " . TABLE_STORE_MAIN . " (store_image, date_added, store_status) values ('" . smn_db_input($store_arr['store_image']) . "', now(), '0')");
            $dup_store_id = smn_db_insert_id();
            $description_query = smn_db_query("select language_id, store_name, store_description from " . TABLE_STORE_DESCRIPTION . " where store_id = '" . (int) $list_store_id . "'");
            while ($description = smn_db_fetch_array($description_query)) {
                smn_db_query("insert into " . TABLE_STORE_DESCRIPTION . " (store_id, language_id, store_name, store_description, store_viewed) values ('" . (int) $dup_store_id . "', '" . (int) $description['language_id'] . "', '" . smn_db_input($description['store_name']) . "', '" . smn_db_input($description['store_description']) . "', '0')");
            }
            smn_db_query("insert into " . TABLE_STORE_TO_CATEGORIES . " (store_id, store_categories_id) values ('" . (int) $dup_store_id . "', '" . (int) $store_categories_id . "')");
            $list_store_id = $dup_store_id;
        }
        if (USE_CACHE == 'true') {
            smn_reset_cache_block('store_categories');
            smn_reset_cache_block('also_purchased');
        }
    }
    smn_redirect(smn_href_link(FILENAME_MANAGEMENT, 'sPath=' . $store_categories_id . '&sID=' . $list_store_id));
}
            break;
        case 'deleteconfirm':
            $manufacturers_id = smn_db_prepare_input($_GET['mID']);
            if (isset($_POST['delete_image']) && $_POST['delete_image'] == 'on') {
                $manufacturer_query = smn_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int) $manufacturers_id . "'");
                $manufacturer = smn_db_fetch_array($manufacturer_query);
                $image_location = DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG_IMAGES . $manufacturer['manufacturers_image'];
                if (file_exists($image_location)) {
                    @unlink($image_location);
                }
            }
            smn_db_query("delete from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int) $manufacturers_id . "'");
            smn_db_query("delete from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int) $manufacturers_id . "'");
            if (isset($_POST['delete_products']) && $_POST['delete_products'] == 'on') {
                $products_query = smn_db_query("select products_id from " . TABLE_PRODUCTS . " where manufacturers_id = '" . (int) $manufacturers_id . "'");
                while ($products = smn_db_fetch_array($products_query)) {
                    smn_remove_product($products['products_id']);
                }
            } else {
                smn_db_query("update " . TABLE_PRODUCTS . " set manufacturers_id = '' where manufacturers_id = '" . (int) $manufacturers_id . "'");
            }
            if (USE_CACHE == 'true') {
                smn_reset_cache_block('manufacturers');
            }
            smn_redirect(smn_href_link(FILENAME_MANUFACTURERS, 'page=' . $_GET['page']));
            break;
    }
}
$content_page = basename($_SERVER['PHP_SELF']);
require 'templates/default/layout.php';
require DIR_WS_INCLUDES . 'application_bottom.php';
Example #7
0
function smn_remove_store($category_id)
{
    $category_image_query = smn_db_query("select store_categories_image from " . TABLE_STORE_CATEGORIES . " where store_categories_id = '" . (int) $category_id . "'");
    $category_image = smn_db_fetch_array($category_image_query);
    $duplicate_image_query = smn_db_query("select count(*) as total from " . TABLE_STORE_CATEGORIES . " where store_categories_image = '" . smn_db_input($category_image['store_categories_image']) . "'");
    $duplicate_image = smn_db_fetch_array($duplicate_image_query);
    if ($duplicate_image['total'] < 2) {
        if (file_exists(DIR_FS_CATALOG_IMAGES . $category_image['store_categories_image'])) {
            @unlink(DIR_FS_CATALOG_IMAGES . $category_image['store_categories_image']);
        }
    }
    smn_db_query("delete from " . TABLE_STORE_CATEGORIES . " where store_categories_id = '" . (int) $store_categories_id . "'");
    smn_db_query("delete from " . TABLE_STORE_CATEGORIES_DESCRIPTION . " where store_categories_id = '" . (int) $store_categories_id . "'");
    smn_db_query("delete from " . TABLE_STORE_TO_CATEGORIES . " where store_categories_id = '" . (int) $store_categories_id . "'");
    if (USE_CACHE == 'true') {
        smn_reset_cache_block('store_categories');
    }
}