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/rest/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/rest/lib/log.php
<?php
namespace Bitrix\Rest;

use Bitrix\Main;
use Bitrix\Main\Request;

/**
 * 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 = [])
 * @method static EO_Log_Result getById($id)
 * @method static EO_Log_Result getList(array $parameters = [])
 * @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,
			),
			'EVENT_ID' => array(
				'data_type' => 'integer',
			),
			'MESSAGE' => array(
				'data_type' => 'text',
			),
		);
	}

	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();";
	}

	public static function filterResponseData(&$data): void
	{
		//filter non-searizable objects
		if (is_object($data) && !method_exists($data, '__serialize'))
		{
			$data = '';
		}
		else if (is_array($data))
		{
			foreach ($data as &$oneData)
			{
				static::filterResponseData($oneData);
			}
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit