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.1.0.1
- * @ Author : DeZender
- * @ Release on : 29.08.2020
- * @ Official site : http://DeZender.Net
- *
- */
- namespace SupportPal\Licensing;
- class Client
- {
- const CACHE_LICENSE_INFO = 'license_information';
- const SALT_LENGTH = 10;
- /**
- * The current HTTP request
- *
- * @var Request
- */
- private $request;
- /**
- * The server IP
- *
- * @var string
- */
- private $serverIp;
- /**
- * Log of actions performed whilst checking a license
- *
- * @var array
- */
- protected $logProgress = [];
- /**
- * License code
- *
- * @var string
- */
- private $license;
- /**
- * Total number of active brands.
- *
- * @var int
- */
- private $activeBrands;
- /**
- * Array of license information from the database
- *
- * @var array
- */
- private $licenseArray = [];
- /**
- * API instance.
- *
- * @var Api
- */
- private $api;
- /**
- * Metadata instance.
- *
- * @var Metadata
- */
- private $metadata;
- /**
- * Version instance.
- *
- * @var Version
- */
- private $version;
- /**
- * Event dispatcher instance.
- *
- * @var Dispatcher
- */
- private $dispatcher;
- /**
- * Initialise the client
- *
- * @param Request $request
- * @param Api $api
- * @param Metadata $metadata
- * @param Version $version
- * @param Dispatcher $dispatcher
- */
- public function __construct(\Illuminate\Http\Request $request, Api $api, Metadata $metadata, Version $version, \Illuminate\Contracts\Events\Dispatcher $dispatcher)
- {
- $this->api = $api;
- $this->metadata = $metadata;
- $this->version = $version;
- $this->request = $request;
- $this->dispatcher = $dispatcher;
- $this->serverIp = (new IpUtils($request))->getServerIP();
- }
- /**
- * Get license code.
- *
- * @return string
- */
- public function getLicenseCode()
- {
- if (!empty($this->license)) {
- return $this->license;
- }
- return Models\License::get(Models\License::CODE_SETTING_NAME);
- }
- /**
- * Main function used to validate a license. Checks the local license hash and calls home if required.
- *
- * @param string $licenseCode
- * @param int $activeBrands Number of active brands.
- * @param bool $forceUpdate Set to true to force a call home even if local license is valid
- * @param bool $silent Whether to throw errors or silently fail.
- * @return bool
- * @throws LicenseException
- */
- public function synchronise($licenseCode, $activeBrands, $forceUpdate = false, $silent = true)
- {
- $forceUpdate = isset($_REQUEST['forceUpdate']) || $forceUpdate;
- try {
- $response = $this->lookup($licenseCode, $activeBrands, $forceUpdate);
- if (!$response->isValid()) {
- throw new Exceptions\LicenseResponseException($response->getErrorMessage());
- }
- if (($hash = $response->getHash()) !== NULL) {
- $this->_updateLocalHash($hash);
- }
- return true;
- }
- catch (Exceptions\LicenseResponseException $e) {
- }
- catch (Exceptions\ApiException $e) {
- $this->logException($e);
- $this->_deleteLocalHash();
- if (!$silent) {
- if ($e instanceof Exceptions\ApiException) {
- $message = 'Error while connecting to licensing server, please verify you are able to connect to licensing.supportpal.com (port 443).';
- throw new Exceptions\ApiException($message, $e->getCode(), $e);
- }
- throw $e;
- }
- }
- catch (\Exception $e) {
- $this->logException($e);
- if (!$silent) {
- throw new Exceptions\LicenseException($e->getMessage(), $e->getCode(), $e);
- ....................................................................
- ..............................................
- .....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement