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 License Activation * Description: A plugin to search ..
Decoded Output download
<?php
/**
* Plugin Name: Custom License Activation
* Description: A plugin to search and activate licenses and display product details
* Version: 1.2
* Author: Your Name
*/
if (!defined('ABSPATH')) {
exit; // Prevent direct access
}
session_start(); // Start session
// Add shortcode for the license search form
function license_search_form_handler() {
ob_start();
?>
<form action="" method="post" class="form-license">
<div style="width: 82%;">
<input type="text" id="license_code" name="license_code" required>
</div>
<button type="submit" name="submit_license" style="border-radius: 15px;">Search & Activate License</button>
</form>
<div class="product-info">
<?php
if (!empty($_SESSION['product_info'])) {
echo $_SESSION['product_info'];
unset($_SESSION['product_info']); // Clear product info after displaying
}
?>
</div>
<style>
.form-license {
display: flex;
margin: auto;
justify-content: space-evenly;
gap: 10px;
}
@media only screen and (max-width: 600px) {
.form-license {
flex-direction: column;
}
.form-license div {
width: 100% !important;
}
}
.product-info img {
max-width: 200px;
display: block;
margin: auto;
}
@media only screen and (min-width: 600px) {
.form-license {
flex-direction: column;
}
.form-license div {
width: 100% !important;
}
.custome-container {
display: grid;
}
.stamp {
font-size: 3rem!important;
}
}
.custome-container {
direction: rtl;
grid-template-areas:
"header header"
"menu content"
"footer footer";
grid-template-columns: 4fr 1fr;
gap: 5px;
padding: 5px;
align-items: center;
}
h3.header {
text-align: left;
border-bottom: 2px solid #e4e4e440;
padding-bottom: 10px;
font-size: 25px;
}
.license-message {
margin-top: 10px;
padding: 8px;
border-radius: 5px;
font-weight: bold;
text-align: center;
}
.stamp {
transform: rotate(0deg);
/*color: #555;*/
font-size: 1.5rem;
font-weight: 700;
display: inline-block;
padding: 0.25rem 1rem;
text-transform: uppercase;
border-radius: 1rem;
font-family: 'Courier';
-webkit-mask-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/8399/grunge.png');
-webkit-mask-size: 944px 604px;
/*mix-blend-mode: multiply;*/
}
</style>
<?php
return ob_get_clean();
}
add_shortcode('license_search_form', 'license_search_form_handler');
// Process license activation and retrieve product details
function process_license_activation() {
if (isset($_POST['submit_license']) && !empty($_POST['license_code'])) {
$license_code = sanitize_text_field($_POST['license_code']);
$query = array('license_key' => $license_code);
$licenses = lmfwc_get_licenses($query);
if (!empty($licenses)) {
$license = reset($licenses);
$license_id = $license->getId();
$product_id = $license->getProductId();
if ($license->getTimesActivated() == 0 || $license->getTimesActivated() == null) {
$activation_args = array(
'source' => 'custom_form',
'ip_address' => 'custom_form',
'user_agent' => 'custom_form',
'label' => 'Custom Activation',
'meta_data' => array(
'extra_info' => 'Activated via custom form',
)
);
$activation_result = lmfwc_activate_license($license_code, $activation_args);
if (is_wp_error($activation_result)) {
$_SESSION['license_message'] = '<div style="color: red;">Error: ' . $activation_result->get_error_message() . '</div>';
} else {
$_SESSION['license_message'] = '<div style="color: green;border: 0.25rem solid green;border-radius: 20px;">License successfully activated</div>';
}
LicenseManagerForWooCommerce\Repositories\Resources\License::instance()->updateBy(
array('id' => $license_id),
array('times_activated' => 1)
);
LicenseManagerForWooCommerce\Repositories\Resources\License::instance()->update(
$license_id,
array('status' => 1)
);
} else {
$_SESSION['license_message'] = '<div style="color: orange;border: 0.25rem solid orange;border-radius: 20px;">This license is already active</div>';
}
// Retrieve product details based on Product ID
if (!empty($product_id)) {
$product = wc_get_product($product_id);
if ($product) {
$product_title = $product->get_name();
$product_desc = $product->get_description();
$product_price = $product->get_price();
$product_image = get_the_post_thumbnail_url($product_id, 'medium');
$product_link = get_permalink($product_id);
$_SESSION['product_info'] = '
<div class="custome-container" style="border: 1px solid #ececec5e; padding: 15px; text-align: center; border-radius: 15px;">
<h3 class="header">' . esc_html($product_title) . '</h3>
<p class="header" style="color: white; font-weight: bold;">License Code: ' . esc_html($license_code) . '</p>
<div class="license-message stamp is-approved">' . $_SESSION['license_message'] . '</div>
<img class="menu" src="' . esc_url($product_image) . '" alt="' . esc_attr($product_title) . '">
</div>';
unset($_SESSION['license_message']); // Clear license message after displaying
} else {
$_SESSION['product_info'] = '<div style="color: red;">Product not found!</div>';
}
}
} else {
$_SESSION['license_message'] = '<div style="color: red;">License not found!</div>';
}
wp_redirect($_SERVER['REQUEST_URI']); // Redirect back to the same page to display messages
exit();
}
}
add_action('init', 'process_license_activation');
?>
Did this file decode correctly?
Original Code
<?php
/**
* Plugin Name: Custom License Activation
* Description: A plugin to search and activate licenses and display product details
* Version: 1.2
* Author: Your Name
*/
if (!defined('ABSPATH')) {
exit; // Prevent direct access
}
session_start(); // Start session
// Add shortcode for the license search form
function license_search_form_handler() {
ob_start();
?>
<form action="" method="post" class="form-license">
<div style="width: 82%;">
<input type="text" id="license_code" name="license_code" required>
</div>
<button type="submit" name="submit_license" style="border-radius: 15px;">Search & Activate License</button>
</form>
<div class="product-info">
<?php
if (!empty($_SESSION['product_info'])) {
echo $_SESSION['product_info'];
unset($_SESSION['product_info']); // Clear product info after displaying
}
?>
</div>
<style>
.form-license {
display: flex;
margin: auto;
justify-content: space-evenly;
gap: 10px;
}
@media only screen and (max-width: 600px) {
.form-license {
flex-direction: column;
}
.form-license div {
width: 100% !important;
}
}
.product-info img {
max-width: 200px;
display: block;
margin: auto;
}
@media only screen and (min-width: 600px) {
.form-license {
flex-direction: column;
}
.form-license div {
width: 100% !important;
}
.custome-container {
display: grid;
}
.stamp {
font-size: 3rem!important;
}
}
.custome-container {
direction: rtl;
grid-template-areas:
"header header"
"menu content"
"footer footer";
grid-template-columns: 4fr 1fr;
gap: 5px;
padding: 5px;
align-items: center;
}
h3.header {
text-align: left;
border-bottom: 2px solid #e4e4e440;
padding-bottom: 10px;
font-size: 25px;
}
.license-message {
margin-top: 10px;
padding: 8px;
border-radius: 5px;
font-weight: bold;
text-align: center;
}
.stamp {
transform: rotate(0deg);
/*color: #555;*/
font-size: 1.5rem;
font-weight: 700;
display: inline-block;
padding: 0.25rem 1rem;
text-transform: uppercase;
border-radius: 1rem;
font-family: 'Courier';
-webkit-mask-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/8399/grunge.png');
-webkit-mask-size: 944px 604px;
/*mix-blend-mode: multiply;*/
}
</style>
<?php
return ob_get_clean();
}
add_shortcode('license_search_form', 'license_search_form_handler');
// Process license activation and retrieve product details
function process_license_activation() {
if (isset($_POST['submit_license']) && !empty($_POST['license_code'])) {
$license_code = sanitize_text_field($_POST['license_code']);
$query = array('license_key' => $license_code);
$licenses = lmfwc_get_licenses($query);
if (!empty($licenses)) {
$license = reset($licenses);
$license_id = $license->getId();
$product_id = $license->getProductId();
if ($license->getTimesActivated() == 0 || $license->getTimesActivated() == null) {
$activation_args = array(
'source' => 'custom_form',
'ip_address' => 'custom_form',
'user_agent' => 'custom_form',
'label' => 'Custom Activation',
'meta_data' => array(
'extra_info' => 'Activated via custom form',
)
);
$activation_result = lmfwc_activate_license($license_code, $activation_args);
if (is_wp_error($activation_result)) {
$_SESSION['license_message'] = '<div style="color: red;">Error: ' . $activation_result->get_error_message() . '</div>';
} else {
$_SESSION['license_message'] = '<div style="color: green;border: 0.25rem solid green;border-radius: 20px;">License successfully activated</div>';
}
LicenseManagerForWooCommerce\Repositories\Resources\License::instance()->updateBy(
array('id' => $license_id),
array('times_activated' => 1)
);
LicenseManagerForWooCommerce\Repositories\Resources\License::instance()->update(
$license_id,
array('status' => 1)
);
} else {
$_SESSION['license_message'] = '<div style="color: orange;border: 0.25rem solid orange;border-radius: 20px;">This license is already active</div>';
}
// Retrieve product details based on Product ID
if (!empty($product_id)) {
$product = wc_get_product($product_id);
if ($product) {
$product_title = $product->get_name();
$product_desc = $product->get_description();
$product_price = $product->get_price();
$product_image = get_the_post_thumbnail_url($product_id, 'medium');
$product_link = get_permalink($product_id);
$_SESSION['product_info'] = '
<div class="custome-container" style="border: 1px solid #ececec5e; padding: 15px; text-align: center; border-radius: 15px;">
<h3 class="header">' . esc_html($product_title) . '</h3>
<p class="header" style="color: white; font-weight: bold;">License Code: ' . esc_html($license_code) . '</p>
<div class="license-message stamp is-approved">' . $_SESSION['license_message'] . '</div>
<img class="menu" src="' . esc_url($product_image) . '" alt="' . esc_attr($product_title) . '">
</div>';
unset($_SESSION['license_message']); // Clear license message after displaying
} else {
$_SESSION['product_info'] = '<div style="color: red;">Product not found!</div>';
}
}
} else {
$_SESSION['license_message'] = '<div style="color: red;">License not found!</div>';
}
wp_redirect($_SERVER['REQUEST_URI']); // Redirect back to the same page to display messages
exit();
}
}
add_action('init', 'process_license_activation');
Function Calls
| defined | 1 |
Stats
| MD5 | a041c0cc58e471b2e075b3f872d299c4 |
| Eval Count | 0 |
| Decode Time | 84 ms |