Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 4.0.9.0
- * @ Author : DeZender
- * @ Release on : 08.08.2019
- * @ Official site : http://DeZender.Net
- *
- */
- namespace FITC\XVCB\WooCommerce;
- class LicenseBoxAPI
- {
- const LB_API_DEBUG = false;
- private $product_id;
- private $api_url;
- private $current_version;
- private $current_path;
- private $root_path;
- private $verify_type;
- private $api_key;
- private $license_file;
- private $verification_period;
- public function __construct()
- {
- $this->product_id = '51986767';
- $this->api_url = 'https://license.codetay.com/';
- $this->current_version = 'v1.0.0';
- $this->current_path = realpath(__DIR__);
- $this->root_path = realpath($this->current_path . '/..');
- $this->verify_type = 'non_envato';
- $this->api_key = '0FE1EF7D5FCA60E3102A';
- $this->license_file = $this->current_path . '/.lic';
- $this->verification_period = '0';
- if (!self::LB_API_DEBUG) {
- ini_set('display_errors', 0);
- }
- }
- public function check_connection()
- {
- $data_array = [];
- $get_data = $this->callAPI('POST', $this->api_url . 'api/check_connection_ext', json_encode($data_array));
- $response = json_decode($get_data, true);
- return $response;
- }
- public function getProductID()
- {
- return $this->product_id;
- }
- private function callAPI($method, $url, $data)
- {
- $curl = curl_init();
- switch ($method) {
- case 'POST':
- curl_setopt($curl, CURLOPT_POST, 1);
- if ($data) {
- curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
- }
- break;
- case 'PUT':
- curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
- if ($data) {
- curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
- }
- break;
- default:
- if ($data) {
- $url = sprintf('%s?%s', $url, http_build_query($data));
- }
- }
- $this_server_name = getenv('SERVER_NAME') ?: $_SERVER['SERVER_NAME'] ?: getenv('HTTP_HOST') ?: $_SERVER['HTTP_HOST'];
- $this_http_or_https = ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')) ? 'https://' : 'http://');
- $this_url = $this_http_or_https . $this_server_name . $_SERVER['REQUEST_URI'];
- $this_ip = getenv('SERVER_ADDR') ?: $_SERVER['SERVER_ADDR'] ?: getenv('REMOTE_ADDR') ?: $_SERVER['REMOTE_ADDR'] ?: $this->get_ip_from_third_party();
- curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type:application/json', 'LB-API-KEY: ' . $this->api_key, 'LB-URL: ' . $this_url, 'LB-IP: ' . $this_ip]);
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- $result = curl_exec($curl);
- if (!$result && !self::LB_API_DEBUG) {
- $rs = ['status' => false, 'message' => 'Connection to server failed or the server returned an error, please contact support.'];
- return json_encode($rs);
- }
- $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
- if (!self::LB_API_DEBUG) {
- if ($http_status != 200) {
- $rs = ['status' => false, 'message' => 'Server returned an invalid response, please contact support.'];
- return json_encode($rs);
- }
- }
- curl_close($curl);
- return $result;
- }
- private function get_ip_from_third_party()
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'http://ipecho.net/plain');
- .......................................................................
- ........................................
- ...............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement