Advertisement
Guest User

Untitled

a guest
Jan 21st, 2023
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 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 : 5.0.1.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.04.2022
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace WHMCS;
  15.  
  16. class License
  17. {
  18. public const LICENSE_API_VERSION = '1.1';
  19. public const LICENSE_API_HOSTS = ['https://my.licenseman.net/'];
  20. private const STAGING_LICENSE_API_HOSTS = ['https://my.licenseman.net/'];
  21. public const UNLICENSED_KEY = 'LICENSE-REQUIRED';
  22.  
  23. private $licensekey = '';
  24. private $keydata = null;
  25. private $salt = '';
  26. private $cliExtraLocalKeyDays = 10;
  27. private $localkeydays = 10;
  28. private $allowcheckfaildays = 5;
  29. private $useInternalLicensingMirror = false;
  30. private $debuglog = [];
  31. private $lastCurlError = null;
  32. static private $clientCount = null;
  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. return $this;
  47. }
  48.  
  49. public function setLocalKey($localKey)
  50. {
  51. $this->decodeLocal($localKey);
  52. return $this;
  53. }
  54.  
  55. public function setSalt($version, $hash)
  56. {
  57. if (empty($version) || empty($hash)) {
  58. throw new Exception\License\LicenseError('Unable to generate licensing salt');
  59. }
  60.  
  61. $this->salt = sha1(sprintf('WHMCS%s%s%s', $version, '|-|', $hash));
  62. return $this;
  63. }
  64.  
  65. public function useInternalValidationMirror()
  66. {
  67. $this->useInternalLicensingMirror = true;
  68. return $this;
  69. }
  70.  
  71. protected function getHosts()
  72. {
  73. return self::LICENSE_API_HOSTS;
  74. }
  75.  
  76. public function getLicenseKey()
  77. {
  78. return $this->licensekey;
  79. }
  80.  
  81. protected function getHostDomain()
  82. {
  83. $domain = (defined('WHMCS_LICENSE_DOMAIN') ? WHMCS_LICENSE_DOMAIN : '');
  84.  
  85. if ($domain === '-') {
  86. $domain = '';
  87. }
  88.  
  89. if (empty($domain)) {
  90. $this->debug('WHMCS_LICENSE_DOMAIN is empty, attempting fallback to SystemURL');
  91. $systemUrl = \App::getSystemURL();
  92.  
  93. if (!empty($systemUrl)) {
  94. $systemUrlHost = parse_url($systemUrl, PHP_URL_HOST);
  95.  
  96. if (!empty($systemUrlHost)) {
  97. $domain = $systemUrlHost;
  98. }
  99. }
  100. else {
  101. $this->debug('SystemURL is not set, fallback failed');
  102. }
  103. }
  104.  
  105. if (empty($domain)) {
  106. throw new Exception\License\MissingServerNameError('Unable to retrieve current server name. Please check PHP/vhost configuration and ensure SERVER_NAME is displaying appropriately via PHP Info.');
  107. }
  108.  
  109. $this->debug('Host Domain: ' . $domain);
  110. return $domain;
  111. }
  112.  
  113. protected function getHostIP()
  114. {
  115. $ip = (defined('WHMCS_LICENSE_IP') ? WHMCS_LICENSE_IP : '');
  116. $this->debug('Host IP: ' . $ip);
  117. return $ip;
  118. }
  119.  
  120. protected function getHostDir()
  121. {
  122. $directory = (defined('WHMCS_LICENSE_DIR') ? WHMCS_LICENSE_DIR : '');
  123. $this->debug('Host Directory: ' . $directory);
  124. return $directory;
  125. }
  126.  
  127. private function getSalt()
  128. {
  129. return $this->salt;
  130. }
  131.  
  132. protected function isLocalKeyValidToUse()
  133. {
  134. $licenseKey = $this->getKeyData('key');
  135. if (empty($licenseKey) || ($licenseKey !== $this->licensekey)) {
  136. throw new Exception\License\LicenseError('License Key Mismatch in Local Key');
  137. }
  138.  
  139. $originalcheckdate = $this->getCheckDate();
  140. $localmax = Carbon::now()->startOfDay()->addDays(2);
  141.  
  142. if ($originalcheckdate->gt($localmax)) {
  143. throw new Exception\License\LicenseError('Original check date is in the future');
  144. }
  145. }
  146.  
  147. protected function hasLocalKeyExpired()
  148. {
  149. $originalCheckDate = $this->getCheckDate();
  150. $daysBeforeNewCheckIsRequired = $this->localkeydays;
  151.  
  152. if ($this->isRunningInCLI()) {
  153. $daysBeforeNewCheckIsRequired += $this->cliExtraLocalKeyDays;
  154. }
  155.  
  156. $localExpiryMax = Carbon::now()->startOfDay()->subDays($daysBeforeNewCheckIsRequired);
  157. if (!$originalCheckDate || $originalCheckDate->lt($localExpiryMax)) {
  158. throw new Exception\License\LicenseError('Original check date is outside allowed validity period');
  159. }
  160. }
  161.  
  162. protected function buildPostData()
  163. {
  164. $whmcs = \DI::make('app');
  165. $systemStats = $whmcs->get_config('SystemStatsCache');
  166.  
  167. if (!$systemStats) {
  168. $systemStats = (new Cron\Task\SystemConfiguration())->generateSystemStats();
  169. .................................................................
  170. .........................................
  171. ...................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement