Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*This is a partially decoded file (50%), with 697 lines of code, size 23.91 KB.
- /*The fully decoded file has 1416 lines of code and a size of 47.82 KB.*/
- /*Rev:07.09.23r0 Php8.2.5*/
- namespace CodeLathe\Core\Subsystem\System\License;
- defined('TONIDO_CLOUD_ROOT_DIR') || exit('Forbidden');
- class LicenseManager
- {
- public const GROUP_ENTERPRISE_SERVER_BASE = 'ENTERPRISE_SERVER_BASE';
- public const GROUP_ENTERPRISE_ONLINE_BASE = 'ENTERPRISE_ONLINE_BASE';
- public const COMPONENT_TONIDOCLOUD = 'Tonido Cloud';
- public const COMPONENT_SERVERLINK = 'SERVERLINK';
- public const COMPONENT_FSSYNC = 'FSSYNC';
- public const COMPONENT_ENTERPRISE = 'ENTERPRISE';
- public const COMPONENT_SALESFORCE = 'SALESFORCE';
- public const COMPONENT_RETENTION = 'RETENTION';
- public const COMPONENT_PATTERNSEARCH = 'PATTERNSEARCH';
- public const COMPONENT_FIPS140 = 'FIPS140';
- public const COMPONENT_SIEM = 'SIEM';
- public const COMPONENT_CCS = 'CCE';
- public const COMPONENT_COMMUNITY = 'COMMUNITY';
- public const COMPONENT_DRM = 'DRM';
- public const COMPONENT_LIMITED_USER_2FA = 'LIMITED2FA';
- public const COMPONENT_CASB = 'CASB';
- public const COMPONENT_OCR = 'OCR';
- public const COMPONENT_MSTEAMS = 'MSTEAMS';
- public const COMPONENT_COMPLIANCE = 'COMPLIANCE';
- public const COMPONENT_AUTOMATION_WORKFLOW = 'AUTOMATION_WORKFLOW';
- public const COMPONENT_DISABLE_POWERED_BY = 'OEM_DISABLE_OPTION1';
- public const COMPONENT_CAD_VIEWER = 'CAD_VIEWER';
- public const COMPONENT_AD_LDAP = 'AD_LDAP';
- public const COMPONENT_SSO = 'SSO';
- public const COMPONENT_DLP = 'DLP';
- static public $standaloneComponents = array('COMMUNITY', 'OEM_DISABLE_OPTION1');
- private $settingsManager;
- private $userDataStore;
- private $keyRecordDataStore;
- private $logger;
- public function __construct()
- {
- $this->userDataStore = \CodeLathe\Application\ContainerFacade::get('CodeLathe\\Core\\Subsystem\\User\\User\\UserDataStore');
- $this->settingsManager = \CodeLathe\Application\ContainerFacade::get('CodeLathe\\Core\\Infrastructure\\Settings\\SettingsManager');
- $this->keyRecordDataStore = \CodeLathe\Application\ContainerFacade::get('CodeLathe\\Core\\Common\\Utility\\KeyRecord\\KeyRecordDataStore');
- $this->logger = \CodeLathe\Application\ContainerFacade::get('CodeLathe\\Application\\Service\\LoggerService');
- }
- public static function isCommunityEdition(bool $safeMode = FALSE): bool
- {
- $settingsManager = \CodeLathe\Core\Infrastructure\Settings\SettingsManager::getInstance();
- if ($safeMode && (($settingsManager->getSiteSetting()) || \CodeLathe\Core\Infrastructure\Database\Database::hasInstance())) {
- throw (new \CodeLathe\Core\Common\Exception\TonidoCloudException('Internal settings have already been set'));
- }
- $isOk = (new self())->isComponentOK('COMMUNITY');
- if ($safeMode) {
- $settingsManager->clearSiteSetting();
- \CodeLathe\Core\Infrastructure\Database\Database::destroyInstance();
- }
- return $isOk;
- }
- public function isComponentOK($reqComponent)
- {
- $result = $this->isLicenseValid($message);
- if ($result) {
- $externalSource = $this->settingsManager->getSetting('TONIDOCLOUD_LICENSE_EXTERNAL_SOURCE', 'string', 'NONE');
- if ($externalSource == 'NONE' || $externalSource == '') {
- $xmldata = $this->settingsManager->getSetting('INSTALL_LICENSE', 'string', '');
- if ($xmldata == '') {
- return FALSE;
- }
- $licensedata = $this->getLicenseData($xmldata);
- $license = $this->getLicense($licensedata);
- $component = $license->getComponent();
- $compArray = $this->getComponentArray($component);
- $isComponentInLicense = in_array($reqComponent, $compArray, TRUE);
- if ($isComponentInLicense) {
- return TRUE;
- }
- $isEnterpriseLicense = in_array('ENTERPRISE', $compArray, TRUE);
- $isStandaloneComponent = in_array($reqComponent, self::$standaloneComponents, TRUE);
- return $isEnterpriseLicense && !$isStandaloneComponent;
- }
- else {
- $ismulti = $this->settingsManager->getSetting('TONIDOCLOUD_MULTISITE_ENABLE', 'int', '0');
- if ($ismulti == 0) {
- $obj = LicenseExternalHelper::getInstance();
- return $obj->isComponentOK($reqComponent, $message);
- }
- else {
- $message = 'Multi Site not Supported in this License.';
- $this->logger->logError($message);
- return FALSE;
- }
- }
- }
- return FALSE;
- }
- public function isLicenseValid(&$message)
- {
- $message = '';
- $result = FALSE;
- if ($this->getLicenseCheckFromCache($result, $message)) {
- return $result;
- }
- $externalSource = $this->settingsManager->getSetting('TONIDOCLOUD_LICENSE_EXTERNAL_SOURCE', 'string', 'NONE');
- if ($externalSource == 'NONE' || $externalSource == '') {
- $xmldata = $this->settingsManager->getSetting('INSTALL_LICENSE', 'string', '');
- if ($xmldata == '') {
- $message = 'Invalid License';
- $result = FALSE;
- }
- else {
- $licType = 0;
- $result = $this->checkLicenseString($xmldata, $message, $licType);
- }
- }
- else {
- $ismulti = $this->settingsManager->getSetting('TONIDOCLOUD_MULTISITE_ENABLE', 'int', '0');
- if ($ismulti == 0) {
- $obj = LicenseExternalHelper::getInstance();
- $result = $obj->checkLicense($message);
- }
- else {
- $message = 'Multi Site not Supported in this License.';
- $result = FALSE;
- }
- }
- $this->addLicenseCheckToCache($result, $message);
- return $result;
- }
- private function getLicenseCheckFromCache(bool &$isvalid, string &$message): bool
- {
- if (!(\CodeLathe\Core\Common\RequestCache::getValue('licensevalid'))) {
- return FALSE;
- }
- $validity = \CodeLathe\Core\Common\RequestCache::getValue('licensevalid');
- list($isvalid, $message) = explode('#', $validity);
- return TRUE;
- }
- public function checkLicenseString($xmldata, &$message, &$licType)
- {
- $message = '';
- $licType = 0;
- $license = $this->loadLicenseFromXMLData($xmldata, $message);
- if ($license == NULL) {
- $message = 'Invalid License';
- return FALSE;
- }
- $this->checkHost($license->getHost(), $message);
- if ($message != '') {
- $message = 'Invalid License Host';
- return FALSE;
- }
- $this->checkLockedVersion($license->getLockedVersion(), $message);
- if ($message != '') {
- return FALSE;
- }
- if ($license->getSPLA() == '1') {
- $licType = 1;
- if (time() < strtotime($license->getExpiryDate())) {
- $newdate = strtotime('+1 month', strtotime($license->getIssueDate()));
- $expirationdate = mktime(0, 0, 0, date('m', $newdate), 16, date('Y', $newdate));
- $finalexpirationdate = strtotime($license->getExpiryDate());
- $extensiondata = $this->settingsManager->getSetting('EXTENSION_LICENSE', 'string', '');
- $extlicense = $this->loadSPLALicenseFromXMLData($extensiondata, $message);
- if ($extlicense != NULL) {
- $newdate = strtotime('+1 month', strtotime($extlicense->getIssueDate()));
- $extexpirationdate = mktime(0, 0, 0, date('m', $newdate), 16, date('Y', $newdate));
- if ($expirationdate < $extexpirationdate) {
- $expirationdate = $extexpirationdate;
- }
- if ($finalexpirationdate < $expirationdate) {
- $expirationdate = $finalexpirationdate;
- }
- }
- if ($expirationdate < time()) {
- $message = 'License Expired';
- }
- }
- else {
- $message = 'License Expired';
- }
- }
- else if (time() < strtotime($license->getExpiryDate())) {
- $activeCount = $this->getActiveUsers();
- $allowedCount = $license->getAccountCount();
- if ($allowedCount < $activeCount) {
- if (!($this->isWithinAdditionalGuestAccountsLimit((int) $allowedCount, $activeCount, $license->getAdditionalGuestAccounts()))) {
- $message = sprintf("The number of active users exceeds the maximum of %s license accounts. \r\n Before applying again, please check your user list or contact support.", $allowedCount);
- }
- }
- $this->checkHost($license->getHost(), $message);
- }
- else {
- $message = 'License Expired';
- }
- if ($message == '') {
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
- public function loadLicenseFromXMLData($xmldata, &$message)
- {
- if ($xmldata == '') {
- return NULL;
- }
- $licensedata = $this->getLicenseData($xmldata);
- $signaturedata = $this->getSignatureData($xmldata);
- $signaturevalue = $this->getSignatureValue($signaturedata);
- $signatureindex = $this->getSignatureIndex($signaturedata);
- if (intval($signatureindex) === 0) {
- $message = 'Unsupported license file version';
- return NULL;
- }
- $public_key = $this->getPublicKey($signatureindex);
- $b64decodedSignature = base64_decode($signaturevalue);
- $ok = openssl_verify($licensedata, $b64decodedSignature, $public_key, OPENSSL_ALGO_SHA1);
- if ($ok == 1) {
- return $this->getLicense($licensedata);
- }
- $message = 'Invalid License File';
- return NULL;
- }
- private function getLicenseData($xmldata)
- {
- $findme1 = '<LicenseData>';
- $findme2 = '</LicenseData>';
- $pos1 = strpos($xmldata, $findme1);
- $pos2 = strpos($xmldata, $findme2) + 14;
- return rtrim(ltrim(substr($xmldata, $pos1, $pos2 - $pos1)));
- }
- private function getSignatureData($xmldata)
- {
- $findme1 = '<SignatureData>';
- $findme2 = '</SignatureData>';
- $pos1 = strpos($xmldata, $findme1);
- $pos2 = strpos($xmldata, $findme2) + 16;
- return rtrim(ltrim(substr($xmldata, $pos1, $pos2 - $pos1)));
- }
- private function getSignatureValue($a_signaturedata)
- {
- libxml_use_internal_errors(TRUE);
- $xml = simplexml_load_string($a_signaturedata);
- if ($xml !== FALSE) {
- return $xml->SignatureValue;
- }
- return '';
- }
- private function getSignatureIndex($a_signaturedata)
- {
- libxml_use_internal_errors(TRUE);
- $xml = simplexml_load_string($a_signaturedata);
- if ($xml !== FALSE) {
- return $xml->SignatureIndex;
- }
- return '';
- }
- private function getPublicKey($signatureindex)
- {
- $key = '';
- if ($signatureindex == 1) {
- $key = "-----BEGIN PUBLIC KEY-----\r\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6xS6ozD+ritoaVk5nGvI\r\nKECmKr+T0VFRQaPATIaA1A4pZgiMjnTM50UjT6/QU3fkAg09l2pDVHGDlOWPlkuc\r\naHAHDO9klyOjZBxt4yWuNo/s/9gi+x6syLvIqqpl+LMrk/RDfHEXTaBa+YdmzupZ\r\nw1742DO5V8n2/Nc6LfeGXaNEYiIaj1EHudEaUeKA7slF/ZnVyZAQentwr/Pqh9oY\r\n302+5jEmi9LQ2R/KgLiWRozgFTbw9GLoiGBVm8uquIE9gz8y6krrOgzFWKzKDMG7\r\nreP/adM4m4z/bv5VaOAiIZME6HRZ/2qCRpbdoKIqztO189aslDa5ao9PrQQLjnKi\r\nkwIDAQAB\r\n-----END PUBLIC KEY-----";
- }
- return $key;
- }
- public function getManifestPublicKey()
- {
- return "-----BEGIN PUBLIC KEY-----\r\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApQq0p/BxYuYtW540zg/N\r\nC/HIIf79A1+G8deLFCQCfkuNKSUeshTPNoldU4U79BUsxjMPcvNDAM7sE10svRt6\r\niytJmZzBI5GtNy1WHvNMnA6rnoxCrfatODO314Xoj+hy3jVFXczSW4e/DOwfGIca\r\npTBkDjSfBNVv/QF4CEPfo6lpJfBu7/nOdcAEv2hwx3ELNeG1OsfyN/GbJae4S+CI\r\nwTtXQVIsJuAHDx0YcwnVQmdkvUcXib77xsSqZHPTAhSt5E/kxKGheVR0V0lJSaP+\r\nBFM3yrxetrCFhXEW2w/7t9j0rNTenarQlQjK2MBQG8eE2iEGt4xuE0N0A/bTB2Ej\r\n6QIDAQAB\r\n-----END PUBLIC KEY-----";
- }
- private function getLicense($a_licensedata): License
- {
- libxml_use_internal_errors(TRUE);
- $xml = simplexml_load_string($a_licensedata);
- $license = (new License());
- if ($xml !== FALSE) {
- $license->setCompany($xml->Company);
- $license->setAccountCount($xml->Accounts);
- $license->setComponent($xml->Component);
- $license->setExpiryDate($xml->ExpiryDate);
- $license->setIssueDate($xml->IssueDate);
- $license->setLevel($xml->Level);
- $license->setLicenseData($a_licensedata);
- $license->setLicenseString($xml->LicenseString);
- $license->setName($xml->Name);
- $license->setID($xml->ID);
- if (isset($xml->Host)) {
- $license->setHost($xml->Host);
- }
- if (isset($xml->SPLA)) {
- $license->setSPLA($xml->SPLA);
- }
- $license->setWhitelistedDomains(($xml->WhitelistedDomains ?? ''));
- if (!empty($xml->AddlGuestAccounts)) {
- $license->setAdditionalGuestAccounts((int) $xml->AddlGuestAccounts);
- }
- if (isset($xml->EnforceUserLimitForSPLA)) {
- $license->setEnforceUserLimitForSpla($xml->EnforceUserLimitForSPLA);
- }
- $license->setLockedVersion(($xml->LockedVersion ?? ''));
- }
- return $license;
- }
- private function checkHost($host, &$message)
- {
- if (strlen(trim($host)) == 0) {
- return NULL;
- }
- if ($host == '*') {
- return NULL;
- }
- $reqHostName = \CodeLathe\Core\Common\Utility\Utility::getHTTPHost();
- if ($reqHostName != '') {
- if ($reqHostName == '127.0.0.1' || $reqHostName == 'localhost') {
- return NULL;
- }
- if (filter_var($reqHostName, FILTER_VALIDATE_IP)) {
- return NULL;
- }
- if (substr($reqHostName, 0, 4) == 'www.') {
- $reqHostName = substr($reqHostName, 4);
- }
- $reqHostName = mb_strtolower($reqHostName);
- $host = mb_strtolower($host);
- $hostArray = explode(',', $host);
- foreach ($hostArray as $hostName) {
- if ($reqHostName == trim($hostName)) {
- return NULL;
- }
- }
- $this->logger->logError(\CodeLathe\Core\Common\FCLogger::getCode(array(\CodeLathe\Core\Common\FCLogger::UNAUTHORIZED_SITE_HOST)) . ' Unauthorized Site Host for access: ' . $reqHostName . ' Accepted Host(s): ' . $host);
- $message = 'License is invalid for Site Domain';
- }
- }
- private function checkLockedVersion(string $lockedVersion, string &$message): void
- {
- if (empty($lockedVersion)) {
- return;
- }
- $lockedVersionChecker = \CodeLathe\Application\ContainerFacade::get('CodeLathe\\Core\\Subsystem\\System\\License\\LockedVersionChecker');
- $isValidValueObj = $lockedVersionChecker->check(\CodeLathe\Core\Common\Utility\Utility::getCurrentFileCloudVersion(), $lockedVersion, \CodeLathe\Core\Common\Utility\Utility::getManifestFileContent(), $this->getManifestPublicKey());
- if (!$isValidValueObj->isValid()) {
- $message = $isValidValueObj->getErrorMsg();
- }
- }
- public function loadSPLALicenseFromXMLData($xmldata, &$message)
- {
- if ($xmldata == '') {
- return NULL;
- }
- $licensedata = $this->getExtensionData($xmldata);
- $signaturedata = $this->getSignatureData($xmldata);
- $signaturevalue = $this->getSignatureValue($signaturedata);
- $signatureindex = $this->getSignatureIndex($signaturedata);
- if (intval($signatureindex) === 0) {
- $message = 'Unsupported license file version';
- return NULL;
- }
- $public_key = $this->getPublicKey($signatureindex);
- $b64decodedSignature = base64_decode($signaturevalue);
- $ok = openssl_verify($licensedata, $b64decodedSignature, $public_key, OPENSSL_ALGO_SHA1);
- if ($ok == 1) {
- return $this->getLicense($licensedata);
- }
- $message = 'Invalid License File';
- return NULL;
- }
- private function getExtensionData($xmldata)
- {
- $findme1 = '<ExtensionData>';
- $findme2 = '</ExtensionData>';
- $pos1 = strpos($xmldata, $findme1);
- $pos2 = strpos($xmldata, $findme2) + 16;
- return rtrim(ltrim(substr($xmldata, $pos1, $pos2 - $pos1)));
- }
- public function getActiveUsers()
- {
- $kr = $this->keyRecordDataStore->getKeyRecord('fullguestusercountcache');
- if (!empty($kr)) {
- list($count, $timestamp) = explode(':', $kr->getValue());
- if (!empty($count) || !(!($timestamp || !is_numeric($count) || !is_numeric($timestamp)))) {
- $isvalid = time() < ($timestamp + 900);
- if ($isvalid) {
- return $count;
- }
- }
- }
- $count = $this->userDataStore->getLicensedUserCount();
- $this->keyRecordDataStore->addKeyRecordPair('fullguestusercountcache', $count . ':' . time());
- return $count;
- }
- private function addLicenseCheckToCache(bool $isvalid, string $message): void
- {
- $value = ($isvalid ? '1' : '0') . '#' . $message;
- \CodeLathe\Core\Common\RequestCache::add('licensevalid', $value);
- }
- public function doSPLALicenseUpdate($force = FALSE)
- {
- $xmldata = $this->settingsManager->getSetting('INSTALL_LICENSE', 'string', '');
- if ($xmldata == '') {
- $this->logger->logDebug('CRON: SPLA: License not installed, skipping');
- return NULL;
- }
- $license = $this->loadLicenseFromXMLData($xmldata, $message);
- if ($license == NULL) {
- $this->logger->logDebug('CRON: SPLA: Invalid License, skipping');
- return NULL;
- }
- if ($license->getSPLA() != '1') {
- $this->logger->logDebug('CRON: SPLA: Not a SPLA license, skipping');
- return NULL;
- }
- $keyrecord = $this->keyRecordDataStore->getKeyRecord('lastsplacheck');
- if (($keyrecord)) {
- $dateInfo = date_parse_from_format('Y-m-d H:i:s', $keyrecord->getValue());
- $lastRun = mktime($dateInfo['hour'], $dateInfo['minute'], $dateInfo['second'], $dateInfo['month'], $dateInfo['day'], $dateInfo['year']);
- $currentInfo = date('Y-m-d H:i:s');
- $currentRun = strtotime($currentInfo);
- $hours = round((double) $currentRun - $lastRun / 3600, 1);
- if ($hours < 6 && !$force) {
- $this->logger->logDebug('CRON: SPLA: License Check ' . $hours . ' hours ago, skipping');
- return NULL;
- }
- }
- $expDate = $this->getSPLALicenseExpiryDate();
- if ($expDate < time()) {
- $days = (double) time() - $expDate / 86400;
- }
- else {
- $days = (double) $expDate - time() / 86400;
- }
- $this->logger->logDebug('CRON: Calc SPLA Expiry Date=' . date(DATE_RFC2822, $expDate) . ' with days remaining= ' . $days);
- if ($days < 15 || $expDate < time()) {
- $this->splaReport();
- }
- else {
- $this->logger->logDebug('CRON: More than ' . $days . ' for SPLA expiry date of ' . date(DATE_RFC2822, $expDate) . ' check, Skipping');
- }
- $key1 = (new \CodeLathe\Core\Common\Utility\KeyRecord\KeyRecord());
- $key1->setKey('lastsplacheck');
- $key1->setValue(date('Y-m-d H:i:s'));
- $this->keyRecordDataStore->addKeyRecord($key1);
- }
- public function getSPLALicenseExpiryDate($xmldata = '', $extensiondata = '')
- {
- $result = $this->isLicenseValid($message);
- if ($result) {
- if ($xmldata == '') {
- $xmldata = $this->settingsManager->getSetting('INSTALL_LICENSE', 'string', '');
- }
- if ($xmldata == '') {
- return FALSE;
- }
- $licensedata = $this->getLicenseData($xmldata);
- $license = $this->getLicense($licensedata);
- if ($license->getSPLA() == '1') {
- $newdate = strtotime('+1 month', strtotime($license->getIssueDate()));
- $expirationdate = mktime(0, 0, 0, date('m', $newdate), 16, date('Y', $newdate));
- $finalexpirationdate = strtotime($license->getExpiryDate());
- if ($extensiondata == '') {
- $extensiondata = $this->settingsManager->getSetting('EXTENSION_LICENSE', 'string', '');
- }
- $extlicense = $this->loadSPLALicenseFromXMLData($extensiondata, $message);
- if ($extlicense != NULL) {
- $newdate = strtotime('+1 month', strtotime($extlicense->getIssueDate()));
- $extexpirationdate = mktime(0, 0, 0, date('m', $newdate), 16, date('Y', $newdate));
- if ($expirationdate < $extexpirationdate) {
- $expirationdate = $extexpirationdate;
- }
- if ($finalexpirationdate < $expirationdate) {
- $expirationdate = $finalexpirationdate;
- }
- }
- return $expirationdate;
- }
- return strtotime($license->getExpiryDate());
- }
- return time();
- }
- public function splaReport()
- {
- $this->logger->logDebug('Doing SPLA Check...');
- $this->keyRecordDataStore->deleteKeyRecord('splacheckerror');
- if (!extension_loaded('curl')) {
- $key1 = (new \CodeLathe\Core\Common\Utility\KeyRecord\KeyRecord());
- $key1->setKey('splacheckerror');
- $key1->setValue('Activation Error: PHP CURL Not Found');
- $this->keyRecordDataStore->addKeyRecord($key1);
- return NULL;
- }
- $url = 'https://portal.getfilecloud.com/admin/';
- $rootDir = TONIDO_CLOUD_ROOT_DIR;
- $certfile = $rootDir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'cacert.pem';
- $options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HEADER => FALSE, CURLOPT_FOLLOWLOCATION => FALSE, CURLOPT_ENCODING => '', CURLOPT_USERAGENT => 'fcserveragent', CURLOPT_AUTOREFERER => TRUE, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_CAINFO => $certfile, CURLOPT_SSL_VERIFYHOST => 0);
- $count = $this->getActiveUsers();
- $serverurl = $this->settingsManager->getServerUrl(FALSE);
- $license = $this->getLicenseInfo();
- $params = 'op=splareport&licenseemailid=' . rawurlencode($license->getID()) . '&licensename=' . rawurlencode($license->getName()) . '&licensecompany=' . rawurlencode($license->getCompany()) . '&issuedate=' . rawurlencode($license->getIssueDate()) . '&expirydate=' . rawurlencode($license->getExpiryDate()) . '&sitehost=' . rawurlencode(gethostname()) . '&serverurl=' . rawurlencode($serverurl) . '&count=' . rawurlencode($count);
- $this->logger->logDebug($params);
- $ch = curl_init($url);
- curl_setopt_array($ch, $options);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
- $settingsMgr = \CodeLathe\Core\Infrastructure\Settings\SettingsManager::getInstance();
- $proxyurl = $settingsMgr->getProxyUrl();
- $proxyauth = $settingsMgr->getProxyAuth();
- if ($proxyurl != '') {
- curl_setopt($ch, CURLOPT_PROXY, $proxyurl);
- if ($proxyauth != '') {
- curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
- }
- }
- $content = curl_exec($ch);
- $errmsg = curl_error($ch);
- curl_close($ch);
- if ($content !== FALSE) {
- $message = '';
- $extlicense = $this->loadSPLALicenseFromXMLData($content, $message);
- if ($extlicense != NULL) {
- $key1 = (new \CodeLathe\Core\Common\Utility\KeyRecord\KeyRecord());
- $key1->setKey('splalastreportedcount');
- $key1->setValue($count);
- $this->keyRecordDataStore->addKeyRecord($key1);
- $key1 = (new \CodeLathe\Core\Common\Utility\KeyRecord\KeyRecord());
- $key1->setKey('splalastreporteddate');
- $key1->setValue(date('Y-m-d H:i:s'));
- $this->keyRecordDataStore->addKeyRecord($key1);
- $this->settingsManager->setSetting('EXTENSION_LICENSE', $content);
- }
- else {
- libxml_use_internal_errors(TRUE);
- $xml = simplexml_load_string($content);
- if ($xml !== FALSE) {
- $result = (int) $xml->command->result;
- $message = (string) $xml->command->message;
- $this->logger->logError(\CodeLathe\Core\Common\FCLogger::getCode(array(\CodeLathe\Core\Common\FCLogger::UNABLE_TO_GET_SPLA_INFO, \CodeLathe\Core\Common\FCLogger::XML_FAILED_FOR_URL)) . ' SPLA Extension, Server Failure. Result: ' . $result . ' Message: ' . $message);
- $key1 = (new \CodeLathe\Core\Common\Utility\KeyRecord\KeyRecord());
- $key1->setKey('splacheckerror');
- $key1->setValue('Server Activation Error');
- if ($result == 2) {
- if ($message == 'Invalid License Expiry Date') {
- $key1->setValue('License Expiration Date is Invalid. Please update your license');
- }
- else {
- $key1->setValue('SPLA Disabled');
- }
- }
- $this->keyRecordDataStore->addKeyRecord($key1);
- }
- else {
- $this->logger->logError(\CodeLathe\Core\Common\FCLogger::getCode(array(\CodeLathe\Core\Common\FCLogger::INVALID_SPLA_INFO, \CodeLathe\Core\Common\FCLogger::XML_FAILED_FOR_URL)) . ' SPLA Extension, Server Bad Data Error: ' . $content);
- $key1 = (new \CodeLathe\Core\Common\Utility\KeyRecord\KeyRecord());
- $key1->setKey('splacheckerror');
- $key1->setValue('Activation Response Error');
- $this->keyRecordDataStore->addKeyRecord($key1);
- }
- }
- }
- else {
- $key1 = (new \CodeLathe\Core\Common\Utility\KeyRecord\KeyRecord());
- $key1->setKey('splacheckerror');
- $key1->setValue('Activation Network Error');
- $this->keyRecordDataStore->addKeyRecord($key1);
- $this->logger->logDebug('SPLA Extension, Network Error, CURL said: ' . $errmsg);
- }
- $this->logger->logDebug('SPLA Check Complete...');
- }
- public function getLicenseInfo()
- {
- $xmldata = $this->settingsManager->
- /*This is a partially decoded file.*/
- ?>
Add Comment
Please, Sign In to add comment