随时都可以在软件Software License Manager wordpress中使用许可证验证问题吗?

时间:2018-11-06 10:32:36

标签: php wordpress web

我正在使用许可证管理器插件 将此插件用于许可证密钥模板或任何其他产品...

但是问题是客户端激活了代码铺设并且工作做得很好并且模板已经激活。

但是每次站点加载时此验证都会出现问题-我的意思是服务器自动进行身份验证。

我希望仅在第一次验证(以后购买)之后才能激活它,并且不再需要将其从服务器(我的站点)发送到许可证中的客户端中,无论出于何种原因,如果服务器站点具有断开连接,然后关闭不要走

因为问题是,如果我的站点断开连接,所有许可的站点将被客户删除,这是一个大问题。

我问插件开发人员,说您需要更改客户端代码,对此代码有解决方案:

<?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 }?>

这意味着每次加载后,我都不批准信用,现在默认情况下,站点上的每次加载,我都要求服务器进行验证,站点本身将自动建立,

我想确保在第一次验证之后,不需要在任何负载下对其进行验证,并且直到它从服务器发送一条消息,表明许可证已过期或被阻止(例如,可以通过插件进行验证)面板)

每次都不需要验证...

YOUR_LICENSE_SERVER_URL =服务器的地址为(许可)-(我的站点)。

根本不需要客户的地址....

这是我在上面提供的代码,无论我们放置锁定模板的位置如何。如果许可证已损坏,将显示错误消息。否则,页面将正确显示。

最初,在我们的模板中,我们有一个设计为许可证设置的部分,用户可以在其中锁定许可证本身,并且基本上是从此处获取的sample_license_key变量。

此变量将发送到许可证服务器的站点地址。如果正确,则用户许可和许可是在服务器站点(我的站点)上制作的,并且在该站点中并且尚未过期。该网站运行没有问题。

此工作流程意味着验证变量sample_license_key并将其发送到服务器站点,并自动将每个负载加载到站点上,但是问题是,如果由于某种原因服务器站点被断开连接,客户站点也会崩溃...

这是许可证管理部分:

在这里,信用也得到验证,如果为真,则证明许可证的正确性及其有效性。

这与许可证收据表格及其验证或停用相同:

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>';
}
?>

谢谢您的指导

0 个答案:

没有答案