Advertisement
Guest User

Untitled

a guest
Jan 8th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.0.9.0
  8. * @ Author : DeZender
  9. * @ Release on : 08.08.2019
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace FITC\XVCB\WooCommerce;
  15.  
  16. class LicenseBoxAPI
  17. {
  18. const LB_API_DEBUG = false;
  19.  
  20. private $product_id;
  21. private $api_url;
  22. private $current_version;
  23. private $current_path;
  24. private $root_path;
  25. private $verify_type;
  26. private $api_key;
  27. private $license_file;
  28. private $verification_period;
  29.  
  30. public function __construct()
  31. {
  32. $this->product_id = '51986767';
  33. $this->api_url = 'https://license.codetay.com/';
  34. $this->current_version = 'v1.0.0';
  35. $this->current_path = realpath(__DIR__);
  36. $this->root_path = realpath($this->current_path . '/..');
  37. $this->verify_type = 'non_envato';
  38. $this->api_key = '0FE1EF7D5FCA60E3102A';
  39. $this->license_file = $this->current_path . '/.lic';
  40. $this->verification_period = '0';
  41.  
  42. if (!self::LB_API_DEBUG) {
  43. ini_set('display_errors', 0);
  44. }
  45. }
  46.  
  47. public function check_connection()
  48. {
  49. $data_array = [];
  50. $get_data = $this->callAPI('POST', $this->api_url . 'api/check_connection_ext', json_encode($data_array));
  51. $response = json_decode($get_data, true);
  52. return $response;
  53. }
  54.  
  55. public function getProductID()
  56. {
  57. return $this->product_id;
  58. }
  59.  
  60. private function callAPI($method, $url, $data)
  61. {
  62. $curl = curl_init();
  63.  
  64. switch ($method) {
  65. case 'POST':
  66. curl_setopt($curl, CURLOPT_POST, 1);
  67.  
  68. if ($data) {
  69. curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  70. }
  71.  
  72. break;
  73. case 'PUT':
  74. curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
  75.  
  76. if ($data) {
  77. curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  78. }
  79.  
  80. break;
  81. default:
  82. if ($data) {
  83. $url = sprintf('%s?%s', $url, http_build_query($data));
  84. }
  85. }
  86.  
  87. $this_server_name = getenv('SERVER_NAME') ?: $_SERVER['SERVER_NAME'] ?: getenv('HTTP_HOST') ?: $_SERVER['HTTP_HOST'];
  88. $this_http_or_https = ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')) ? 'https://' : 'http://');
  89. $this_url = $this_http_or_https . $this_server_name . $_SERVER['REQUEST_URI'];
  90. $this_ip = getenv('SERVER_ADDR') ?: $_SERVER['SERVER_ADDR'] ?: getenv('REMOTE_ADDR') ?: $_SERVER['REMOTE_ADDR'] ?: $this->get_ip_from_third_party();
  91. curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type:application/json', 'LB-API-KEY: ' . $this->api_key, 'LB-URL: ' . $this_url, 'LB-IP: ' . $this_ip]);
  92. curl_setopt($curl, CURLOPT_URL, $url);
  93. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  94. $result = curl_exec($curl);
  95. if (!$result && !self::LB_API_DEBUG) {
  96. $rs = ['status' => false, 'message' => 'Connection to server failed or the server returned an error, please contact support.'];
  97. return json_encode($rs);
  98. }
  99.  
  100. $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  101.  
  102. if (!self::LB_API_DEBUG) {
  103. if ($http_status != 200) {
  104. $rs = ['status' => false, 'message' => 'Server returned an invalid response, please contact support.'];
  105. return json_encode($rs);
  106. }
  107. }
  108.  
  109. curl_close($curl);
  110. return $result;
  111. }
  112.  
  113. private function get_ip_from_third_party()
  114. {
  115. $ch = curl_init();
  116. curl_setopt($ch, CURLOPT_URL, 'http://ipecho.net/plain');
  117. .......................................................................
  118. ........................................
  119. ...............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement