示例#1
0
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':
            wdcat_editProduct($id);
            break;
        case 'add_prad':
            wdcat_addProduct();
            break;
        case 'apply':
            if ($id) {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                wdcat_update_prad_cat($id);
            } else {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                wdcat_save_prad_cat();
                $id = $wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "spidercatalog_products");
            }
            wdcat_editProduct($id);
            break;
        case 'save':
            if ($id) {
                wdcat_update_prad_cat($id);
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            } else {
                check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
                wdcat_save_prad_cat();
            }
            wdcat_showProducts();
            break;
        case 'saveorder':
            break;
        case 'publish':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            wdcat_publish_all(TRUE);
            wdcat_showProducts();
            break;
        case 'unpublish':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            wdcat_publish_all(FALSE);
            wdcat_showProducts();
            break;
        case 'delete':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            wdcat_delete_all();
            wdcat_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?");
            }
            wdcat_change_prod($id);
            wdcat_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?");
            }
            wdcat_change_prod($id);
            wdcat_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?");
            }
            wdcat_removeProduct($id);
            wdcat_showProducts();
            break;
        case 'edit_reviews':
            spider_cat_prod_rev($id);
            break;
        case 'delete_reviews':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            wdcat_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?");
            }
            wdcat_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');
            wdcat_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?");
            }
            wdcat_delete_single_rating($id);
            spider_cat_prod_rating($id);
            break;
        case 's_p_apply_rating':
            check_admin_referer('nonce_sp_cat', 'nonce_sp_cat');
            wdcat_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');
            wdcat_update_s_c_rating($id);
            wdcat_editProduct($id);
            break;
        default:
            wdcat_showProducts();
            break;
    }
}
示例#2
0
function wdcat_delete_all()
{
    global $wpdb;
    $ids = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'spidercatalog_products');
    foreach ($ids as $id) {
        if (isset($_POST['check_' . $id])) {
            wdcat_removeProduct($id);
        }
    }
    return true;
}