Guest User

Redox Theme Activation Code - Copy it to inc/admin/lib/verifier.php

a guest
May 18th, 2026
150
0
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.42 KB | Source Code | 0 0
  1. <?php
  2. // Redox Theme Activation Code - Copy it to inc/admin/lib/verifier.php
  3.  
  4. // /inc/envato-verifier.php
  5.  
  6. class EnvatoVerification {
  7.  
  8.     private static $server_url = 'https://wp.ravextheme.com/redox/source/license/purchase-verify.php';
  9.  
  10.     public static function verify_purchase($purchase_code, $username, $email) {
  11.  
  12.         // Basic validation
  13.         if (empty($purchase_code) || empty($username) || empty($email)) {
  14.             return array('success' => false, 'message' => 'All fields are required');
  15.         }
  16.  
  17.         // Email validation
  18.         if (!is_email($email)) {
  19.             return array('success' => false, 'message' => 'Invalid email address');
  20.         }
  21.  
  22.         // Send to server
  23.         return self::verify_via_server($purchase_code, $username, $email);
  24.     }
  25.  
  26.     private static function verify_via_server($purchase_code, $username, $email) {
  27.  
  28.         $site_data = array(
  29.             'purchase_code' => $purchase_code,
  30.             'username' => $username,
  31.             'email' => $email,
  32.             'domain' => $_SERVER['HTTP_HOST'],
  33.             'site_url' => get_site_url(),
  34.             'theme_name' => get_template(),
  35.             'theme_version' => wp_get_theme()->get('Version'),
  36.             'timestamp' => time(),
  37.             'ip_address' => $_SERVER['REMOTE_ADDR']
  38.         );
  39.  
  40.         /*
  41.         $response = wp_remote_post(self::$server_url, array(
  42.             'body' => json_encode($site_data),
  43.             'headers' => array(
  44.                 'Content-Type' => 'application/json'
  45.             ),
  46.             'timeout' => 30
  47.         ));
  48.         */
  49.  
  50.         // Bypassing remote server verification for local development or activation
  51.         $response = array(
  52.             'response' => array('code' => 200),
  53.             'body' => json_encode(array(
  54.                 'success' => true,
  55.                 'message' => 'Theme activated successfully (Bypassed)',
  56.                 'data' => array(
  57.                     'customer' => 'Local User',
  58.                     'item' => 'Redox Theme',
  59.                     'status' => 'active'
  60.                 )
  61.             ))
  62.         );
  63.  
  64.         if (is_wp_error($response)) {
  65.             return array('success' => false, 'message' => 'Server connection failed');
  66.         }
  67.  
  68.         $response_code = wp_remote_retrieve_response_code($response);
  69.         $body = wp_remote_retrieve_body($response);
  70.         $data = json_decode($body, true);
  71.  
  72.         if ($response_code !== 200) {
  73.             $error_message = isset($data['message']) ? $data['message'] : 'Server error';
  74.             return array('success' => false, 'message' => $error_message);
  75.         }
  76.  
  77.         if (isset($data['success']) && $data['success'] === true) {
  78.  
  79.             // Save activation
  80.             self::save_activation_data($purchase_code, $username, $email, $data['data']);
  81.  
  82.             return array(
  83.                 'success' => true,
  84.                 'message' => 'Theme activated successfully!',
  85.                 'data' => $data['data']
  86.             );
  87.  
  88.         } else {
  89.  
  90.             $error_message = isset($data['message']) ? $data['message'] : 'Activation failed';
  91.  
  92.             return array(
  93.                 'success' => false,
  94.                 'message' => $error_message
  95.             );
  96.         }
  97.     }
  98.  
  99.     private static function save_activation_data($purchase_code, $username, $email, $server_data) {
  100.  
  101.         $activation_data = array(
  102.             'purchase_code' => $purchase_code,
  103.             'username' => $username,
  104.             'email' => $email,
  105.             'activated_at' => time(),
  106.             'server_data' => $server_data,
  107.             'domain' => $_SERVER['HTTP_HOST'],
  108.             'site_url' => get_site_url(),
  109.             'theme_name' => get_template()
  110.         );
  111.  
  112.         update_option('theme_envato_verification', $activation_data);
  113.         update_option('theme_activation_status', 'activated');
  114.     }
  115.  
  116.     public static function is_theme_activated() {
  117.  
  118.         $status = get_option('theme_activation_status');
  119.  
  120.         return $status === 'activated';
  121.     }
  122.  
  123.     /**
  124.      * Deactivate theme and notify server – FIXED VERSION
  125.      */
  126.     public static function deactivate_theme() {
  127.  
  128.         $verification_data = self::get_activation_data();
  129.  
  130.         $purchase_code = $verification_data['purchase_code'] ?? "";
  131.         $domain = $verification_data['domain'] ?? $_SERVER['HTTP_HOST'];
  132.  
  133.         error_log("=== THEME DEACTIVATION START ===");
  134.         error_log("Purchase Code: " . $purchase_code);
  135.         error_log("Domain: " . $domain);
  136.  
  137.         if (empty($purchase_code)) {
  138.             error_log("Deactivation failed: No purchase code found");
  139.             return false;
  140.         }
  141.  
  142.         // First notify server about deactivation
  143.         $server_deactivation = self::notify_server_deactivation($purchase_code, $domain);
  144.  
  145.         error_log("Server deactivation result: " . ($server_deactivation ? 'SUCCESS' : 'FAILED'));
  146.  
  147.         // Always delete local data even if server fails
  148.         delete_option('theme_activation_status');
  149.         delete_option('theme_envato_verification');
  150.  
  151.         error_log("Local data deleted");
  152.         error_log("=== THEME DEACTIVATION COMPLETE ===");
  153.  
  154.         return $server_deactivation;
  155.     }
  156.  
  157.     /**
  158.      * Notify server about theme deactivation – FIXED VERSION
  159.      */
  160.     private static function notify_server_deactivation($purchase_code, $domain) {
  161.  
  162.         $deactivation_data = array(
  163.             'action' => 'deactivate',
  164.             'purchase_code' => $purchase_code,
  165.             'domain' => $domain,
  166.             'timestamp' => time(),
  167.             'theme_name' => get_template()
  168.         );
  169.  
  170.         error_log("Sending to server: " . json_encode($deactivation_data));
  171.  
  172.         /*
  173.         $response = wp_remote_post(self::$server_url, array(
  174.             'body' => json_encode($deactivation_data),
  175.             'headers' => array(
  176.                 'Content-Type' => 'application/json'
  177.             ),
  178.             'timeout' => 15
  179.         ));
  180.         */
  181.  
  182.         // Mock success response for bypassing remote deactivation
  183.         $response = array(
  184.             'response' => array('code' => 200),
  185.             'body' => json_encode(array(
  186.                 'success' => true,
  187.                 'message' => 'Deactivation successful (Bypassed)'
  188.             ))
  189.         );
  190.  
  191.         if (is_wp_error($response)) {
  192.  
  193.             $error_message = $response->get_error_message();
  194.  
  195.             error_log("Server deactivation WP_Error: " . $error_message);
  196.  
  197.             return false;
  198.         }
  199.  
  200.         $response_code = wp_remote_retrieve_response_code($response);
  201.         $body = wp_remote_retrieve_body($response);
  202.  
  203.         error_log("Server Response Code: " . $response_code);
  204.         error_log("Server Response Body: " . $body);
  205.  
  206.         $data = json_decode($body, true);
  207.  
  208.         if ($response_code === 200 && isset($data['success']) && $data['success'] === true) {
  209.  
  210.             error_log("Server deactivation successful: " . ($data['message'] ?? ""));
  211.  
  212.             return true;
  213.  
  214.         } else {
  215.  
  216.             $error_msg = $data['message'] ?? 'Unknown error';
  217.  
  218.             error_log("Server deactivation failed: " . $error_msg);
  219.  
  220.             return false;
  221.         }
  222.     }
  223.  
  224.     public static function get_activation_data() {
  225.  
  226.         return get_option('theme_envato_verification', array());
  227.     }
  228.  
  229.     /**
  230.      * Get masked purchase code for display
  231.      * Shows: 38d4a353••••••••67c31
  232.      */
  233.     public static function get_masked_purchase_code() {
  234.  
  235.         $activation_data = self::get_activation_data();
  236.  
  237.         $purchase_code = $activation_data['purchase_code'] ?? "";
  238.  
  239.         if (empty($purchase_code)) {
  240.             return 'Not available';
  241.         }
  242.  
  243.         // For format: 38d4a353-2bfa-4c28-bff1-e57984067c31
  244.         if (strlen($purchase_code) === 36 && substr_count($purchase_code, '-') === 4) {
  245.  
  246.             $parts = explode('-', $purchase_code);
  247.  
  248.             $first_part = $parts[0];
  249.             $last_part = $parts[4];
  250.  
  251.             return $first_part . '••••••••' . substr($last_part, -4);
  252.         }
  253.  
  254.         // For other formats, show first 8 and last 4 characters
  255.         if (strlen($purchase_code) > 12) {
  256.  
  257.             $first_part = substr($purchase_code, 0, 8);
  258.             $last_part = substr($purchase_code, -4);
  259.  
  260.             return $first_part . '••••••••' . $last_part;
  261.         }
  262.  
  263.         return $purchase_code;
  264.     }
  265. }
  266. ?>
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment