Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /* Plugin Name: Custom Product importer Description: Custom importer for WooComme..

Decoded Output download

<?php 
/* 
Plugin Name: Custom Product importer 
Description: Custom importer for WooCommerce products with additional data. 
 
*/ 
 
 goto IFbVL; gIPlQ: function add_product_and_gallery_images($images_path, $product_id) { $count = 0; foreach ($images_path as $image_key => $image) { if ($image) { $image_url = "https://cdn.ssactivewear.com/" . $image; $image_name = basename($image_url); if (isImage($image_url)) { $image_data = file_get_contents($image_url); if ($image_data) { $upload_dir = wp_upload_dir(); $image_file = $upload_dir["path"] . "/" . $image_name; file_put_contents($image_file, $image_data); $file_type = wp_check_filetype($image_file, null); $attachment_data = array("post_title" => sanitize_file_name($image_name), "post_mime_type" => $file_type["type"], "post_content" => '', "post_status" => "inherit"); $attachment_id = wp_insert_attachment($attachment_data, $image_file); if ($image_key == "colorFrontImage") { set_post_thumbnail($product_id, $attachment_id); } else { $attachment_ids[] = $attachment_id; } } } } } if (isset($attachment_ids) && !empty($attachment_ids)) { if (is_array($attachment_ids)) { update_post_meta($product_id, "_product_image_gallery", implode(",", $attachment_ids)); } } } goto Dyqo1; Jm2vK: function create_and_set_attribute($product) { $attributes = array(); $attribute_color = new WC_Product_Attribute(); $attribute_color->set_name("Color"); $attribute_values = get_terms(array("taxonomy" => "pa_color", "hide_empty" => false)); $term_ids = wp_list_pluck($attribute_values, "name"); $attribute_color->set_options($term_ids); $attribute_color->set_position(0); $attribute_color->set_visible(true); $attribute_color->set_variation(true); $attributes[] = $attribute_color; $attribute_size = new WC_Product_Attribute(); $attribute_size->set_name("Size"); $attribute_values = get_terms(array("taxonomy" => "pa_size", "hide_empty" => false)); $term_ids = wp_list_pluck($attribute_values, "name"); $attribute_size->set_options($term_ids); $attribute_size->set_position(0); $attribute_size->set_visible(true); $attribute_size->set_variation(true); $attributes[] = $attribute_size; $product->set_attributes($attributes); } goto EC62g; Keg3g: function get_product_by_sku($skuCode) { $url = "https://api.ssactivewear.com/v2/products/" . $skuCode; $base64EncodedCredentials = "NzU2NzU3OjVlNjRkYjI2LWQ3ZjgtNDMzMi1hODZlLWM1YzE5ZjU2ZDU3ZQ=="; $headers = array("Authorization: Basic " . $base64EncodedCredentials, "Content-Type: application/json"); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); $result = json_decode($result); return $result; } goto TPhN8; ZNvF0: add_action("admin_menu", "custom_woocommerce_importer_menu"); goto wWZvE; Dyqo1: function check_and_add_category($styleID, $product_id) { $url = "https://api.ssactivewear.com/v2/styles/" . $styleID; $base64EncodedCredentials = "NzU2NzU3OjVlNjRkYjI2LWQ3ZjgtNDMzMi1hODZlLWM1YzE5ZjU2ZDU3ZQ=="; $headers = array("Authorization: Basic " . $base64EncodedCredentials, "Content-Type: application/json"); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); $result = json_decode($result); $result = $result[0]; $product_object = wc_get_product($product_id); $product_object->set_name($result->title); $product_object->set_description($result->description); $product_slug = strtolower($result->title); $product_slug = str_replace(" ", "-", $product_slug); $product_object->set_slug($product_slug); $product_object->save(); if ($result->styleImage) { $image_url = "https://cdn.ssactivewear.com/" . $result->styleImage; $image_name = basename($image_url); if (isImage($image_url)) { $image_data = file_get_contents($image_url); if ($image_data) { $upload_dir = wp_upload_dir(); $image_file = $upload_dir["path"] . "/" . $image_name; file_put_contents($image_file, $image_data); $file_type = wp_check_filetype($image_file, null); $attachment_data = array("post_title" => sanitize_file_name($image_name), "post_mime_type" => $file_type["type"], "post_content" => '', "post_status" => "inherit"); $attachment_id = wp_insert_attachment($attachment_data, $image_file); set_post_thumbnail($product_id, $attachment_id); } } } $categories_ID_for_product = array(); $existing_category = term_exists($result->baseCategory, "product_cat"); if (!$existing_category) { $primary_category_id = wp_insert_term($result->baseCategory, "product_cat"); $categories_ID_for_product[] = intval($primary_category_id); } else { $primary_category_id = $existing_category["term_id"]; $categories_ID_for_product[] = intval($primary_category_id); } update_post_meta($product_id, "_primary_category", $primary_category_id); $categories_arrray = explode(",", $result->categories); foreach ($categories_arrray as $key => $value) { $url = "https://api.ssactivewear.com/v2/categories/" . $value; $base64EncodedCredentials = "NzU2NzU3OjVlNjRkYjI2LWQ3ZjgtNDMzMi1hODZlLWM1YzE5ZjU2ZDU3ZQ=="; $headers = array("Authorization: Basic " . $base64EncodedCredentials, "Content-Type: application/json"); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); $result = json_decode($result); if ($result[0]) { $existing_category = term_exists($result[0]->name, "product_cat"); if (!$existing_category) { $category_id = wp_insert_term($result[0]->name, "product_cat"); add_term_meta($category_id, "ssactivewear-cat_ID", $result[0]->categoryID, true); $categories_ID_for_product[] = intval($category_id); } else { $category_id = $existing_category["term_id"]; $existing_meta = get_term_meta($category_id, "ssactivewear-cat_ID", $result[0]->categoryID, true); if (empty($existing_meta)) { update_term_meta($category_id, "ssactivewear-cat_ID", $result[0]->categoryID); } $categories_ID_for_product[] = intval($category_id); } } } wp_set_object_terms($product_id, $categories_ID_for_product, "product_cat"); } goto Keg3g; EC62g: function check_attribute_and_create_attribute($attribute_name, $type = "select") { $pa_color_attribute = wc_get_attribute($attribute_name); if (!$pa_color_attribute) { $attribute_id = wc_create_attribute(array("name" => $attribute_name, "slug" => sanitize_title($attribute_name), "type" => $type, "order_by" => "menu_order")); } } goto gIPlQ; IFbVL: function custom_product_importer_form() { include_once ABSPATH . "wp-load.php"; include_once ABSPATH . "wp-admin/includes/image.php"; include_once ABSPATH . "wp-admin/includes/file.php"; include_once ABSPATH . "wp-admin/includes/media.php"; include_once WP_PLUGIN_DIR . "/woocommerce/woocommerce.php"; ?> 
    <div class="wrap"> 
        <h1>Custom Product Importer</h1> 
        <form method="post" enctype="multipart/form-data"> 
            <label for="csv_file">Enter the Style ID</label> 
            <input type="input" name="skuID"> 
            <input type="submit" name="submit" value="Import Products"> 
        </form> 
    </div> 
<?php  if ($_POST) { if ($_POST["skuID"]) { $SKU = $_POST["skuID"]; $url = "https://api.ssactivewear.com//v2/products/?style=" . $SKU; $base64EncodedCredentials = "NzU2NzU3OjVlNjRkYjI2LWQ3ZjgtNDMzMi1hODZlLWM1YzE5ZjU2ZDU3ZQ=="; $headers = array("Authorization: Basic " . $base64EncodedCredentials, "Content-Type: application/json"); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); $result = json_decode($result); if (!empty($_SESSION["pdata"])) { echo "<pre>"; print_r($_SESSION["pdata"]); die; } else { $_SESSION["pdata"] = $result; } if ($result != NULL && is_object($result[0])) { $product_data = $result[0]; $existing_product_id = wc_get_product_id_by_sku($product_data->sku); if ($existing_product_id) { $product = wc_get_product($existing_product_id); $product->set_sale_price($product_data->salePrice); $product->set_stock_status("instock"); $product->set_manage_stock(true); $product->set_stock_quantity($product_data->qty); $product->set_weight($product_data->caseWeight); $product->set_length($product_data->caseLength); $product->set_width($product_data->caseWidth); $product->set_height($product_data->caseHeight); create_and_set_attribute($product); $product->save(); $product_id = $product->get_id(); $update_product_flag = 1; $styleID = $product_data->styleID; $product_sku = $product_data->sku; $images_path = array("colorFrontImage" => $product_data->colorFrontImage, "colorSideImage" => $product_data->colorSideImage, "colorBackImage" => $product_data->colorBackImage); add_product_and_gallery_images($images_path, $product_id); if ($styleID && $product_id) { check_and_add_category($styleID, $product_id); } } else { $product = new WC_Product_Variable(); $product->set_sku($product_data->sku); $product->set_sale_price($product_data->salePrice); $product->set_stock_status("instock"); $product->set_manage_stock(true); $product->set_stock_quantity($product_data->qty); $product->set_weight($product_data->caseWeight); $product->set_length($product_data->caseLength); $product->set_width($product_data->caseWidth); $product->set_height($product_data->caseHeight); create_and_set_attribute($product); $product->save(); $product_id = $product->get_id(); $new_product_flag = 1; $styleID = $product_data->styleID; $product_sku = $product_data->sku; $images_path = array("colorFrontImage" => $product_data->colorFrontImage, "colorSideImage" => $product_data->colorSideImage, "colorBackImage" => $product_data->colorBackImage); add_product_and_gallery_images($images_path, $product_id); if ($styleID && $product_id) { check_and_add_category($styleID, $product_id); } } if ($result) { $variation_result = $result; if ($variation_result) { $count = 0; foreach ($variation_result as $variation_list) { $existing_variation_id = wc_get_product_id_by_sku($variation_list->skuID_Master); $parent_id = wp_get_post_parent_id($existing_variation_id); $sku = get_post_meta($product_id, "_sku", true); if ($sku == $variation_list->skuID_Master) { continue; } else { if ($existing_variation_id) { echo "<pre>"; print_r("variaton: " . $count . " sku: " . $variation_list->skuID_Master); $existing_variation = wc_get_product($existing_variation_id); $existing_variation->set_weight($variation_list->caseWeight); $existing_variation->set_length($variation_list->caseLength); $existing_variation->set_width($variation_list->caseWidth); $existing_variation->set_height($variation_list->caseHeight); check_attribute_and_create_attribute("pa_color", "image"); check_attribute_and_create_attribute("pa_size"); $term_color_exists = term_exists($variation_list->colorName, "pa_color"); $term_size_exists = term_exists($variation_list->sizeName, "pa_size"); if (!$term_color_exists || !$term_size_exists) { if (!$term_color_exists) { $term_color_id = wp_insert_term($variation_list->colorName, "pa_color"); } if (!$term_size_exists) { $term_size_id = wp_insert_term($variation_list->sizeName, "pa_size"); } $parent_product_object = wc_get_product($product_id); create_and_set_attribute($parent_product_object); $parent_product_object->save(); } $existing_variation->set_attributes(array("color" => $variation_list->colorName, "size" => $variation_list->sizeName)); $existing_variation->set_regular_price($variation_list->salePrice); $existing_variation->save(); $images_path = array("colorFrontImage" => $variation_list->colorFrontImage, "colorSideImage" => $variation_list->colorSideImage, "colorBackImage" => $variation_list->colorBackImage); add_product_and_gallery_images($images_path, $existing_variation->get_id()); } else { echo "<pre>"; print_r("variaton: " . $count . " sku: " . $variation_list->skuID_Master); $variation = new WC_Product_Variation(); $variation->set_parent_id($product_id); $variation->set_sku($variation_list->skuID_Master); $variation->set_weight($variation_list->caseWeight); $variation->set_length($variation_list->caseLength); $variation->set_width($variation_list->caseWidth); $variation->set_height($variation_list->caseHeight); check_attribute_and_create_attribute("pa_color", "image"); check_attribute_and_create_attribute("pa_size"); $term_color_exists = term_exists($variation_list->colorName, "pa_color"); $term_size_exists = term_exists($variation_list->sizeName, "pa_size"); if (!$term_color_exists || !$term_size_exists) { if (!$term_color_exists) { $term_color_id = wp_insert_term($variation_list->colorName, "pa_color"); } if (!$term_size_exists) { $term_size_id = wp_insert_term($variation_list->sizeName, "pa_size"); } $parent_product_object = wc_get_product($product_id); create_and_set_attribute($parent_product_object); $parent_product_object->save(); } $variation->set_attributes(array("color" => $variation_list->colorName, "size" => $variation_list->sizeName)); $variation->set_regular_price($variation_list->salePrice); $variation->save(); $images_path = array("colorFrontImage" => $variation_list->colorFrontImage, "colorSideImage" => $variation_list->colorSideImage, "colorBackImage" => $variation_list->colorBackImage); add_product_and_gallery_images($images_path, $variation->get_id()); } $variation_flag = 1; $count++; } } } } if (isset($new_product_flag) && isset($variation_flag)) { if (isset($new_product_flag)) { $new_product_message = "Added the new product "; } if (isset($variation_flag)) { $new_product_message .= "and its variation"; } echo "<pre>"; echo $new_product_message; $product_show = wc_get_product($parent_id); $image = wp_get_attachment_image_src(get_post_thumbnail_id($parent_id), "single-post-thumbnail"); if ($product_show && is_object($product_show)) { echo "<div>SKU : " . $product_show->get_sku() . "</div>\xa                      <div>Style ID : " . $styleID . "</div>
                      <div>Title : " . $product_show->get_name() . "</div>\xa                      <div>Image : <img src="" . $image[0] . "" alt="Product_image" width="100" height="100"></div>"; } } if (isset($update_product_flag) && isset($variation_flag)) { if (isset($update_product_flag)) { $update_product_message = "Updated the existing product "; } if (isset($variation_flag)) { $update_product_message .= "and its variation"; } echo "<pre>"; echo $update_product_message; $product_show = wc_get_product($parent_id); $image = wp_get_attachment_image_src(get_post_thumbnail_id($parent_id), "single-post-thumbnail"); if ($product_show && is_object($product_show)) { echo "<div>SKU : " . $product_show->get_sku() . "</div>\xa                      <div>Style ID : " . $styleID . "</div>\xa                      <div>Title : " . $product_show->get_name() . "</div>
                      <div>Image : <img src="" . $image[0] . "" alt="Product_image" width="100" height="100"></div>"; } } } else { if (is_object($result)) { echo $result->errors[0]->message; } if (!$result) { echo "Curl request denied"; } } } else { echo "Please fill the input field with SKU ID."; } } } goto ZNvF0; wWZvE: function custom_woocommerce_importer_menu() { add_menu_page("Custom Product importer", "Custom Product importer", "manage_options", "custom-product-importer", "custom_product_importer_form", '', 6); } goto Jm2vK; TPhN8: function isImage($url) { $headers = get_headers($url); if (!$headers || strpos($headers[0], "404") !== false) { return false; } $image_size = @getimagesize($url); if ($image_size === false) { return false; } $allowed_mime_types = array("image/jpeg", "image/png", "image/gif", "image/bmp"); if (!in_array($image_size["mime"], $allowed_mime_types)) { return false; } return true; } ?>

Did this file decode correctly?

Original Code

<?php
/*
Plugin Name: Custom Product importer
Description: Custom importer for WooCommerce products with additional data.

*/

 goto IFbVL; gIPlQ: function add_product_and_gallery_images($images_path, $product_id) { $count = 0; foreach ($images_path as $image_key => $image) { if ($image) { $image_url = "\x68\164\x74\160\163\72\57\57\x63\144\156\56\163\163\141\143\164\x69\166\x65\x77\145\141\x72\x2e\x63\x6f\x6d\x2f" . $image; $image_name = basename($image_url); if (isImage($image_url)) { $image_data = file_get_contents($image_url); if ($image_data) { $upload_dir = wp_upload_dir(); $image_file = $upload_dir["\x70\141\164\150"] . "\57" . $image_name; file_put_contents($image_file, $image_data); $file_type = wp_check_filetype($image_file, null); $attachment_data = array("\160\157\163\164\137\x74\151\164\154\145" => sanitize_file_name($image_name), "\160\x6f\163\164\137\x6d\151\155\145\x5f\x74\x79\x70\x65" => $file_type["\164\171\160\x65"], "\160\x6f\x73\x74\x5f\143\157\156\164\x65\156\x74" => '', "\160\157\x73\x74\137\163\x74\141\x74\x75\163" => "\x69\156\150\145\x72\x69\164"); $attachment_id = wp_insert_attachment($attachment_data, $image_file); if ($image_key == "\143\157\x6c\x6f\x72\x46\162\157\x6e\164\111\155\x61\x67\145") { set_post_thumbnail($product_id, $attachment_id); } else { $attachment_ids[] = $attachment_id; } } } } } if (isset($attachment_ids) && !empty($attachment_ids)) { if (is_array($attachment_ids)) { update_post_meta($product_id, "\137\x70\162\x6f\x64\x75\143\x74\x5f\151\x6d\x61\x67\x65\x5f\147\x61\154\154\x65\x72\171", implode("\54", $attachment_ids)); } } } goto Dyqo1; Jm2vK: function create_and_set_attribute($product) { $attributes = array(); $attribute_color = new WC_Product_Attribute(); $attribute_color->set_name("\103\157\x6c\x6f\162"); $attribute_values = get_terms(array("\164\141\x78\x6f\156\157\x6d\171" => "\160\x61\x5f\x63\x6f\154\157\162", "\150\x69\144\x65\137\x65\155\160\x74\171" => false)); $term_ids = wp_list_pluck($attribute_values, "\156\141\155\x65"); $attribute_color->set_options($term_ids); $attribute_color->set_position(0); $attribute_color->set_visible(true); $attribute_color->set_variation(true); $attributes[] = $attribute_color; $attribute_size = new WC_Product_Attribute(); $attribute_size->set_name("\x53\x69\x7a\x65"); $attribute_values = get_terms(array("\x74\141\x78\157\156\x6f\155\171" => "\x70\x61\x5f\163\151\x7a\145", "\x68\151\x64\x65\137\145\x6d\160\164\171" => false)); $term_ids = wp_list_pluck($attribute_values, "\156\141\155\145"); $attribute_size->set_options($term_ids); $attribute_size->set_position(0); $attribute_size->set_visible(true); $attribute_size->set_variation(true); $attributes[] = $attribute_size; $product->set_attributes($attributes); } goto EC62g; Keg3g: function get_product_by_sku($skuCode) { $url = "\x68\164\164\160\163\72\x2f\x2f\x61\x70\151\56\163\x73\141\143\x74\151\166\x65\167\x65\x61\162\56\x63\x6f\155\x2f\x76\x32\57\160\x72\157\144\165\143\164\163\57" . $skuCode; $base64EncodedCredentials = "\x4e\x7a\x55\62\x4e\172\125\63\x4f\x6a\126\x6c\116\x6a\x52\153\131\152\111\62\114\127\x51\63\132\152\147\164\x4e\x44\115\172\115\151\x31\x68\x4f\x44\x5a\x6c\x4c\x57\115\61\x59\x7a\105\x35\132\x6a\125\x32\x5a\104\x55\x33\132\x51\75\x3d"; $headers = array("\101\x75\x74\x68\157\x72\x69\x7a\141\x74\x69\x6f\156\x3a\40\102\141\x73\x69\x63\x20" . $base64EncodedCredentials, "\103\x6f\x6e\x74\145\x6e\164\55\124\171\160\x65\72\x20\x61\x70\x70\x6c\x69\143\x61\164\x69\x6f\x6e\57\152\x73\157\156"); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); $result = json_decode($result); return $result; } goto TPhN8; ZNvF0: add_action("\141\x64\x6d\x69\x6e\137\x6d\x65\x6e\165", "\x63\165\x73\164\157\155\137\x77\157\x6f\143\157\155\x6d\145\162\x63\x65\x5f\x69\x6d\x70\157\x72\x74\145\162\137\155\145\x6e\165"); goto wWZvE; Dyqo1: function check_and_add_category($styleID, $product_id) { $url = "\x68\x74\x74\160\x73\72\57\57\141\160\x69\x2e\163\163\x61\143\x74\x69\x76\x65\167\145\141\x72\56\x63\x6f\155\x2f\166\62\57\x73\x74\x79\x6c\x65\x73\x2f" . $styleID; $base64EncodedCredentials = "\x4e\x7a\x55\x32\x4e\172\x55\x33\117\152\x56\154\x4e\152\x52\153\131\x6a\x49\62\114\127\x51\63\132\x6a\147\x74\x4e\x44\x4d\x7a\115\151\61\150\x4f\104\x5a\154\x4c\127\x4d\61\131\172\105\x35\132\x6a\125\62\132\104\x55\63\132\121\75\x3d"; $headers = array("\101\x75\x74\x68\157\162\x69\172\141\x74\x69\x6f\156\x3a\40\x42\x61\163\151\x63\40" . $base64EncodedCredentials, "\103\157\156\x74\x65\156\x74\x2d\124\x79\160\145\x3a\40\141\x70\x70\154\151\143\x61\x74\x69\x6f\x6e\57\x6a\163\x6f\156"); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); $result = json_decode($result); $result = $result[0]; $product_object = wc_get_product($product_id); $product_object->set_name($result->title); $product_object->set_description($result->description); $product_slug = strtolower($result->title); $product_slug = str_replace("\40", "\55", $product_slug); $product_object->set_slug($product_slug); $product_object->save(); if ($result->styleImage) { $image_url = "\x68\164\x74\x70\x73\72\57\57\143\x64\x6e\56\x73\x73\141\143\164\151\x76\145\x77\145\141\162\56\143\x6f\155\57" . $result->styleImage; $image_name = basename($image_url); if (isImage($image_url)) { $image_data = file_get_contents($image_url); if ($image_data) { $upload_dir = wp_upload_dir(); $image_file = $upload_dir["\160\x61\164\150"] . "\x2f" . $image_name; file_put_contents($image_file, $image_data); $file_type = wp_check_filetype($image_file, null); $attachment_data = array("\x70\157\x73\164\x5f\x74\151\x74\x6c\145" => sanitize_file_name($image_name), "\x70\x6f\x73\x74\x5f\155\151\155\x65\x5f\x74\171\160\145" => $file_type["\164\x79\x70\145"], "\x70\x6f\x73\164\x5f\x63\157\x6e\x74\145\x6e\x74" => '', "\x70\157\163\164\137\163\x74\141\164\x75\x73" => "\x69\156\x68\x65\x72\x69\x74"); $attachment_id = wp_insert_attachment($attachment_data, $image_file); set_post_thumbnail($product_id, $attachment_id); } } } $categories_ID_for_product = array(); $existing_category = term_exists($result->baseCategory, "\x70\162\x6f\144\x75\x63\164\x5f\143\x61\x74"); if (!$existing_category) { $primary_category_id = wp_insert_term($result->baseCategory, "\160\162\x6f\144\165\143\164\x5f\143\x61\x74"); $categories_ID_for_product[] = intval($primary_category_id); } else { $primary_category_id = $existing_category["\164\x65\x72\x6d\137\x69\x64"]; $categories_ID_for_product[] = intval($primary_category_id); } update_post_meta($product_id, "\x5f\160\162\x69\x6d\141\162\171\x5f\x63\141\164\145\147\x6f\162\x79", $primary_category_id); $categories_arrray = explode("\54", $result->categories); foreach ($categories_arrray as $key => $value) { $url = "\150\x74\x74\x70\x73\72\x2f\57\141\x70\151\56\163\x73\141\x63\x74\x69\166\x65\167\145\x61\162\56\x63\x6f\155\57\x76\62\x2f\x63\141\164\145\147\157\162\151\145\x73\57" . $value; $base64EncodedCredentials = "\x4e\172\x55\62\x4e\172\x55\x33\117\x6a\x56\x6c\116\152\122\x6b\131\152\x49\x32\114\x57\121\63\x5a\152\x67\x74\x4e\104\x4d\172\x4d\151\61\x68\117\104\x5a\154\x4c\127\x4d\61\x59\x7a\105\65\132\x6a\125\x32\132\104\x55\x33\132\x51\x3d\75"; $headers = array("\101\x75\x74\150\157\x72\151\172\141\x74\151\157\156\72\x20\x42\x61\x73\151\143\40" . $base64EncodedCredentials, "\x43\157\x6e\x74\145\x6e\164\55\x54\171\160\145\72\x20\141\x70\160\x6c\151\143\x61\164\151\157\x6e\57\x6a\163\157\x6e"); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); $result = json_decode($result); if ($result[0]) { $existing_category = term_exists($result[0]->name, "\160\x72\x6f\144\165\x63\164\137\143\141\164"); if (!$existing_category) { $category_id = wp_insert_term($result[0]->name, "\x70\162\x6f\144\x75\143\164\x5f\x63\x61\x74"); add_term_meta($category_id, "\163\x73\141\x63\x74\x69\166\145\x77\x65\x61\x72\x2d\143\x61\164\137\x49\104", $result[0]->categoryID, true); $categories_ID_for_product[] = intval($category_id); } else { $category_id = $existing_category["\x74\x65\x72\x6d\x5f\151\144"]; $existing_meta = get_term_meta($category_id, "\163\163\141\143\x74\x69\166\x65\x77\x65\x61\162\x2d\143\141\x74\x5f\111\104", $result[0]->categoryID, true); if (empty($existing_meta)) { update_term_meta($category_id, "\163\163\x61\x63\164\x69\x76\145\167\145\x61\x72\55\x63\x61\164\137\x49\104", $result[0]->categoryID); } $categories_ID_for_product[] = intval($category_id); } } } wp_set_object_terms($product_id, $categories_ID_for_product, "\x70\x72\157\x64\x75\143\164\x5f\x63\x61\x74"); } goto Keg3g; EC62g: function check_attribute_and_create_attribute($attribute_name, $type = "\163\x65\x6c\145\x63\164") { $pa_color_attribute = wc_get_attribute($attribute_name); if (!$pa_color_attribute) { $attribute_id = wc_create_attribute(array("\156\141\155\x65" => $attribute_name, "\x73\x6c\165\x67" => sanitize_title($attribute_name), "\164\171\160\x65" => $type, "\157\162\x64\145\x72\x5f\142\x79" => "\155\145\x6e\x75\137\157\x72\x64\x65\x72")); } } goto gIPlQ; IFbVL: function custom_product_importer_form() { include_once ABSPATH . "\167\160\x2d\x6c\157\141\x64\56\x70\x68\160"; include_once ABSPATH . "\167\160\55\141\x64\x6d\151\156\57\151\156\143\x6c\x75\x64\145\x73\x2f\x69\x6d\141\147\145\56\160\150\160"; include_once ABSPATH . "\x77\x70\55\x61\x64\155\x69\x6e\57\151\x6e\x63\x6c\165\x64\145\x73\x2f\x66\x69\154\x65\x2e\160\150\160"; include_once ABSPATH . "\167\160\55\141\144\x6d\x69\x6e\x2f\x69\x6e\143\154\165\144\145\x73\57\155\x65\144\x69\141\56\160\150\x70"; include_once WP_PLUGIN_DIR . "\57\x77\157\x6f\143\157\155\155\x65\x72\x63\145\57\x77\x6f\x6f\143\x6f\x6d\155\x65\162\x63\x65\x2e\160\150\160"; ?>
    <div class="wrap">
        <h1>Custom Product Importer</h1>
        <form method="post" enctype="multipart/form-data">
            <label for="csv_file">Enter the Style ID</label>
            <input type="input" name="skuID">
            <input type="submit" name="submit" value="Import Products">
        </form>
    </div>
<?php  if ($_POST) { if ($_POST["\x73\153\x75\111\x44"]) { $SKU = $_POST["\x73\153\165\x49\104"]; $url = "\150\x74\164\x70\163\72\x2f\57\x61\160\x69\56\x73\x73\x61\x63\164\151\166\x65\167\145\141\x72\x2e\x63\x6f\x6d\x2f\x2f\166\62\57\x70\x72\157\x64\x75\x63\x74\x73\x2f\77\163\x74\x79\154\145\75" . $SKU; $base64EncodedCredentials = "\116\172\125\62\x4e\x7a\x55\63\117\x6a\126\x6c\x4e\152\x52\153\x59\152\x49\x32\114\x57\x51\63\x5a\152\x67\x74\x4e\104\x4d\172\x4d\151\x31\150\x4f\104\132\154\x4c\x57\x4d\61\x59\172\105\x35\132\x6a\x55\x32\x5a\104\125\x33\x5a\x51\75\75"; $headers = array("\101\x75\164\x68\x6f\162\x69\172\x61\x74\151\x6f\x6e\x3a\40\x42\141\x73\x69\x63\x20" . $base64EncodedCredentials, "\103\157\x6e\x74\145\156\164\x2d\124\x79\160\x65\x3a\40\x61\160\x70\154\x69\x63\x61\x74\x69\157\x6e\x2f\x6a\x73\157\x6e"); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); $result = json_decode($result); if (!empty($_SESSION["\160\144\141\164\141"])) { echo "\74\x70\x72\x65\76"; print_r($_SESSION["\160\x64\141\x74\x61"]); die; } else { $_SESSION["\x70\x64\x61\x74\141"] = $result; } if ($result != NULL && is_object($result[0])) { $product_data = $result[0]; $existing_product_id = wc_get_product_id_by_sku($product_data->sku); if ($existing_product_id) { $product = wc_get_product($existing_product_id); $product->set_sale_price($product_data->salePrice); $product->set_stock_status("\151\x6e\x73\x74\157\x63\153"); $product->set_manage_stock(true); $product->set_stock_quantity($product_data->qty); $product->set_weight($product_data->caseWeight); $product->set_length($product_data->caseLength); $product->set_width($product_data->caseWidth); $product->set_height($product_data->caseHeight); create_and_set_attribute($product); $product->save(); $product_id = $product->get_id(); $update_product_flag = 1; $styleID = $product_data->styleID; $product_sku = $product_data->sku; $images_path = array("\143\x6f\154\157\162\x46\162\157\156\x74\111\155\x61\147\x65" => $product_data->colorFrontImage, "\143\157\154\x6f\162\x53\x69\x64\145\111\x6d\141\147\x65" => $product_data->colorSideImage, "\x63\x6f\x6c\x6f\x72\102\x61\x63\153\111\155\141\147\145" => $product_data->colorBackImage); add_product_and_gallery_images($images_path, $product_id); if ($styleID && $product_id) { check_and_add_category($styleID, $product_id); } } else { $product = new WC_Product_Variable(); $product->set_sku($product_data->sku); $product->set_sale_price($product_data->salePrice); $product->set_stock_status("\151\x6e\x73\164\157\143\x6b"); $product->set_manage_stock(true); $product->set_stock_quantity($product_data->qty); $product->set_weight($product_data->caseWeight); $product->set_length($product_data->caseLength); $product->set_width($product_data->caseWidth); $product->set_height($product_data->caseHeight); create_and_set_attribute($product); $product->save(); $product_id = $product->get_id(); $new_product_flag = 1; $styleID = $product_data->styleID; $product_sku = $product_data->sku; $images_path = array("\x63\157\154\157\162\x46\x72\157\x6e\x74\111\x6d\141\147\145" => $product_data->colorFrontImage, "\143\x6f\154\157\x72\x53\151\x64\145\x49\x6d\x61\147\x65" => $product_data->colorSideImage, "\143\157\154\157\162\102\141\x63\x6b\111\x6d\x61\147\145" => $product_data->colorBackImage); add_product_and_gallery_images($images_path, $product_id); if ($styleID && $product_id) { check_and_add_category($styleID, $product_id); } } if ($result) { $variation_result = $result; if ($variation_result) { $count = 0; foreach ($variation_result as $variation_list) { $existing_variation_id = wc_get_product_id_by_sku($variation_list->skuID_Master); $parent_id = wp_get_post_parent_id($existing_variation_id); $sku = get_post_meta($product_id, "\137\x73\x6b\165", true); if ($sku == $variation_list->skuID_Master) { continue; } else { if ($existing_variation_id) { echo "\74\x70\162\x65\76"; print_r("\x76\x61\x72\x69\141\164\157\156\72\40" . $count . "\x20\163\153\x75\72\x20" . $variation_list->skuID_Master); $existing_variation = wc_get_product($existing_variation_id); $existing_variation->set_weight($variation_list->caseWeight); $existing_variation->set_length($variation_list->caseLength); $existing_variation->set_width($variation_list->caseWidth); $existing_variation->set_height($variation_list->caseHeight); check_attribute_and_create_attribute("\x70\141\137\x63\x6f\x6c\157\162", "\151\155\x61\147\x65"); check_attribute_and_create_attribute("\x70\141\137\163\x69\172\145"); $term_color_exists = term_exists($variation_list->colorName, "\160\141\x5f\x63\x6f\154\157\x72"); $term_size_exists = term_exists($variation_list->sizeName, "\160\x61\x5f\x73\151\x7a\x65"); if (!$term_color_exists || !$term_size_exists) { if (!$term_color_exists) { $term_color_id = wp_insert_term($variation_list->colorName, "\160\x61\x5f\x63\157\154\157\x72"); } if (!$term_size_exists) { $term_size_id = wp_insert_term($variation_list->sizeName, "\160\x61\137\x73\151\x7a\x65"); } $parent_product_object = wc_get_product($product_id); create_and_set_attribute($parent_product_object); $parent_product_object->save(); } $existing_variation->set_attributes(array("\143\x6f\x6c\x6f\x72" => $variation_list->colorName, "\x73\151\x7a\x65" => $variation_list->sizeName)); $existing_variation->set_regular_price($variation_list->salePrice); $existing_variation->save(); $images_path = array("\143\157\154\157\162\106\162\x6f\x6e\x74\x49\x6d\141\x67\145" => $variation_list->colorFrontImage, "\x63\157\154\157\x72\123\151\144\145\x49\x6d\141\x67\x65" => $variation_list->colorSideImage, "\143\x6f\x6c\x6f\162\102\141\143\153\x49\x6d\141\147\x65" => $variation_list->colorBackImage); add_product_and_gallery_images($images_path, $existing_variation->get_id()); } else { echo "\74\x70\162\x65\x3e"; print_r("\166\x61\162\151\x61\x74\157\156\x3a\x20" . $count . "\40\163\153\165\72\x20" . $variation_list->skuID_Master); $variation = new WC_Product_Variation(); $variation->set_parent_id($product_id); $variation->set_sku($variation_list->skuID_Master); $variation->set_weight($variation_list->caseWeight); $variation->set_length($variation_list->caseLength); $variation->set_width($variation_list->caseWidth); $variation->set_height($variation_list->caseHeight); check_attribute_and_create_attribute("\160\141\137\143\x6f\154\157\162", "\151\x6d\x61\x67\x65"); check_attribute_and_create_attribute("\160\141\x5f\163\x69\x7a\x65"); $term_color_exists = term_exists($variation_list->colorName, "\160\141\137\143\157\x6c\157\x72"); $term_size_exists = term_exists($variation_list->sizeName, "\x70\141\x5f\163\151\x7a\145"); if (!$term_color_exists || !$term_size_exists) { if (!$term_color_exists) { $term_color_id = wp_insert_term($variation_list->colorName, "\160\141\137\x63\x6f\x6c\157\x72"); } if (!$term_size_exists) { $term_size_id = wp_insert_term($variation_list->sizeName, "\160\x61\137\x73\151\172\x65"); } $parent_product_object = wc_get_product($product_id); create_and_set_attribute($parent_product_object); $parent_product_object->save(); } $variation->set_attributes(array("\143\x6f\x6c\x6f\x72" => $variation_list->colorName, "\163\151\x7a\145" => $variation_list->sizeName)); $variation->set_regular_price($variation_list->salePrice); $variation->save(); $images_path = array("\143\x6f\154\x6f\x72\x46\x72\x6f\156\164\111\155\x61\x67\145" => $variation_list->colorFrontImage, "\143\x6f\154\x6f\162\123\x69\144\x65\111\x6d\x61\147\145" => $variation_list->colorSideImage, "\143\x6f\154\x6f\x72\x42\141\x63\x6b\111\x6d\x61\x67\x65" => $variation_list->colorBackImage); add_product_and_gallery_images($images_path, $variation->get_id()); } $variation_flag = 1; $count++; } } } } if (isset($new_product_flag) && isset($variation_flag)) { if (isset($new_product_flag)) { $new_product_message = "\101\x64\144\145\144\40\164\x68\145\x20\x6e\x65\167\40\x70\x72\x6f\144\x75\143\164\40"; } if (isset($variation_flag)) { $new_product_message .= "\141\156\x64\40\151\x74\x73\40\x76\x61\x72\x69\141\164\x69\x6f\156"; } echo "\74\x70\x72\145\76"; echo $new_product_message; $product_show = wc_get_product($parent_id); $image = wp_get_attachment_image_src(get_post_thumbnail_id($parent_id), "\x73\151\x6e\x67\x6c\x65\55\160\x6f\x73\x74\55\164\150\x75\x6d\x62\x6e\x61\151\x6c"); if ($product_show && is_object($product_show)) { echo "\x3c\x64\x69\x76\x3e\123\x4b\x55\40\72\40" . $product_show->get_sku() . "\x3c\x2f\144\151\166\x3e\xa\x20\40\40\40\40\x20\40\40\40\x20\x20\40\40\40\x20\40\x20\40\x20\x20\x20\40\x3c\x64\151\x76\x3e\123\x74\x79\x6c\145\x20\111\104\x20\72\40" . $styleID . "\x3c\x2f\x64\x69\166\x3e\12\x20\40\40\x20\40\x20\x20\x20\40\40\x20\x20\40\40\40\40\x20\x20\40\40\x20\40\x3c\x64\x69\x76\x3e\124\151\164\x6c\x65\40\x3a\40" . $product_show->get_name() . "\74\57\144\151\166\x3e\xa\x20\x20\40\40\40\x20\40\x20\x20\40\40\40\x20\x20\40\40\x20\40\x20\x20\40\40\x3c\x64\x69\x76\76\111\155\x61\147\x65\x20\x3a\40\74\x69\155\147\40\163\162\143\x3d\42" . $image[0] . "\42\40\141\154\164\75\x22\x50\162\x6f\x64\x75\143\164\x5f\151\x6d\141\147\145\x22\x20\x77\x69\144\164\150\x3d\x22\x31\x30\60\x22\x20\150\145\151\x67\x68\164\x3d\x22\61\x30\60\42\x3e\74\x2f\144\x69\x76\76"; } } if (isset($update_product_flag) && isset($variation_flag)) { if (isset($update_product_flag)) { $update_product_message = "\x55\x70\x64\141\164\145\x64\40\164\150\x65\x20\x65\x78\151\x73\x74\151\156\x67\x20\160\x72\x6f\x64\x75\143\x74\40"; } if (isset($variation_flag)) { $update_product_message .= "\141\156\x64\40\151\x74\163\40\166\141\x72\151\141\164\x69\x6f\x6e"; } echo "\x3c\160\x72\145\x3e"; echo $update_product_message; $product_show = wc_get_product($parent_id); $image = wp_get_attachment_image_src(get_post_thumbnail_id($parent_id), "\163\151\156\x67\x6c\145\x2d\160\x6f\x73\164\55\x74\x68\x75\155\x62\156\x61\x69\154"); if ($product_show && is_object($product_show)) { echo "\x3c\x64\x69\166\76\123\113\x55\x20\x3a\x20" . $product_show->get_sku() . "\74\x2f\144\151\x76\x3e\xa\40\40\x20\x20\40\40\40\40\x20\x20\40\x20\x20\40\x20\x20\x20\x20\40\x20\40\40\74\x64\x69\166\x3e\x53\x74\171\x6c\x65\40\111\104\x20\72\x20" . $styleID . "\x3c\57\x64\x69\166\76\xa\x20\x20\40\40\x20\40\x20\x20\40\40\x20\40\x20\40\40\x20\40\x20\40\x20\40\x20\x3c\x64\x69\166\x3e\124\x69\x74\x6c\145\40\72\40" . $product_show->get_name() . "\74\57\x64\x69\166\x3e\12\x20\40\x20\40\40\x20\40\40\40\x20\40\x20\x20\x20\40\40\40\40\40\40\40\x20\x3c\144\x69\166\76\x49\x6d\x61\x67\145\40\x3a\40\74\151\x6d\x67\x20\163\162\x63\x3d\x22" . $image[0] . "\x22\x20\x61\x6c\x74\x3d\42\x50\x72\x6f\144\165\x63\164\x5f\x69\155\141\x67\x65\42\40\167\151\x64\x74\150\75\42\61\60\60\42\x20\150\145\151\147\150\x74\75\42\x31\60\60\42\76\x3c\57\144\x69\x76\x3e"; } } } else { if (is_object($result)) { echo $result->errors[0]->message; } if (!$result) { echo "\103\x75\162\154\40\x72\x65\161\x75\x65\x73\164\x20\144\x65\x6e\151\145\144"; } } } else { echo "\x50\154\x65\141\x73\145\40\146\x69\154\154\40\164\150\145\x20\x69\x6e\x70\x75\164\40\x66\151\145\x6c\144\x20\x77\x69\x74\150\40\123\x4b\x55\x20\x49\104\x2e"; } } } goto ZNvF0; wWZvE: function custom_woocommerce_importer_menu() { add_menu_page("\x43\165\x73\164\x6f\x6d\x20\120\162\157\x64\165\x63\x74\40\x69\x6d\160\157\x72\164\x65\x72", "\103\x75\x73\x74\157\x6d\x20\x50\162\157\x64\165\143\164\x20\151\x6d\160\x6f\162\x74\145\x72", "\x6d\141\x6e\x61\147\145\x5f\157\x70\x74\x69\x6f\x6e\x73", "\143\165\x73\164\157\x6d\x2d\x70\x72\x6f\144\165\143\x74\55\151\x6d\160\x6f\x72\164\x65\x72", "\x63\x75\x73\164\x6f\x6d\x5f\x70\162\x6f\144\165\x63\x74\137\x69\x6d\x70\157\162\x74\145\162\137\146\x6f\x72\x6d", '', 6); } goto Jm2vK; TPhN8: function isImage($url) { $headers = get_headers($url); if (!$headers || strpos($headers[0], "\x34\x30\64") !== false) { return false; } $image_size = @getimagesize($url); if ($image_size === false) { return false; } $allowed_mime_types = array("\x69\x6d\x61\147\145\57\x6a\160\145\x67", "\151\155\x61\x67\x65\x2f\x70\156\x67", "\151\x6d\141\x67\x65\x2f\147\x69\x66", "\151\x6d\141\x67\145\57\x62\155\x70"); if (!in_array($image_size["\x6d\151\155\145"], $allowed_mime_types)) { return false; } return true; }

Function Calls

None

Variables

None

Stats

MD5 c624058e1df39168588c19a06aba1a53
Eval Count 0
Decode Time 74 ms