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/acrit.cleanmaster/classes/general/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/acrit.cleanmaster/classes/general/ccleanmain.php
<?
IncludeModuleLangFile(__FILE__);
IncludeModuleLangFile(__DIR__ . '/../../steps.php');

if (! class_exists('CUpdateClientPartner')) {
	require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/update_client_partner.php";
}

/**
 * Class CCleanMain для выполнения общих действий (а не главного модуля ;)
 */
class CCleanMain extends TCleanMasterFunctions
{
	public const MODULE_ID = 'acrit.cleanmaster';

	public static function includeAllNeedModules()
	{
		CModule::IncludeModule("iblock");
		CModule::IncludeModule("form");
		CModule::IncludeModule("forum");
		CModule::IncludeModule("subscribe");
		CModule::IncludeModule("statistic");
		CModule::IncludeModule("sale");
		CModule::IncludeModule("acrit.core");
		//CModule::IncludeModule(self::MODULE_ID);
	}

	/**
	 * Шаги с диагностикой
	 * @return array
	 */
	public static function getMainSteps()
	{
		$actionList = [
			1 => GetMessage("CLEANMASTER_ACTION_1"),
			2 => GetMessage("CLEANMASTER_ACTION_2"),
			3 => GetMessage("CLEANMASTER_ACTION_3"),
			4 => GetMessage("CLEANMASTER_ACTION_4"),
			5 => GetMessage("CLEANMASTER_ACTION_5"),
			6 => GetMessage("CLEANMASTER_ACTION_6"),
			7 => GetMessage("CLEANMASTER_ACTION_7"),
			8 => GetMessage("CLEANMASTER_ACTION_8"),
			9 => GetMessage("CLEANMASTER_ACTION_9"),
			10 => GetMessage("CLEANMASTER_ACTION_10"),
			11 => GetMessage("CLEANMASTER_ACTION_11"),
			12 => GetMessage("CLEANMASTER_ACTION_12"),
			13 => GetMessage("CLEANMASTER_ACTION_13"),
			14 => GetMessage("CLEANMASTER_ACTION_14"),
			16 => GetMessage("CLEANMASTER_ACTION_16"),
			17 => GetMessage("CLEANMASTER_ACTION_17"),
			20 => GetMessage("CLEANMASTER_ACTION_20"),
			21 => GetMessage("CLEANMASTER_ACTION_21"),
			22 => GetMessage("CLEANMASTER_ACTION_22"),
			23 => GetMessage("CLEANMASTER_ACTION_23"),
			28 => GetMessage("CLEANMASTER_ACTION_28"),
			29 => GetMessage("CLEANMASTER_ACTION_29"),
			34 => GetMessage("CLEANMASTER_ACTION_34"),
			35 => GetMessage("CLEANMASTER_ACTION_35"),
			36 => GetMessage("CLEANMASTER_ACTION_36"),
		];
		return $actionList;
	}

	public static function getToolsSteps()
	{
		$actionList = [
			24 => GetMessage("CLEANMASTER_ACTION_24"),
			25 => GetMessage("CLEANMASTER_ACTION_25"),
			26 => GetMessage("CLEANMASTER_ACTION_26"),
			27 => GetMessage("CLEANMASTER_ACTION_27"),
			30 => GetMessage("CLEANMASTER_ACTION_30"),
			31 => GetMessage("CLEANMASTER_ACTION_31"),
			32 => GetMessage("CLEANMASTER_ACTION_32"),
			33 => GetMessage("CLEANMASTER_ACTION_33"),
		];
		return $actionList;
	}

	/**
	 * @param int $stepId
	 * @param bool $isTool
	 *
	 * @return array{ url : string, moreUrl : string }
	 */
	public static function getStepUrls(int $stepId, bool $isTool = false): array
	{
		if (! $isTool) {
			$urlPref = "/bitrix/admin/settings.php?clear_menu=Y&lang=ru&mid=acrit.cleanmaster&mid_menu=1";
		} else {
			$urlPref = "/bitrix/admin/settings.php?dop_tools=Y&lang=ru&mid=acrit.cleanmaster&mid_menu=1";
		}
		$url = $urlPref . '&show_steps=' . $stepId . '&action_start=Y';
		$moreUrl = $urlPref . '&show_steps=SELECT' . $stepId . '&action_start=Y';

		return [
			'url'       => $url,
			'moreUrl'   => $moreUrl
		];
	}

	public static function getDiagnosticStepCodesByStep($step)
	{
		$step = (int)$step;
		if ($step <= 0) {
			return false;
		}

		$diagSteps = [
			1 => ['site'],
			2 => ['templates'],
			3 => ['ibelement'],
			4 => ['mailtemplate'],
			5 => ['file_index', 'upload'],
			6 => ['user'],
			7 => ['orderstat'],
			8 => ['cache'],
			9 => ['attackevent'],
			10 => ['webhist'],
			11 => ['dropbasket'],
			12 => ['unconfirmed'],
			13 => [],
			14 => ['webform'],
			16 => ['lang'],
			17 => ['module'],
			20 => ['component'],
			21 => [],
			22 => ['perfmon'],
			23 => ['saleviewed'],
			24 => [],
			25 => [],
			26 => [],
		];
		for ($i = 33; $i < 50; $i++) {
			$className = 'Acrit\Cleanmaster\Steps\Step'.$i;
			if (! class_exists($className)) {
				continue;
			}
			/** @var Acrit\Cleanmaster\Steps\BaseStep $className */
			if (method_exists($className, 'getDiagnosticStepsCodes')) {
				$diagSteps[ $className::getId() ] = $className::getDiagnosticStepsCodes();
			}
		}
		return $diagSteps[$step];
	}

	/**
	 * Конвертирует элементы и ключи массива из UTF8 в cp1251
	 *
	 * @param      $array
	 * @param bool $orig
	 *
	 * @return mixed {array}
	 * @internal param $ {array} $array Сам массив. $array Сам массив.
	 * @internal param $ {bool} $orig=false Возврощать ли оригинальные элементы с '~'. $orig=false Возвращать ли оригинальные элементы с '~'.
	 */
	public static function convArray_r($array, $orig = false)
	{
		$res = [];
		foreach ($array as $k => $v) {
			if (is_array($v)) {
				$o = ($orig) ? true : false;
				$res[$k] = self::convArray_r($v, $o);
			} else {
				$res[$k] = mb_convert_encoding($v, 'WINDOWS-1251', 'UTF-8');
				if ($orig) {
					$res['~' . $k] = $v;
				}
			}
		}
		return $res;
	}

	public static function ArrayValidate($arData)
	{
		$result = false;
		if (isset($arData) && is_array($arData) && !empty($arData)) {
			$result = true;
		}
		return $result;
	}

	private static function GetMarketModuleList()
	{
		$arRequestedModules = CUpdateClientPartner::GetRequestedModules("");
		$arUpdateList = CUpdateClientPartner::GetUpdatesList(
			$errorMessage,
			LANGUAGE_ID,
			"N",
			$arRequestedModules,
			[
				"fullmoduleinfo" => "Y"
			]
		);
		return $arUpdateList;
	}

	public static function GetModuleUpdatesInfo()
	{
		$bHasUpdates = false;

		$arModuleList = self::GetMarketModuleList();
		if (self::ArrayValidate($arModuleList["MODULE"])) {
			foreach ($arModuleList["MODULE"] as $arModule) {
				if ($arModule["@"]["ID"] != self::MODULE_ID) {
					continue;
				}
				if (self::ArrayValidate($arModule["#"]) && self::ArrayValidate($arModule["#"]["VERSION"])) {
					$bHasUpdates = true;
				}
			}
		}
		return $bHasUpdates;
	}

	/**
	 * Check module updates
	 *
	 * @param string    $strModuleID
	 * @param           $intDateTo
	 * @param bool      $sessionCache = false
	 *
	 * @return array
	 */
	public static function checkModuleUpdates($strModuleID, &$intDateTo, $sessionCache = true)
	{
		$arAvailableUpdates = [];
		if (!class_exists('CUpdateClientPartner')) {
			return $arAvailableUpdates;
		}

		$cacheTime = 3600 * 3;
		// session cache
		$cacheKey = 'acrit.cleanmaster.arUpdateFullList';

		// D7
		$cache = Bitrix\Main\Data\Cache::createInstance();
		if ($cache->initCache($cacheTime, $cacheKey, 'php/acrit_updates')) {
			$arAvailableUpdates = $cache->getVars();
		} elseif ($cache->startDataCache()) {
			$arAvailableUpdates = [];

			$arUpdateList = CUpdateClientPartner::GetUpdatesList($errorMessage, LANGUAGE_ID, 'Y', [], ['fullmoduleinfo' => 'Y']);

			if (is_array($arUpdateList) && is_array($arUpdateList['MODULE'])) {
				foreach ($arUpdateList['MODULE'] as $arModuleData) {
					if ($arModuleData['@']['ID'] == $strModuleID) {
						if (preg_match('#^(\d{1,2})\.(\d{1,2})\.(\d{4})$#', $arModuleData['@']['DATE_TO'], $arMatch)) {
							$intDateTo = mktime(23, 59, 59, $arMatch[2], $arMatch[1], $arMatch[3]);
						}
						if (isset($arModuleData['#']['VERSION']) && is_array($arModuleData['#']['VERSION'])) {
							foreach ($arModuleData['#']['VERSION'] as $arVersion) {
								$arAvailableUpdates[$arVersion['@']['ID']] = $arVersion['#']['DESCRIPTION'][0]['#'];
							}
						}
					}
				}
			}

			$cache->endDataCache($arAvailableUpdates);
		}

		return $arAvailableUpdates;
	}

	/**
	 * Show success
	 */
	public static function showSuccess($strMessage = null, $strDetails = null): string
	{
		ob_start();
		\CAdminMessage::ShowMessage([
			'MESSAGE' => $strMessage,
			'DETAILS' => $strDetails,
			'HTML' => true,
			'TYPE' => 'OK',
		]);
		return ob_get_clean();
	}

	/**
	 * Show note
	 */
	public static function showNote($strNote, $bCompact = false, $bCenter = false): void
	{
		$arClass = [];
		if ($bCompact) {
			$arClass[] = 'acrit-exp-note-compact';
		}
		if ($bCenter) {
			$arClass[] = 'acrit-exp-note-center';
		}
		print '<div class="' . implode(' ', $arClass) . '">';
		print BeginNote();
		print $strNote;
		print EndNote();
		print '</div>';
	}

	public function GetHttpHost()
	{
		$arHttpHost = explode( ":", $_SERVER["HTTP_HOST"] );
		return $arHttpHost[0];
	}

	/**
	 * @var array|\CApplicationException[]|\Exception[]
	 */
	protected static $ERRORS;

	public static function setLastError($error): void
	{
		self::$ERRORS[] = $error;
	}
	public static function getLastErrors(): string
	{
		$return = '';
		foreach (self::$ERRORS as $error) {
			if (method_exists($error, 'getMessage')) {
				$err = $error->getMessage();
			} else if (method_exists($error, 'GetString')) {
				$err = $error->GetString();
			} else {
				$err = serialize($error);
			}
			$return .= $err . PHP_EOL;
		}
		return $return;
	}

} // end class

Youez - 2016 - github.com/yon3zu
LinuXploit