403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sproduction.datasync/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sproduction.datasync/lib/checkstate.php
<?php
/**
 *    Check module state
 *
 * @mail support@s-production.online
 * @link s-production.online
 */

namespace SProduction\Datasync;

use Bitrix\Main,
    Bitrix\Main\DB\Exception,
	Bitrix\Main\Localization\Loc,
    Bitrix\Main\Config\Option;

class CheckState
{
    const MODULE_ID = 'sproduction.datasync';
	const SCOPES = ['crm', 'catalog'];

	public static function getErrors() {
		$list = [];
		if (self::isSyncActive()) {
			if (!self::checkConnection(true)) {
				$list[] = \SProdDatasync::formatError('CHECKSTATE_ERROR_CONN', Loc::getMessage("SP_DS_CHECKSTATE_ERROR_CONN"));
			}
			else {
				$resp = Rest::execute('scope');
				if (is_array($resp) && !in_array(self::SCOPES, $resp)) {
					$missing_scopes = array_diff(self::SCOPES, $resp);
					if (count($missing_scopes)) {
						$list[] = \SProdDatasync::formatError('CHECKSTATE_ERROR_SCOPE', Loc::getMessage("SP_DS_CHECKSTATE_ERROR_SCOPE", ['#SCOPES#' => implode(', ', $missing_scopes)]), Loc::getMessage("SP_DS_CHECKSTATE_ERROR_SCOPE_HINT"));
					}
				}
			}
		}
		return $list;
	}

	public static function getWarnings() {
		$list = [];
		// Demo-period
		$incl_res = \Bitrix\Main\Loader::includeSharewareModule(self::MODULE_ID);
		if ($incl_res == \Bitrix\Main\Loader::MODULE_DEMO) {
			$days = (int)\SProdDatasync::getDemoDaysLeft();
			$term_phrase = \SProdDatasync::declineWord($days, Loc::getMessage("SP_DS_WARN_MODULE_DEMO_DAYS_TERM1", ['#DAYS#' => $days]), Loc::getMessage("SP_DS_WARN_MODULE_DEMO_DAYS_TERM2", ['#DAYS#' => $days]), Loc::getMessage("SP_DS_WARN_MODULE_DEMO_DAYS_TERM3", ['#DAYS#' => $days]));
			$list[]['message'] = Loc::getMessage("SP_DS_WARN_MODULE_DEMO_DAYS", ['#TERM_PHRASE#' => $term_phrase]);
		}
		return $list;
	}


	/**
	 * Check system parameters
	 */
	public static function checkList() {
		$res = [
			'auth_file' => false,
//			'store_handler_file' => false,
			'crm_handler_file' => false,
			'app_info' => false,
			'auth_info' => false,
			'connect' => false,
			'store_events' => false,
			'crm_events' => false,
			'agents' => false,
			'profiles' => false,
			'crm_events_uncheck' => false,
		];
		// Site base directory
		$site_default = \SProdDatasync::getSiteDef();
		$abs_root_path = $_SERVER['DOCUMENT_ROOT'] . $site_default['DIR'];
		// Check auth file
		if (file_exists($abs_root_path . 'bitrix/sprod_dsync_auth.php')) {
			$res['auth_file'] = true;
		}
//		// Check handler files
//		if (file_exists($abs_root_path . 'bitrix/sprod_dsync_bgr_run.php')) {
//			$res['store_handler_file'] = true;
//		}
		if (file_exists($abs_root_path . 'bitrix/sprod_dsync_handler.php')) {
			$res['crm_handler_file'] = true;
		}
		// Availability of B24 application data
		if (Rest::getAppInfo()) {
			$res['app_info'] = true;
			// Availability of connection data
			if (Rest::getAuthInfo()) {
				$res['auth_info'] = true;
			}
		}
//		// Check agents
//		if (IblockProfilesAddSync::check()) {
//			$res['agents'] = true;
//		}
		// Has active profiles
		if (self::checkActiveProfiles()) {
			$res['profiles'] = true;
		}
		if ($res['app_info'] && $res['auth_info']) {
			// Availability of an order change handler
			if (StoreHandlers::check()) {
				$res['store_events'] = true;
			}
			// Relevance of data for connecting to B24
			$resp = Rest::execute('app.info', [], false, true, false);
			if ($resp && !$resp['error']) {
				$res['connect'] = true;
//				// Availability of a deal change handler
//				if (PortalHandlers::checkHandlers()) {
//					$res['crm_events'] = true;
//				}
//				if (Settings::get('direction') == 'ctos') {
//					$res['crm_events_uncheck'] = true;
//				}
			}
		}
		return $res;
	}

	/**
	 * Check active profiles
	 */
	public static function checkActiveProfiles() {
		$is_exist = false;
		$list = IblocksProfilesTable::getList([
			'filter' => ['active' => 'Y'],
			'select' => ['id'],
		]);
		if (count($list)) {
			$is_exist = true;
		}
		return $is_exist;
	}

	public static function checkConnection($conn_test=false) {
		$res = false;
		if (Rest::getAppInfo() && Rest::getAuthInfo()) {
			$conn_test_res = true;
			if ($conn_test) {
				$conn_test_res = false;
				$app_info = Rest::execute('app.info');
				if ($app_info['ID']) {
					$conn_test_res = true;
				}
			}
			if ($conn_test_res) {
				$res = true;
			}
		}
		return $res;
	}

	public static function isSyncActive() {
		$result = false;
		if (Settings::get('active')) {
			$result = true;
		}
		return $result;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit