Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Pmk Web Dev

    (@pumukyyy)

    Hello again @drazenbebic.
    With the code I gave you as an example, it works for me, but I wanted to know if there is any other way to make it safer.

    Thread Starter Pmk Web Dev

    (@pumukyyy)

    Thank you!????

    Thread Starter Pmk Web Dev

    (@pumukyyy)

    If you can give me an example of the best form of implementation, it would be helpful

    Thread Starter Pmk Web Dev

    (@pumukyyy)

    hello again @drazenbebic
    I hope you’re well, I still need your help, I’m a little stuck with the plugin

    Thread Starter Pmk Web Dev

    (@pumukyyy)

    And to verify the license I have something like that

    $msg ='';
    $result = '';
    $api_params = array(
        'consumer_key' => WFS_CONSUMER_KEY,
        'consumer_secret' => WFS_CONSUMER_SECRET,
    );
    
    $url_params = WFS_LICENSE_SERVER_URL;
    $url_params .= urlencode( get_option( 'wfs_license_key' ) );
    
    $query = esc_url_raw( add_query_arg( $api_params, $url_params ) );
    $response = wp_remote_get($query, array('timeout' => 20, 'sslverify' => true));
    
    if ( is_array( $response ) && ! is_wp_error( $response ) ) {
    
        $license_data = json_decode( wp_remote_retrieve_body( $response ) );
    
        if( isset( $license_data->success ) &&  $license_data->success == 1 ) {
    
            $current_date = strtotime(date("Y-m-d H:i:00",time()));
            $expires_date = strtotime($license_data->data->expiresAt);
    
            if ( isset( $license_data->data->licenseKey) && strcmp ( $license_data->data->licenseKey, get_option('wfs_license_key') ) == 0 && $current_date < $expires_date ) {
    
                $result .= $license_data->data->licenseKey;
    
                $msg .= __( 'your license will be active until:' );
                $msg .= ' '. $license_data->data->expiresAt;
    
            }
    
        } else{
    
            $msg .= __( 'Invalid License' );
        
        } 
    
    } else {
    
        $msg .=  __( 'something did not go well when reading the license' );
    
    }
    Thread Starter Pmk Web Dev

    (@pumukyyy)

    Hello again @drazenbebic.
    Thank you for responding so quickly, the idea is to make a freemium add-on. I am new to this world, so I cannot think of another way to do a verification, I know it is very easy to avoid, is there any other way to make it more difficult?
    would something like this be activated or deactivated?

     <?php 
    
    if ( isset( $_REQUEST['activate_license'] ) || isset( $_REQUEST['deactivate_license'] ) ) {
    
        if ( ! wp_verify_nonce(  $_REQUEST['wfs_license_nonce'], 'wfs_license_nonce' ) ) {
    
            wp_die("Error - Invalid nonce verification ?");
    
        }else {
    
            $license_key = sanitize_text_field( $_REQUEST['wfs_license_key'] );             
    
            if ( isset( $_REQUEST['activate_license'] ) ) {
    
                $license_action = 'activate/';
    
            }elseif ( isset( $_REQUEST['deactivate_license'] ) ) {
    
                $license_action = 'deactivate/';
            }
    
            $api_params = array(
                
                'consumer_key' => WFS_CONSUMER_KEY,
                'consumer_secret' => WFS_CONSUMER_SECRET,
            );
    
            $url_params = WFS_LICENSE_SERVER_URL;
            $url_params .= $license_action;
            $url_params .= urlencode($license_key);
    
            $query = esc_url_raw( add_query_arg( $api_params, $url_params ) );
            $response = wp_remote_get($query, array('timeout' => 20, 'sslverify' => false));
    
            if ( is_array( $response ) && ! is_wp_error( $response ) ) {
    
                $license_data = json_decode( wp_remote_retrieve_body( $response ) );
    
                if( 1 == $license_data->success ){
    
                    if ( isset( $_REQUEST['activate_license'] ) ) {
    
                        update_option( 'wfs_license_key', $license_key ); 
    
                    }elseif ( isset( $_REQUEST['deactivate_license'] ) ) {
    
                        update_option( 'wfs_license_key', '' ); 
                    }
    
                }else{
    
                    $msg .= $license_data->message;
                }
            }else {
    
                _e( 'something did not go well when reading the license');
            }
    
        }
    }
    
    ?>
    <form action="" method="post" style="width:100%;">
        <?php wp_nonce_field( 'wfs_license_nonce', 'wfs_license_nonce' ); ?>
        <div class="content-label-share">
            <label class="label-share">
                <p class="label-p"><?php _e( 'License Key' ); ?></p>
                <input class="input-share" type="text" id="sample_license_key" name="wfs_license_key"  value="<?php echo get_option('wfs_license_key'); ?>" >
                <?php if ( !empty( $msg ) ) { echo '<p>'.$msg .'</p>'; } ?>
            </label>
        </div>  
        <p class="submit">
            <?php submit_button( __( 'Activate' ), 'primary', 'activate_license', false, array( 'id' => 'wsf-activate-license-id' ) ); ?>
            <?php submit_button( __( 'Deactivate' ), 'delete', 'deactivate_license', false, array( 'id' => 'wsf-deactivate-license-id' ) ); ?>
        </p>
    </form>     
    <?php 

    Thanks for the help

    • This reply was modified 5 years, 2 months ago by Pmk Web Dev.

    hola yo también estoy interesado en saber una respuesta para eso ademas me gustaría saber si hay algún modo de que un suscriptor puede borrar sus datos almacenado si lo requiere
    gracias!!

Viewing 7 replies - 1 through 7 (of 7 total)