function Products_Spider_Catalog()
{
    global $wpdb;
    require_once "products.php";
    require_once "Products.html.php";
    if (!function_exists('print_html_nav')) {
        require_once "nav_function/nav_html_func.php";
    }
    if (isset($_GET['id'])) {
        $id = $_GET['id'];
    } else {
        $id = 0;
    }
    if (isset($_GET['task'])) {
        $task = $_GET['task'];
    } else {
        $task = "";
    }
    switch ($task) {
        case 'edit_prad':
            editProduct($id);
            break;
        case 'add_prad':
            addProduct();
            break;
        case 'apply':
            if ($id) {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                update_prad_cat($id);
            } else {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                save_prad_cat();
                $id = $wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "spidercatalog_products");
            }
            editProduct($id);
            break;
        case 'save':
            if ($id) {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                update_prad_cat($id);
            } else {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                save_prad_cat();
            }
            showProducts();
            break;
        case 'saveorder':
            break;
        case 'publish':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            publish_all(TRUE);
            showProducts();
            break;
        case 'unpublish':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            publish_all(FALSE);
            showProducts();
            break;
        case 'delete':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            delete_all();
            showProducts();
            break;
        case 'unpublish_prad':
            $nonce_sp_cat = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_cat, 'nonce_sp_cat')) {
                die("Are you sure you want to do this?");
            }
            change_prod($id);
            showProducts();
            break;
        case 'unpublish_prad':
            $nonce_sp_cat = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_cat, 'nonce_sp_cat')) {
                die("Are you sure you want to do this?");
            }
            change_prod($id);
            showProducts();
            break;
        case 'remove_prod':
            $nonce_sp_cat = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_cat, 'nonce_sp_cat')) {
                die("Are you sure you want to do this?");
            }
            removeProduct($id);
            showProducts();
            break;
        case 'edit_reviews':
            spider_cat_prod_rev($id);
            break;
        case 'delete_reviews':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            delete_rev($id);
            spider_cat_prod_rev($id);
            break;
        case 'delete_review':
            $nonce_sp_cat = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_cat, 'nonce_sp_cat')) {
                die("Are you sure you want to do this?");
            }
            delete_single_review($id);
            spider_cat_prod_rev($id);
            break;
        case 'edit_rating':
            spider_cat_prod_rating($id);
            break;
        case 'delete_ratings':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            delete_ratings($id);
            spider_cat_prod_rating($id);
            break;
        case 'delete_rating':
            $nonce_sp_cat = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_cat, 'nonce_sp_cat')) {
                die("Are you sure you want to do this?");
            }
            delete_single_rating($id);
            spider_cat_prod_rating($id);
            break;
        case 's_p_apply_rating':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            update_s_c_rating($id);
            spider_cat_prod_rating($id);
            break;
        case 's_p_save_rating':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            update_s_c_rating($id);
            editProduct($id);
            break;
        default:
            showProducts();
            break;
    }
}
$task = $params->get('task');
switch ($task) {
    case 'add_product':
        addProduct();
        break;
    case 'show_products':
        showProducts();
        break;
    case 'show_products_delete':
        showProductsDelete();
        break;
    case 'create_category':
        createCategory();
        break;
    default:
        showProducts();
        break;
}
function addProduct()
{
    global $mainframe, $_POST, $database, $my;
    //STEP 3
    //store in database
    if (isset($_POST["asin"])) {
        $_POST["asin"] = stripslashes($_POST["asin"]);
        $_POST["amazon_price"] = stripslashes($_POST["amazon_price"]);
        $_POST["amazon_new_price"] = stripslashes($_POST["amazon_new_price"]);
        $_POST["amazon_used_price"] = stripslashes($_POST["amazon_used_price"]);
        $_POST["amazon_remind"] = stripslashes($_POST["amazon_remind"]);
        $_POST["amazon_3rd_new_remind"] = stripslashes($_POST["amazon_3rd_new_remind"]);
        $_POST["amazon_3rd_used_remind"] = stripslashes($_POST["amazon_3rd_used_remind"]);