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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/sale/lib/fuser.php
<?php
/**
 * Bitrix Framework
 * @package bitrix
 * @subpackage sale
 * @copyright 2001-2012 Bitrix
 */
namespace Bitrix\Sale;

use Bitrix\Main;
use Bitrix\Sale\Internals;
use Bitrix\Main\Localization\Loc;

Loc::loadMessages(__FILE__);

class Fuser
{
	function __construct()
	{

	}

	/**
	 * Return fuserId.
	 *
	 * @param bool $skipCreate		Create, if not exist.
	 * @return int|null
	 */
	public static function getId($skipCreate = false)
	{
		global $USER;

		$id = null;

		static $fuserList = array();

		if ((isset($USER) && $USER instanceof \CUser) && $USER->IsAuthorized())
		{
			$currentUserId = (int)$USER->GetID();
			if (!isset($fuserList[$currentUserId]))
			{
				$fuserList[$currentUserId] = static::getIdByUserId($currentUserId);
			}
			$id = $fuserList[$currentUserId];
			unset($currentUserId);
		}

		if ((int)$id <= 0)
		{
			$id = \CSaleUser::getID($skipCreate);
		}
		static::updateSession($id);
		return $id;
	}

	/**
	 * Update session data
	 *
	 * @param int $id				FuserId.
	 * @return void
	 */
	protected static function updateSession($id)
	{
		\CSaleUser::updateSessionSaleUserID();
		if ((string)Main\Config\Option::get('sale', 'encode_fuser_id') != 'Y' && isset($_SESSION['SALE_USER_ID']))
			$_SESSION['SALE_USER_ID'] = (int)$_SESSION['SALE_USER_ID'];

		if (!isset($_SESSION['SALE_USER_ID']) || (string)$_SESSION['SALE_USER_ID'] == '' || $_SESSION['SALE_USER_ID'] === 0)
			$_SESSION['SALE_USER_ID'] = $id;
	}

	/**
	 * Return fuser code.
	 *
	 * @return int
	 */
	protected static function getCode()
	{
		return \CSaleUser::getFUserCode();
	}

	/**
	 * Return fuserId for user.
	 *
	 * @param int $userId			User Id.
	 * @return false|int
	 * @throws Main\ArgumentException
	 */
	public static function getIdByUserId($userId)
	{
		$res = Internals\FuserTable::getList(array(
			'filter' => array(
				'USER_ID' => $userId
			),
			'select' => array(
				'ID'
			),
			'order' => array('ID' => "DESC")
		));
		if ($fuserData = $res->fetch())
		{
			return (int)$fuserData['ID'];
		}
		else
		{
			/** @var Result $r */
			$r = static::createForUserId($userId);
			if ($r->isSuccess())
			{
				return $r->getId();
			}
		}

		return false;
	}

	/**
	 * Return user by fuserId.
	 *
	 * @param int $fuserId		Fuser Id.
	 * @return int
	 * @throws Main\ArgumentException
	 */
	public static function getUserIdById($fuserId)
	{
		$result = 0;

		$fuserId = (int)$fuserId;
		if ($fuserId <= 0)
			return $result;
		$row = Internals\FuserTable::getList(array(
			'select' => array('USER_ID'),
			'filter' => array('=ID' => $fuserId),
			'order' => array('ID' => "DESC")
		))->fetch();
		if (!empty($row))
			$result = (int)$row['USER_ID'];

		return $result;
	}

	/**
	 * Delete fuserId over several days.
	 *
	 * @param int $days			Interval.
	 * @return void
	 */
	public static function deleteOld($days)
	{
		$expired = new Main\Type\DateTime();
		$expired->add('-'.$days.' days');
		$expiredValue = $expired->format('Y-m-d H:i:s');

		/** @var Main\DB\Connection $connection */
		$connection = Main\Application::getConnection();
		/** @var Main\DB\SqlHelper $sqlHelper */
		$sqlHelper = $connection->getSqlHelper();

		$query = "DELETE FROM b_sale_fuser WHERE
									b_sale_fuser.DATE_UPDATE < ".$sqlHelper->getDateToCharFunction("'".$expiredValue."'")."
									AND b_sale_fuser.USER_ID IS NULL
									AND b_sale_fuser.id NOT IN (select FUSER_ID from b_sale_basket)";
		$connection->queryExecute($query);
	}

	/**
	 * Create new fuserId for user.
	 *
	 * @param int $userId				User id.
	 * @return Main\Entity\AddResult
	 * @throws \Exception
	 */
	protected static function createForUserId($userId)
	{
		$fields = array(
			'DATE_INSERT' => new Main\Type\DateTime(),
			'DATE_UPDATE' => new Main\Type\DateTime(),
			'USER_ID' => $userId,
			'CODE' => md5(time().randString(10))
		);

		/** @var Result $r */
		return Internals\FuserTable::add($fields);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit