ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,74 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Model\User;
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\Stdlib\Cookie\CookieReaderInterface;
use Plumrocket\CookieConsent\Api\Data\CategoryInterface;
use Plumrocket\CookieConsent\Api\GetUserConsentInterface;
/**
* @since 1.0.0
*/
class GetConsent implements GetUserConsentInterface
{
/**
* @var \Magento\Framework\Stdlib\Cookie\CookieReaderInterface
*/
private $cookieReader;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* @param \Magento\Framework\Stdlib\Cookie\CookieReaderInterface $cookieReader
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
public function __construct(
CookieReaderInterface $cookieReader,
SerializerInterface $serializer
) {
$this->cookieReader = $cookieReader;
$this->serializer = $serializer;
}
/**
* @inheritDoc
*/
public function execute(): array
{
$consent = $this->cookieReader->getCookie(self::COOKIE_CONSENT_NAME);
if (null === $consent) {
throw new NotFoundException(__('User didnt make any consents.'));
}
/**
* todo: remove in 2022
*
* Previously we used "*" for "all categories" but cookie with this value is blocked by mod security
* @see REQUEST-942-APPLICATION-ATTACK-SQLI
*/
$consent = str_replace('*', CategoryInterface::ALL_CATEGORIES, $consent);
return $this->serializer->unserialize($consent);
}
}
@@ -0,0 +1,56 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Model\User;
use Magento\Framework\Exception\NotFoundException;
use Plumrocket\CookieConsent\Api\GetUserConsentInterface;
use Plumrocket\CookieConsent\Api\IsUserOptInInterface;
/**
* @since 1.0.0
*/
class IsOptIn implements IsUserOptInInterface
{
/**
* @var \Plumrocket\CookieConsent\Api\GetUserConsentInterface
*/
private $getUserConsent;
/**
* @param \Plumrocket\CookieConsent\Api\GetUserConsentInterface $getUserConsent
*/
public function __construct(GetUserConsentInterface $getUserConsent)
{
$this->getUserConsent = $getUserConsent;
}
/**
* @inheritDoc
*/
public function execute(): bool
{
try {
$this->getUserConsent->execute();
return true;
} catch (NotFoundException $e) {
return false;
}
}
}
@@ -0,0 +1,72 @@
<?php
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2022 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Model\User;
use Magento\Framework\Stdlib\Cookie\PublicCookieMetadata;
use Magento\Framework\Stdlib\CookieManagerInterface;
use Magento\Framework\Stdlib\Cookie\PublicCookieMetadataFactory;
use Plumrocket\CookieConsent\Helper\Config;
/**
* @since 1.6.0
*/
class SetCookieConsentId
{
public const COOKIE_CONSENT_ID = 'pr-cookie-consent-id';
/**
* @var CookieManagerInterface
*/
private $cookieManager;
/**
* @var PublicCookieMetadataFactory
*/
private $publicCookieMetadataFactory;
/**
* @var Config
*/
private $config;
/**
* @param CookieManagerInterface $cookieManager
* @param PublicCookieMetadataFactory $publicCookieMetadataFactory
* @param Config $config
*/
public function __construct(
CookieManagerInterface $cookieManager,
PublicCookieMetadataFactory $publicCookieMetadataFactory,
Config $config
) {
$this->cookieManager = $cookieManager;
$this->publicCookieMetadataFactory = $publicCookieMetadataFactory;
$this->config = $config;
}
/**
* Save the user's consent id in browser's cookie
*
* @param int $consentId
* @return void
* @throws \Magento\Framework\Exception\InputException
* @throws \Magento\Framework\Stdlib\Cookie\CookieSizeLimitReachedException
* @throws \Magento\Framework\Stdlib\Cookie\FailureToSendException
*/
public function execute(int $consentId): void
{
/** @var PublicCookieMetadata $publicCookieMetadata */
$publicCookieMetadata = $this->publicCookieMetadataFactory->create(['metadata' => []]);
$publicCookieMetadata
->setDuration($this->config->getConsentExpiry() * 86400)
->setPath('/');
$this->cookieManager->setPublicCookie(self::COOKIE_CONSENT_ID, $consentId, $publicCookieMetadata);
}
}