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/app/code/Cnc/Store/Setup/Patch/Data/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/app/code/Cnc/Store/Setup/Patch/Data/ConfigureCaptcha.php
<?php
/**
 * @author    Radosław Łańcucki <[email protected]>
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 * @copyright Copyright (c) 2022 KDC (https://digitalcommerce.kaliop.com/)
 */
declare(strict_types=1);

namespace Cnc\Store\Setup\Patch\Data;

use Magento\Framework\App\Config\ConfigResource\ConfigInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;

class ConfigureCaptcha implements DataPatchInterface
{
    /**
     * @var ConfigInterface
     */
    private $config;

    /**
     * Recaptcha protected Forms
     *
     * @var bool[]
     */
    private $recaptchaForms = [
        'contact' => true,
        'customer_create' => true,
        'customer_edit' => false,
        'customer_forgot_password' => true,
        'customer_login' => false,
        'newsletter' => false,
        'paypal_payflowpro' => false,
        'product_review' => false,
        'sendfriend' => false,
    ];

    /**
     * Recaptcha protected Backend Forms
     *
     * @var bool[]
     */
    private $recaptchaBackendForms = [
        'user_login' => true,
        'user_forgot_password' => true
    ];

    private $recaptchaVersion = 'recaptcha_v3';

    /**
     * @param ConfigInterface $config
     */
    public function __construct(ConfigInterface $config)
    {
        $this->config = $config;
    }

    /**
     * {@inheritDoc}
     */
    public static function getDependencies(): array
    {
        return [];
    }

    /**
     * {@inheritDoc}
     */
    public function getAliases(): array
    {
        return [];
    }

    public function apply(): void
    {
        $this->disableCaptcha();
        $this->enableReCaptcha();
    }

    private function disableCaptcha(): void
    {
        $this->config->saveConfig('customer/captcha/enable', 0);
        $this->config->saveConfig('customer/captcha/forms', null);
    }

    private function enableReCaptcha(): void
    {
        foreach ($this->recaptchaForms as $recaptchaForm => $isActive) {
            $value = $isActive ? $this->recaptchaVersion : null;
            $this->config->saveConfig("recaptcha_frontend/type_for/{$recaptchaForm}", $value);
        }

        foreach ($this->recaptchaBackendForms as $recaptchaBackendForm => $isActive) {
            $value = $isActive ? $this->recaptchaVersion : null;
            $this->config->saveConfig("recaptcha_backend/type_for/{$recaptchaBackendForm}", $value);
        }
    }
}

Spamworldpro Mini