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/components/bitrix/mail.client.config.dirs/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/components/bitrix/mail.client.config.dirs/class.php
<?php

if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true)
{
	die();
}

use Bitrix\Mail;
use Bitrix\Mail\Helper\MailboxDirectoryHelper;
use Bitrix\Mail\MailboxDirectory;
use Bitrix\Main;
use Bitrix\Main\Context;
use Bitrix\Main\Engine\Contract\Controllerable;
use Bitrix\Main\Error;
use Bitrix\Main\Errorable;
use Bitrix\Main\ErrorCollection;
use Bitrix\Main\Loader;
use Bitrix\Main\Localization\Loc;

Loc::loadMessages(__DIR__ . '/../mail.client/class.php');

Loader::includeModule('mail');

class CMailClientConfigDirsComponent extends CBitrixComponent implements Controllerable, Errorable
{
	/** @var  ErrorCollection */
	protected $errorCollection;

	/**
	 * @inheritDoc
	 */
	public function configureActions()
	{
		$this->errorCollection = new Main\ErrorCollection();

		return [];
	}

	public function executeComponent()
	{
		global $USER, $APPLICATION;

		$APPLICATION->setTitle(Loc::getMessage('MAIL_CLIENT_CONFIG_DIRS_TITLE'));

		if (!is_object($USER) || !$USER->isAuthorized())
		{
			$APPLICATION->authForm('');
			return;
		}

		$request = Context::getCurrent()->getRequest();
		$mailboxId = (int)$request->getQuery('mailboxId');

		if (!$mailboxId)
		{
			showError(Loc::getMessage('MAIL_CLIENT_ELEMENT_NOT_FOUND'));
			return;
		}

		$mailboxHelper = Mail\Helper\Mailbox::createInstance($mailboxId, false);
		if (!$mailboxHelper)
		{
			LocalRedirect('/mail');
		}

		$mailboxHelper->cacheDirs();

		$mailboxDirsHelper = $mailboxHelper->getDirsHelper();

		$this->arResult['DIRS'] = $mailboxDirsHelper->buildTreeDirs();
		$this->arResult['MAX_LEVEL'] = 1;
		$this->arResult['OUTCOME'] = $mailboxDirsHelper->getOutcome();
		$this->arResult['TRASH'] = $mailboxDirsHelper->getTrash();
		$this->arResult['SPAM'] = $mailboxDirsHelper->getSpam();
		$this->arResult['MAILBOX_ID'] = $mailboxId;
		$this->arResult['MAX_LEVEL_DIRS'] = MailboxDirectoryHelper::getMaxLevelDirs();

		ob_start();
		$this->includeComponentTemplate('dirs');
		$this->arResult['DIRS_TREE'] = ob_get_clean();

		$this->includeComponentTemplate();
	}

	public function saveAction()
	{
		$request = Context::getCurrent()->getRequest();

		$mailboxId = (int)$request->getPost("mailboxId");
		$dirs = (array)$request->getPost("dirs");
		$dirsTypes = (array)$request->getPost("dirsTypes");

		if (!$mailboxId || (empty($dirs) && empty($dirsTypes)))
		{
			$this->errorCollection[] = new Error(Loc::getMessage('MAIL_CLIENT_FORM_ERROR'));
			return false;
		}

		global $USER;

		if (!Mail\Helper\Message::isMailboxOwner($mailboxId, $USER->GetID()))
		{
			$this->errorCollection[] = new Error('access denied');
			return false;
		}

		$mailboxDirsHelper = new MailboxDirectoryHelper($mailboxId);
		$mailboxDirsHelper->toggleSyncDirs($dirs);
		$mailboxDirsHelper->saveDirsTypes($dirsTypes);

		return [];
	}

	public function levelAction()
	{
		$request = Context::getCurrent()->getRequest();

		$mailboxId = (int)$request->getPost("mailboxId");
		$dir = (array)$request->getPost("dir");

		if (!$mailboxId || empty($dir) || empty($dir['dirMd5']))
		{
			$this->errorCollection[] = new Error(Loc::getMessage('MAIL_CLIENT_FORM_ERROR'));

			return false;
		}

		global $USER;

		if (!Mail\Helper\Message::isMailboxOwner($mailboxId, $USER->GetID()))
		{
			$this->errorCollection[] = new Error('access denied');
			return false;
		}

		$parent = MailboxDirectory::fetchOneByMailboxIdAndHash($mailboxId, $dir['dirMd5']);

		if ($parent == null)
		{
			$this->errorCollection[] = new Error(Loc::getMessage('MAIL_CLIENT_MAILBOX_NOT_FOUND'));

			return false;
		}

		if ($parent->getLevel() >= MailboxDirectoryHelper::getMaxLevelDirs())
		{
			$this->errorCollection[] = new Error(Loc::getMessage('MAIL_CLIENT_CONFIG_DIRS_MAX_LEVEL_DIRS'));

			return false;
		}

		$mailboxDirsHelper = new MailboxDirectoryHelper($mailboxId);

		if (!$mailboxDirsHelper->syncChildren($parent))
		{
			$this->errorCollection = $mailboxDirsHelper->getErrors();

			return false;
		}

		$dirs = $mailboxDirsHelper->getAllLevelByParentId($parent);
		$mailboxDirsHelper->setDirs($dirs);

		$this->arResult['DIRS'] = $mailboxDirsHelper->buildTreeDirs();
		$this->arResult['MAX_LEVEL'] = 1;

		ob_start();
		$this->includeComponentTemplate('dirs');

		return ['dirs' => $this->arResult['DIRS'], 'html' => ob_get_clean()];
	}

	/**
	 * Getting array of errors.
	 * @return Error[]
	 */
	public function getErrors()
	{
		return $this->errorCollection->toArray();
	}

	/**
	 * Getting once error with the necessary code.
	 * @param string $code Code of error.
	 * @return Error
	 */
	public function getErrorByCode($code)
	{
		return $this->errorCollection->getErrorByCode($code);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit