Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/module-security/Model/ResourceModel/AdminSessionInfo/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-security/Model/ResourceModel/AdminSessionInfo/Collection.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Security\Model\ResourceModel\AdminSessionInfo;

/**
 * Admin Session Info collection
 *
 * @api
 * @since 100.1.0
 */
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
    /**
     * @var string
     * @since 100.1.0
     */
    protected $_idFieldName = 'id';

    /**
     * @var \Magento\Framework\Stdlib\DateTime\DateTime
     * @since 100.1.0
     */
    protected $dateTime;

    /**
     * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
     * @param \Psr\Log\LoggerInterface $logger
     * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
     * @param \Magento\Framework\Event\ManagerInterface $eventManager
     * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
     * @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
     * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource
     */
    public function __construct(
        \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
        \Psr\Log\LoggerInterface $logger,
        \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
        \Magento\Framework\Event\ManagerInterface $eventManager,
        \Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
        \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
        \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
    ) {
        parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
        $this->dateTime = $dateTime;
    }

    /**
     * Define resource model
     *
     * @return void
     * @since 100.1.0
     */
    protected function _construct()
    {
        $this->_init(
            \Magento\Security\Model\AdminSessionInfo::class,
            \Magento\Security\Model\ResourceModel\AdminSessionInfo::class
        );
    }

    /**
     * Update active sessions status except a specific one
     *
     * @param int $status
     * @param int $userId
     * @param string $sessionIdToExclude
     * @param int $updateOlderThen
     * @return int The number of affected rows.
     * @since 100.1.0
     */
    public function updateActiveSessionsStatus(
        $status,
        $userId,
        $sessionIdToExclude,
        $updateOlderThen = null
    ) {
        return $this->getResource()->updateStatusByUserId(
            $status,
            $userId,
            [\Magento\Security\Model\AdminSessionInfo::LOGGED_IN],
            [$sessionIdToExclude],
            $updateOlderThen
        );
    }

    /**
     * Filter by user
     *
     * @param int $userId
     * @param int $status
     * @param null|string $sessionIdToExclude
     * @return $this
     * @since 100.1.0
     */
    public function filterByUser(
        $userId,
        $status = \Magento\Security\Model\AdminSessionInfo::LOGGED_IN,
        $sessionIdToExclude = null
    ) {
        $this->addFieldToFilter('user_id', $userId);
        $this->addFieldToFilter('status', $status);
        if (null !== $sessionIdToExclude) {
            $this->addFieldToFilter('id', ['neq' => $sessionIdToExclude]);
        }
        return $this;
    }

    /**
     * Filter expired sessions
     *
     * @param int $sessionLifeTime
     * @return $this
     * @since 100.1.0
     */
    public function filterExpiredSessions($sessionLifeTime)
    {
        $connection = $this->getConnection();
        $gmtTimestamp = $this->dateTime->gmtTimestamp();
        $this->addFieldToFilter(
            'updated_at',
            ['gt' => $connection->formatDate($gmtTimestamp - $sessionLifeTime)]
        );
        return $this;
    }

    /**
     * Delete sessions older than some value
     *
     * @param int $timestamp
     * @return $this
     * @since 100.1.0
     */
    public function deleteSessionsOlderThen($timestamp)
    {
        $this->getResource()->deleteSessionsOlderThen((int) $timestamp);

        return $this;
    }
}

Spamworldpro Mini