Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. <?php
  2. /*
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 3.5.0.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.06.2018
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace WHMCS;
  15.  
  16. class License
  17. {
  18. private $licensekey = '';
  19. private $localkey = false;
  20. private $keydata = null;
  21. private $salt = '';
  22. private $postmd5hash = '';
  23. private $localkeydays = '10';
  24. private $allowcheckfaildays = '5';
  25. private $useInternalLicensingMirror = false;
  26. private $debuglog = array();
  27. private $lastCurlError = null;
  28.  
  29. const LICENSE_API_VERSION = '1.1';
  30. const LICENSE_API_HOSTS = array('a.licensing.whmcs.com', 'b.licensing.whmcs.com', 'c.licensing.whmcs.com', 'd.licensing.whmcs.com', 'e.licensing.whmcs.com', 'f.licensing.whmcs.com');
  31. const STAGING_LICENSE_API_HOSTS = array('hou-1.licensing.web.staging.whmcs.com');
  32. const UNLICENSED_KEY = 'LICENSE-REQUIRED';
  33.  
  34. public function checkFile($value)
  35. {
  36. if ($value != 'a896faf2c31f2acd47b0eda0b3fd6070958f1161') {
  37. throw new Exception\Fatal('File version mismatch. Please contact support.');
  38. }
  39.  
  40. return $this;
  41. }
  42.  
  43. public function setLicenseKey($licenseKey)
  44. {
  45. $this->licensekey = $licenseKey;
  46.  
  47. return $this;
  48. }
  49.  
  50. public function setLocalKey($localKey)
  51. {
  52. $this->decodeLocal($localKey);
  53.  
  54. return $this;
  55. }
  56.  
  57. public function setSalt($version, $hash)
  58. {
  59. if (empty($version) || empty($hash)) {
  60. throw new Exception('Unable to generate licensing salt');
  61. }
  62.  
  63. $this->salt = sha1(sprintf('WHMCS%s%s%s', $version, '|-|', $hash));
  64.  
  65. return $this;
  66. }
  67.  
  68. public function useInternalValidationMirror()
  69. {
  70. $this->useInternalLicensingMirror = true;
  71.  
  72. return $this;
  73. }
  74.  
  75. protected function getHosts()
  76. {
  77. if ($this->useInternalLicensingMirror) {
  78. return self::STAGING_LICENSE_API_HOSTS;
  79. }
  80.  
  81. return self::LICENSE_API_HOSTS;
  82. }
  83.  
  84. public function getLicenseKey()
  85. {
  86. return $this->licensekey;
  87. }
  88.  
  89. protected function getHostDomain()
  90. {
  91. $domain = (defined('WHMCS_LICENSE_DOMAIN') ? WHMCS_LICENSE_DOMAIN : '');
  92.  
  93. if (empty($domain) || $domain == '-') {
  94. throw new Exception('Unable to retrieve current server name. Please check PHP/vhost configuration and ensure SERVER_NAME is displaying appropriately via PHP Info.');
  95. }
  96.  
  97. $this->debug('Host Domain: ' . $domain);
  98.  
  99. return $domain;
  100. }
  101.  
  102. protected function getHostIP()
  103. {
  104. $ip = (defined('WHMCS_LICENSE_IP') ? WHMCS_LICENSE_IP : '');
  105. $this->debug('Host IP: ' . $ip);
  106.  
  107. return $ip;
  108. }
  109.  
  110. protected function getHostDir()
  111. {
  112. $directory = (defined('WHMCS_LICENSE_DIR') ? WHMCS_LICENSE_DIR : '');
  113. $this->debug('Host Directory: ' . $directory);
  114.  
  115. return $directory;
  116. }
  117.  
  118. private function getSalt()
  119. {
  120. return $this->salt;
  121. }
  122.  
  123. protected function isLocalKeyValidToUse()
  124. {
  125. $licenseKey = $this->getKeyData('key');
  126.  
  127. if (empty($licenseKey) || $licenseKey != $this->licensekey) {
  128. throw new Exception('License Key Mismatch in Local Key');
  129. }
  130.  
  131. $originalcheckdate = $this->getCheckDate();
  132. $localmax = Carbon::now()->startOfDay()->addDays(2);
  133.  
  134. if ($originalcheckdate->gt($localmax)) {
  135. throw new Exception('Original check date is in the future');
  136. }
  137. }
  138.  
  139. protected function hasLocalKeyExpired()
  140. {
  141. $originalCheckDate = $this->getCheckDate();
  142. $localExpiryMax = Carbon::now()->startOfDay()->subDays($this->localkeydays);
  143.  
  144. if (!$originalCheckDate || $originalCheckDate->lt($localExpiryMax)) {
  145. throw new Exception('Original check date is outside allowed validity period');
  146. }
  147. }
  148.  
  149. protected function buildPostData()
  150. {
  151. $whmcs = \DI::make('app');
  152. $stats = json_decode($whmcs->get_config('SystemStatsCache'), true);
  153.  
  154. if (!is_array($stats)) {
  155. ..........................................................................
  156. .........................................
  157. ....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement