mardi 6 novembre 2018

License validation problem at any time in software Software License Manager wordpress?

I am using the License Manager plugin Use this plugin for the license key template or any other product ...

But the problem is that after the codelaying has been activated by the client and the work is done well and the template is activated.

But there is a problem with this validation every time the site is loaded - I mean the authentication of the server automatically.

I want to be able to activate it only after the first validation (purchase later) and no longer until it is sent from the server (my site) to the client in the license, for any reason, if the server site has been disconnected, then shut down Do not go

Because the problem is that if my site is disconnected, all licensed sites will be dropped by customers and this is a big problem.

I asked the plugin developer, saying that you need to change the client-side code, you have a solution for this code:

<?php
define('YOUR_LICENSE_SERVER_URL','https://localhost');
$api_params=array('slm_action'=>'slm_check','secret_key'=>'245454545445','license_key'=>get_option('sample_license_key'),);
$response=wp_remote_get(add_query_arg($api_params,YOUR_LICENSE_SERVER_URL),array('timeout'=>20,'sslverify'=>false));
$license_data=json_decode(wp_remote_retrieve_body($response));
global $active,$message;if($license_data->result=='success'){
?>
<?php }
else{?>
<?php wp_die(__('No License'));?><?php }?>

This means that after every load, I do not approve the credit, now by default, with every load on the site, I ask the server to validate it, the site itself will automatically be set up,

I want to be sure that after the first validation, it does not need to be verified at any load, and until it sends a message from the server that the license is expired or blocked (for example, it's possible from the plugin panel)

No need to validate after every time ...

YOUR_LICENSE_SERVER_URL = The address of the server is (Licensed) - (my site).

The customer's address does not need here at all ....

This is the code that I provided above wherever we place the locked template. If the license is corrupted, the error message will be displayed. Otherwise, the page will be displayed correctly.

 

Originally, inside our template, we have a section designed as a license setting where the user locks the license itself and is basically the sample_license_key variable that comes from there.

 

This variable will be sent to the site address that is the license server. If it was correct, the user license and license was made on the server site (my site) and it was there and was not expired. The site runs without problems.

 

This workflow means validating the variable sample_license_key and sending it to the server site, with each load loaded on the site automatically, but the problem is that if for any reason the server site was disconnected, the customer site also crashes ...

This is the license management part:

Here, too, the credit is validated, and if true, the correctness of the license and its validity is done.

This is the same as the license receipt form and its validation or deactivation:

function sample_license_management_page () {
    echo '<div class = "wrap">';
    echo '<h2> Manage Template Licensing </ h2>';
    if (isset ($ _ REQUEST ['activate_license'])) {
        $ license_key = $ _REQUEST ['sample_license_key'];
        $ api_params = array (
            'slm_action' => 'slm_activate'
            'secret_key' => YOUR_SPECIAL_SECRET_KEY
            'license_key' => $ license_key
            'registered_domain' => $ _SERVER ['SERVER_NAME'],
            'item_reference' => urlencode (YOUR_ITEM_REFERENCE)
        );
        $ query = esc_url_raw (add_query_arg ($ api_params, YOUR_LICENSE_SERVER_URL));
        $ response = wp_remote_get ($ query, array ('timeout' => 20, 'sslverify' => false));
        if (is_wp_error ($ response)) {
            echo "Unexpected error! Query sent with an error.";
        }
        $ license_data = json_decode (wp_remote_retrieve_body ($ response));
        if ($ license_data-> result == 'success') {
            echo '<br /> The following message was returned from the server:'. $ license_data-> message;
echo '<br /> Licensed successfully. ';
            update_option ('sample_license_key', $ license_key);
        }
        else {
            echo '<br /> The following message was returned from the server:'. $ license_data-> message;
        }
    }
    if (isset ($ _ REQUEST ['deactivate_license'])) {
        $ license_key = $ _REQUEST ['sample_license_key'];
        $ api_params = array (
            'slm_action' => 'slm_deactivate'
            'secret_key' => YOUR_SPECIAL_SECRET_KEY
            'license_key' => $ license_key
            'registered_domain' => $ _SERVER ['SERVER_NAME'],
            'item_reference' => urlencode (YOUR_ITEM_REFERENCE)
        );
        $ query = esc_url_raw (add_query_arg ($ api_params, YOUR_LICENSE_SERVER_URL));
        $ response = wp_remote_get ($ query, array ('timeout' => 20, 'sslverify' => false));
        if (is_wp_error ($ response)) {
            echo "Unexpected error! Query sent with an error.";
        }

        $ license_data = json_decode (wp_remote_retrieve_body ($ response));

        
        if ($ license_data-> result == 'success') {// Success was returned for the license activation
            echo '<br /> The following message was returned from the server:'. $ license_data-> message;
            echo '<br /> Licensed successfully. ';
            update_option ('sample_license_key', '');
        }
        else {
            echo '<br /> The following message was returned from the server:'. $ license_data-> message;
        }
        
    }
    ?>
    <p> Please enter the license key to activate the template, when you purchase the product, the license key has been delivered to you, if you do not have a license key, contact us.

</ p>
    <formaction = "" method = "post">
        <table class = "form-table">
            <tr>
                <th style = "width: 100px;"> <label for = "sample_license_key"> license key </ label> </ th>
                <td> <input class = "regular-text" type = "text" id = "sample_license_key" name = "sample_license_key" value = "<? php echo get_option ('sample_license_key');?>"> </ td>
            </ tr>
        </ table>
        <p class = "submit">
            <input type = "submit" name = "activate_license" value = "activation" class = "button-primary" />
            <input type = "submit" name = "deactivate_license" value = "disable" class = "button" />
        </ p>
    </ form>
    <? php
    
    echo '</ div>';
}
?>

Thank you for guiding me




Aucun commentaire:

Enregistrer un commentaire