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-captcha/CustomerData/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-captcha/CustomerData/Captcha.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

namespace Magento\Captcha\CustomerData;

use Magento\Customer\CustomerData\SectionSourceInterface;
use Magento\Customer\Model\Session as CustomerSession;
use Magento\Captcha\Model\DefaultModel;
use Magento\Captcha\Helper\Data as CaptchaHelper;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\DataObject;

/**
 * Captcha section.
 *
 * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
 */
class Captcha extends DataObject implements SectionSourceInterface
{
    /**
     * @var array
     */
    private $formIds;

    /**
     * @var CaptchaHelper
     */
    private $helper;

    /**
     * @var CustomerSession
     */
    private $customerSession;

    /**
     * @param CaptchaHelper $helper
     * @param array $formIds
     * @param array $data
     * @param CustomerSession|null $customerSession
     */
    public function __construct(
        CaptchaHelper $helper,
        array $formIds,
        array $data = [],
        ?CustomerSession $customerSession = null
    ) {
        $this->helper = $helper;
        $this->formIds = $formIds;
        parent::__construct($data);
        $this->customerSession = $customerSession ?? ObjectManager::getInstance()->get(CustomerSession::class);
    }

    /**
     * @inheritdoc
     */
    public function getSectionData(): array
    {
        $data = [];

        foreach ($this->formIds as $formId) {
            /** @var DefaultModel $captchaModel */
            $captchaModel = $this->helper->getCaptcha($formId);
            $login = '';
            if ($this->customerSession->isLoggedIn()) {
                $login = $this->customerSession->getCustomerData()->getEmail();
            }
            $required =  $captchaModel->isRequired($login);
            $data[$formId] = [
                'isRequired' => $required,
                'timestamp' => time()
            ];
        }

        return $data;
    }
}

Spamworldpro Mini