GIF94; MINI MO Shell - Tarih Gösterimli

MINI MINI MANI MO - TARİH GÖSTERİMLİ

Path : /var/www/wordpress/wp-content/plugins/oxymade/includes/
File Upload :
Current File : /var/www/wordpress/wp-content/plugins/oxymade/includes/license.php

<?php

namespace OxyMade\License;

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}

/**
 * License verification class - using OxyMade licensing system with efficient autoload caching
 */
class LicenseCheck {
    /**
     * Verify if the license is active
     *
     * @return bool
     */
    public static function verify() {
        global $oxymade_license_client;

        // Check if OxyMade license is activated
        if (isset($oxymade_license_client)) {
            $settings = $oxymade_license_client->settings();
            $license_key = $settings->license_key ?? '';
            $activation_id = $settings->activation_id ?? '';

            return !empty($license_key) && !empty($activation_id);
        }

        return false;
    }
    
    /**
     * Get license data with level from custom API - using autoload caching for performance
     *
     * @return array
     */
    public static function get_license_data() {
        global $oxymade_license_client;

        $default_data = [
            'is_active' => false,
            'level' => 'Free',
            'status' => 'inactive',
            'license_key' => '',
            'activation_id' => ''
        ];

        if (!isset($oxymade_license_client)) {
            return $default_data;
        }

        $settings = $oxymade_license_client->settings();
        $license_key = $settings->license_key ?? '';
        $activation_id = $settings->activation_id ?? '';

        // If no license key, return inactive
        if (empty($license_key)) {
            return $default_data;
        }

        // If activated, get level from autoload cache or API
        $is_active = !empty($activation_id);

        if ($is_active) {
            // Try to get cached level data first (autoload for performance)
            $cached_level = \get_option('oxymade_license_level', '');

            if (empty($cached_level)) {
                // If no cached level, fetch from API and store
                $level_data = self::get_license_level_from_api($license_key);
                $cached_level = $level_data['level'];

                // Store in autoload option for fast access
                \update_option('oxymade_license_level', $cached_level);
            }

            return [
                'is_active' => true,
                'level' => $cached_level,
                'status' => 'active',
                'license_key' => $license_key,
                'activation_id' => $activation_id
            ];
        }

        return $default_data;
    }
    
    /**
     * Get license level from custom API
     *
     * @param string $license_key
     * @return array
     */
    private static function get_license_level_from_api($license_key) {
        if (empty($license_key)) {
            return ['level' => 'Free', 'valid' => false];
        }

        global $oxymade_license_client;

        if (!isset($oxymade_license_client)) {
            return ['level' => 'Free', 'valid' => false];
        }

        try {
            // Use OxyMade's built-in license verification
            $license = $oxymade_license_client->license();
            $license_data = $license->get_license_data();

            // Map license levels to OxyMade-style levels
            $level = $license_data['level'] ?? 'Free';
            $is_valid = $license_data['is_active'] ?? false;

            // Convert license levels to OxyMade-style levels
            $breakmade_level = self::map_surecart_to_breakmade_level($level);

            return [
                'level' => $breakmade_level,
                'valid' => $is_valid,
                'status' => $is_valid ? 'active' : 'inactive'
            ];

        } catch (\Exception $e) {
            return ['level' => 'Free', 'valid' => false];
        }
    }

    /**
     * Map license levels to OxyMade-style levels
     */
    private static function map_surecart_to_breakmade_level($surecart_level) {
        switch ($surecart_level) {
            case 'All Access':
                return 'Unlimited-LTD';
            case 'Unlimited':
                return 'Unlimited-LTD';
            case 'Design Set Only':
                return 'Layers-LTD';
            case 'Templates Only':
                return 'Layers-LTD';
            case 'Free':
            default:
                return 'Free';
        }
    }

    /**
     * Check if current license is pro or higher (Layers-LTD or Unlimited-LTD)
     *
     * @return boolean
     */
    public static function is_pro() {
        $data = self::get_license_data();
        return $data['is_active'] && in_array($data['level'], ['Layers-LTD', 'Unlimited-LTD']);
    }

    /**
     * Check if current license is unlimited access
     *
     * @return boolean
     */
    public static function is_unlimited() {
        $data = self::get_license_data();
        return $data['is_active'] && $data['level'] === 'Unlimited-LTD';
    }
    
    /**
     * Get license status for display
     *
     * @return string
     */
    public static function get_license_status_display() {
        $data = self::get_license_data();

        if (!$data['is_active']) {
            return 'Activate License';
        }

        $level = $data['level'];
        // Convert level names for better display
        $display_level = str_replace('-LTD', ' Lifetime', $level);
        return "License Active - {$display_level} User";
    }
    
    /**
     * Clear license data when license is deactivated
     */
    public static function clear_license_data() {
        // Clear stored license level
        \delete_option('oxymade_license_level');

        // Clear any legacy cache options
        \delete_option('oxymade_license_cache');
        \delete_option('oxymade_license_cache_expiry');
        \delete_option('oxymade_license_key');
    }

    /**
     * Refresh license data by fetching fresh data from API
     */
    public static function refresh_license_data() {
        global $oxymade_license_client;

        if (!isset($oxymade_license_client)) {
            return false;
        }

        $settings = $oxymade_license_client->settings();
        $license_key = $settings->license_key ?? '';

        if (empty($license_key)) {
            self::clear_license_data();
            return false;
        }

        // Fetch fresh data from API
        $level_data = self::get_license_level_from_api($license_key);

        // Update stored level
        \update_option('oxymade_license_level', $level_data['level']);

        return true;
    }
    
    /**
     * Test license verification - for debugging (only logs when explicitly called)
     */
    public static function test_license_verification() {
        global $oxymade_license_client;

        if (!isset($oxymade_license_client)) {
            error_log('🔐 OxyMade License TEST: License client not available');
            return false;
        }

        $settings = $oxymade_license_client->settings();
        $license_key = $settings->license_key ?? '';
        $activation_id = $settings->activation_id ?? '';

        error_log('🔐 OxyMade License TEST: License key: ' . ($license_key ? 'PRESENT' : 'EMPTY'));
        error_log('🔐 OxyMade License TEST: Activation ID: ' . ($activation_id ? 'PRESENT' : 'EMPTY'));

        if (empty($license_key)) {
            return false;
        }

        try {
            $license = $oxymade_license_client->license();
            $is_active = $license->is_active();
            error_log('🔐 OxyMade License TEST: is_active = ' . ($is_active ? 'TRUE' : 'FALSE'));
            return $is_active;
        } catch (\Exception $e) {
            error_log('🔐 OxyMade License TEST: Exception - ' . $e->getMessage());
            return false;
        }
    }
}


OHA YOOO - Tarih: 2026-08-04 00:23:46