Advertisement
Guest User

Untitled

a guest
Dec 7th, 2020
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 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.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace SupportPal\Licensing;
  15.  
  16. class Client
  17. {
  18. const CACHE_LICENSE_INFO = 'license_information';
  19. const SALT_LENGTH = 10;
  20.  
  21. /**
  22. * The current HTTP request
  23. *
  24. * @var Request
  25. */
  26. private $request;
  27. /**
  28. * The server IP
  29. *
  30. * @var string
  31. */
  32. private $serverIp;
  33. /**
  34. * Log of actions performed whilst checking a license
  35. *
  36. * @var array
  37. */
  38. protected $logProgress = [];
  39. /**
  40. * License code
  41. *
  42. * @var string
  43. */
  44. private $license;
  45. /**
  46. * Total number of active brands.
  47. *
  48. * @var int
  49. */
  50. private $activeBrands;
  51. /**
  52. * Array of license information from the database
  53. *
  54. * @var array
  55. */
  56. private $licenseArray = [];
  57. /**
  58. * API instance.
  59. *
  60. * @var Api
  61. */
  62. private $api;
  63. /**
  64. * Metadata instance.
  65. *
  66. * @var Metadata
  67. */
  68. private $metadata;
  69. /**
  70. * Version instance.
  71. *
  72. * @var Version
  73. */
  74. private $version;
  75. /**
  76. * Event dispatcher instance.
  77. *
  78. * @var Dispatcher
  79. */
  80. private $dispatcher;
  81.  
  82. /**
  83. * Initialise the client
  84. *
  85. * @param Request $request
  86. * @param Api $api
  87. * @param Metadata $metadata
  88. * @param Version $version
  89. * @param Dispatcher $dispatcher
  90. */
  91. public function __construct(\Illuminate\Http\Request $request, Api $api, Metadata $metadata, Version $version, \Illuminate\Contracts\Events\Dispatcher $dispatcher)
  92. {
  93. $this->api = $api;
  94. $this->metadata = $metadata;
  95. $this->version = $version;
  96. $this->request = $request;
  97. $this->dispatcher = $dispatcher;
  98. $this->serverIp = (new IpUtils($request))->getServerIP();
  99. }
  100.  
  101. /**
  102. * Get license code.
  103. *
  104. * @return string
  105. */
  106. public function getLicenseCode()
  107. {
  108. if (!empty($this->license)) {
  109. return $this->license;
  110. }
  111.  
  112. return Models\License::get(Models\License::CODE_SETTING_NAME);
  113. }
  114.  
  115. /**
  116. * Main function used to validate a license. Checks the local license hash and calls home if required.
  117. *
  118. * @param string $licenseCode
  119. * @param int $activeBrands Number of active brands.
  120. * @param bool $forceUpdate Set to true to force a call home even if local license is valid
  121. * @param bool $silent Whether to throw errors or silently fail.
  122. * @return bool
  123. * @throws LicenseException
  124. */
  125. public function synchronise($licenseCode, $activeBrands, $forceUpdate = false, $silent = true)
  126. {
  127. $forceUpdate = isset($_REQUEST['forceUpdate']) || $forceUpdate;
  128.  
  129. try {
  130. $response = $this->lookup($licenseCode, $activeBrands, $forceUpdate);
  131.  
  132. if (!$response->isValid()) {
  133. throw new Exceptions\LicenseResponseException($response->getErrorMessage());
  134. }
  135.  
  136. if (($hash = $response->getHash()) !== NULL) {
  137. $this->_updateLocalHash($hash);
  138. }
  139.  
  140. return true;
  141. }
  142. catch (Exceptions\LicenseResponseException $e) {
  143. }
  144. catch (Exceptions\ApiException $e) {
  145. $this->logException($e);
  146. $this->_deleteLocalHash();
  147.  
  148. if (!$silent) {
  149. if ($e instanceof Exceptions\ApiException) {
  150. $message = 'Error while connecting to licensing server, please verify you are able to connect to licensing.supportpal.com (port 443).';
  151. throw new Exceptions\ApiException($message, $e->getCode(), $e);
  152. }
  153.  
  154. throw $e;
  155. }
  156. }
  157. catch (\Exception $e) {
  158. $this->logException($e);
  159.  
  160. if (!$silent) {
  161. throw new Exceptions\LicenseException($e->getMessage(), $e->getCode(), $e);
  162. ....................................................................
  163. ..............................................
  164. .....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement