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/settings.php
<?php
/**
 *    Settings
 *
 * @mail support@s-production.online
 * @link s-production.online
 */

namespace SProduction\Datasync;

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

class Settings
{
    const MODULE_ID = 'sproduction.datasync';
	const MEMORY_LIMIT = 104857600; // 100 Mb
	const EVENTS_MODE_KEY = 'events_mode';
	const EVENTS_MODE_VAL_ENABLED = '';
	const EVENTS_MODE_VAL_BY_USER = 'by_user';
	const EVENTS_MODE_VAL_DISABLED = 'disabled';
	const IBLOCK_SYNC_EXCLUDES = 'sync_excludes';
	public const FLD_IBLOCKS_SYNC_STEP_TIME = 'iblocks_sync_step_time';

	public static function get($name, $serialized=false) {
		$value = false;
		if ($name) {
			$value = Option::get(self::MODULE_ID, $name);
		}
		if ($serialized && $value) {
			$value = unserialize($value);
		}
		return $value;
	}

	public static function hasRecord($name) {
		$value = false;
		if ($name) {
			$value = (Option::getRealValue(self::MODULE_ID, $name) === NULL) ? false : true;
		}
		return $value;
	}

	public static function save($name, $value, $serialized=false) {
		$result = true;
		if ($serialized) {
			$value = serialize($value);
		}
		Option::set(self::MODULE_ID, $name, $value);
		return $result;
	}

	/**
	 * PHP script memory limit in bytes (with reserve)
	 */
	public static function getScriptMemoryLimit() {
		$memory_limit = ini_get('memory_limit');
		if ($memory_limit) {
			if (preg_match('/^(\d+)(.)$/', $memory_limit, $matches)) {
				if ($matches[2] == 'M') {
					$memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
				} else if ($matches[2] == 'K') {
					$memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
				}
			}
			// Reserve 20 MB
			if ($memory_limit > 41943040) {
				$memory_limit -= 20971520;
			}
		}
		else {
			$memory_limit = self::MEMORY_LIMIT;
		}
		return $memory_limit;
	}

	public static function isAllowEventProcess($user_id) {
		$result = false;
		$user_id = intval($user_id);
		// If not excluded
		if (!in_array($user_id, self::getSyncExcludes())) {
			if (self::get(self::EVENTS_MODE_KEY) == self::EVENTS_MODE_VAL_ENABLED) {
				$result = true;
			} elseif (self::get(self::EVENTS_MODE_KEY) == self::EVENTS_MODE_VAL_BY_USER) {
				if ($user_id) {
					$result = true;
				}
			}
		}
		return $result;
	}

	public static function getSyncExcludes() {
		$list = explode(',', self::get(self::IBLOCK_SYNC_EXCLUDES));
		$list = array_map('intval', array_map('trim', $list));
		return $list;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit