%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.145.105.122
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/translate/lib/controller/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/translate/lib/controller/stepper.php
<?php
namespace Bitrix\Translate\Controller;

use Bitrix\Main;
use Bitrix\Translate;

/**
 * Stepper
 *
 * @implements Translate\Controller\ITimeLimit
 */
trait Stepper
{
	/** @var string */
	protected $processToken;

	/** @var boolean */
	protected $isNewProcess = true;

	/** @var boolean */
	protected $isProcessCompleted = false;

	/** @var int */
	protected $processedItems = 0;

	/** @var int */
	protected $totalItems = 0;

	/** @var Translate\Controller\Timer */
	protected $timer;


	/**
	 * Initializes controller stepper and checks necessary parameters.
	 * @see \Bitrix\Main\Engine\Action::onBeforeRun
	 *
	 * @return bool
	 */
	protected function onBeforeRun()
	{
		if ($this instanceof IProcessParameters)
		{
			$this->keepField(array(
				'processedItems',
				'totalItems',
			));

			/** @var Main\Engine\Action $this */
			$this->processToken = $this->getController()->getRequest()->get('PROCESS_TOKEN');

			$progressData = $this->getProgressParameters();
			if (count($progressData) > 0)
			{
				$this->isNewProcess = (empty($progressData['processToken']) || $progressData['processToken'] !== $this->processToken);
				if (!$this->isNewProcess)
				{
					// restore state
					$this->restoreProgressParameters();
				}
			}

			$this->keepField('processToken');
		}

		if($this->processToken === '')
		{
			$this->addError(new Main\Error('Process token is not specified.'));
		}

		return count($this->getErrors()) === 0;
	}

	/**
	 * Performs action.
	 *
	 * @param \Closure|callable|string $action Action to be executed.
	 * @param array $params Parameters.
	 *
	 * @return array|Main\Engine\Response\AjaxJson
	 */
	protected function performStep($action, array $params = array())
	{
		if ($this->isNewProcess)
		{
			$this->processedItems = 0;
			$this->totalItems = 0;

			if ($this instanceof IProcessParameters)
			{
				$this->saveProgressParameters();
			}
		}

		$this->startTimer();

		if ($action instanceof \Closure)
		{
			$result = $action->call($this, $params);
		}
		elseif (is_callable($action))
		{
			$result = call_user_func($action, $params);
		}
		elseif (is_string($action) && is_callable(array($this, $action)))
		{
			$result = call_user_func(array($this, $action), $params);
		}
		else
		{
			$this->addError(new Main\Error('Wrong action parameter!'));
		}

		if ($this->hasErrors())
		{
			$result['STATUS'] = Translate\Controller\STATUS_COMPLETED;
		}
		elseif ($this->hasProcessCompleted())
		{
			$result['STATUS'] = Translate\Controller\STATUS_COMPLETED;
		}
		else
		{
			$result['STATUS'] = Translate\Controller\STATUS_PROGRESS;
		}

		if ($this instanceof IProcessParameters)
		{
			// Save progress
			$this->saveProgressParameters();
		}

		return $result;
	}

	/**
	 * Switch accomplishment flag of the process.
	 *
	 * @param boolean $flag Accomplishment flag value.
	 *
	 * @return void
	 */
	public function declareAccomplishment($flag = true)
	{
		$this->isProcessCompleted = $flag;
	}

	/**
	 * Tells true if process has completed.
	 *
	 * @return boolean
	 */
	public function hasProcessCompleted()
	{
		return $this->isProcessCompleted;
	}


	/**
	 * Getting array of errors.
	 * @return boolean
	 */
	public function hasErrors()
	{
		/** @property \Bitrix\Main\ErrorCollection $errorCollection */
		if ($this->errorCollection instanceof Main\ErrorCollection)
		{
			return $this->errorCollection->isEmpty() !== true;
		}

		return false;
	}

	/**
	 * Gets timer.
	 *
	 * @return Translate\Controller\Timer
	 */
	public function instanceTimer()
	{
		if (!($this->timer instanceof Translate\Controller\Timer))
		{
			$this->timer = new Translate\Controller\Timer();
		}

		return $this->timer;
	}

	/**
	 * Sets start up time.
	 *
	 * @see Translate\Controller\ITimeLimit
	 *
	 * @return void
	 */
	public function startTimer()
	{
		$this->instanceTimer()->startTimer((int)START_EXEC_TIME);
	}

	/**
	 * Tells true if time limit reached.
	 *
	 * @see Translate\Controller\ITimeLimit
	 *
	 * @return boolean
	 */
	public function hasTimeLimitReached()
	{
		return $this->instanceTimer()->hasTimeLimitReached();
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit