%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.135.212.195
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/rest/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/rest/lib//log.php
<?php
namespace Bitrix\Rest;

use Bitrix\Main;

/**
 * Class LogTable
 *
 * Fields:
 * <ul>
 * <li> ID int mandatory
 * <li> TIMESTAMP_X datetime mandatory default 'CURRENT_TIMESTAMP'
 * <li> CLIENT_ID string(45) optional
 * <li> PASSWORD_ID int optional
 * <li> SCOPE string(50) optional
 * <li> METHOD string(255) optional
 * <li> REQUEST_URI string(255) optional
 * <li> REQUEST_DATA string optional
 * <li> RESPONSE_DATA string optional
 * </ul>
 *
 * @package Bitrix\Rest
 *
 * DO NOT WRITE ANYTHING BELOW THIS
 *
 * <<< ORMENTITYANNOTATION
 * @method static EO_Log_Query query()
 * @method static EO_Log_Result getByPrimary($primary, array $parameters = array())
 * @method static EO_Log_Result getById($id)
 * @method static EO_Log_Result getList(array $parameters = array())
 * @method static EO_Log_Entity getEntity()
 * @method static \Bitrix\Rest\EO_Log createObject($setDefaultValues = true)
 * @method static \Bitrix\Rest\EO_Log_Collection createCollection()
 * @method static \Bitrix\Rest\EO_Log wakeUpObject($row)
 * @method static \Bitrix\Rest\EO_Log_Collection wakeUpCollection($rows)
 */
class LogTable extends Main\Entity\DataManager
{
	/**
	 * Returns DB table name for entity.
	 *
	 * @return string
	 */
	public static function getTableName()
	{
		return 'b_rest_log';
	}

	/**
	 * Returns entity map definition.
	 *
	 * @return array
	 */
	public static function getMap()
	{
		return array(
			'ID' => array(
				'data_type' => 'integer',
				'primary' => true,
				'autocomplete' => true,
			),
			'TIMESTAMP_X' => array(
				'data_type' => 'datetime',
			),
			'CLIENT_ID' => array(
				'data_type' => 'string',
			),
			'PASSWORD_ID' => array(
				'data_type' => 'integer',
			),
			'SCOPE' => array(
				'data_type' => 'string',
			),
			'METHOD' => array(
				'data_type' => 'string',
			),
			'REQUEST_METHOD' => array(
				'data_type' => 'string',
			),
			'REQUEST_URI' => array(
				'data_type' => 'string',
			),
			'REQUEST_AUTH' => array(
				'data_type' => 'text',
				'serialized' => true,
			),
			'REQUEST_DATA' => array(
				'data_type' => 'text',
				'serialized' => true,
			),
			'RESPONSE_STATUS' => array(
				'data_type' => 'string',
			),
			'RESPONSE_DATA' => array(
				'data_type' => 'text',
				'serialized' => true,
			),
		);
	}

	/**
	 * Checks if logging is applicable to the data and logs it if this is the case.
	 *
	 * @param \CRestServer $server REST call context.
	 * @param string $data Response content.
	 *
	 * @return void
	 *
	 * @see \Bitrix\Rest\Log::checkEntry
	 * @see \Bitrix\Rest\Log::addEntry
	 */
	public static function log(\CRestServer $server, $data)
	{
		if(static::checkEntry($server))
		{
			static::addEntry($server, $data);
		}
	}

	/**
	 * Checks if logging is applicable to the rest call.
	 *
	 * @param \CRestServer $server REST call context.
	 *
	 * @return void
	 */
	public static function checkEntry(\CRestServer $server)
	{
		global $USER;

		$logEndTime = intval(\Bitrix\Main\Config\Option::get('rest', 'log_end_time', 0));
		if ($logEndTime < time())
		{
			return false;
		}

		$logOptions = @unserialize(
			\Bitrix\Main\Config\Option::get('rest', 'log_filters', ''),
			[
				'allowed_classes' => false
			]
		);
		if (!is_array($logOptions))
		{
			$logOptions = array();
		}

		if(
			isset($logOptions['client_id']) && $server->getClientId() !== $logOptions['client_id']
			|| isset($logOptions['password_id']) && $server->getPasswordId() !== $logOptions['password_id']
			|| isset($logOptions['scope']) && $server->getScope() !== $logOptions['scope']
			|| isset($logOptions['method']) && $server->getMethod() !== $logOptions['method']
			|| isset($logOptions['user_id']) && $USER->getId() !== $logOptions['user_id']
		)
		{
			return false;
		}

		return true;
	}

	/**
	 * Adds a log entry.
	 *
	 * @param \CRestServer $server REST call context.
	 * @param string $data Response content.
	 *
	 * @return void
	 */
	public static function addEntry(\CRestServer $server, $data)
	{
		$request = Main\Context::getCurrent()->getRequest();

		static::add(array(
			'CLIENT_ID' => $server->getClientId(),
			'PASSWORD_ID' => $server->getPasswordId(),
			'SCOPE' => $server->getScope(),
			'METHOD' => $server->getMethod(),
			'REQUEST_METHOD' => $request->getRequestMethod(),
			'REQUEST_URI' => $request->getRequestUri(),
			'REQUEST_AUTH' => $server->getAuth(),
			'REQUEST_DATA' => $server->getQuery(),
			'RESPONSE_STATUS' => \CHTTP::getLastStatus(),
			'RESPONSE_DATA' => $data,
		));
	}

	public static function getCountAll()
	{
		$entity = static::getEntity();
		$sqlTableName = static::getTableName();

		$sql = "SELECT count(1) CNT FROM {$sqlTableName}";
		$query = $entity->getConnection()->query($sql);
		return $query->fetch()["CNT"];
	}

	public static function clearAll()
	{
		$entity = static::getEntity();
		$sqlTableName = static::getTableName();

		$sql = "TRUNCATE TABLE {$sqlTableName}";
		$entity->getConnection()->queryExecute($sql);
	}

	public static function cleanUpAgent()
	{
		$entity = static::getEntity();
		$sqlTableName = static::getTableName();
		$connection = $entity->getConnection();

		$lastIdQuery = $connection->query("
			SELECT max(ID) MID
			from {$sqlTableName}
		");
		$lastId = $lastIdQuery->fetch();
		if ($lastId && $lastId['MID'])
		{
			$date = new Main\Type\DateTime();
			$date->add("-7D");

			$lastTimeQuery = $connection->query("
				SELECT TIMESTAMP_X
				from {$sqlTableName}
				WHERE ID = $lastId[MID]
			");
			$lastTime = $lastTimeQuery->fetch();
			if ($lastTime && $lastTime['TIMESTAMP_X'] < $date)
			{
				static::clearAll();
			}
		}

		return "\\Bitrix\\Rest\\LogTable::cleanUpAgent();";
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit