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,89 @@
<?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\Block\Html;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Plumrocket\CookieConsent\Api\Data\CategoryInterface;
use Plumrocket\CookieConsent\Model\Category\GetCategoriesWithScripts;
/**
* @since 1.0.0
*/
class BodyScripts extends Template
{
/**
* @var \Plumrocket\CookieConsent\Model\Category\GetCategoriesWithScripts
*/
private $getCategoriesWithScripts;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Plumrocket\CookieConsent\Model\Category\GetCategoriesWithScripts $getCategoriesWithScripts
* @param array $data
*/
public function __construct(
Context $context,
GetCategoriesWithScripts $getCategoriesWithScripts,
array $data = []
) {
parent::__construct($context, $data);
$this->getCategoriesWithScripts = $getCategoriesWithScripts;
}
/**
* @return \Plumrocket\CookieConsent\Api\Data\CategoryInterface[]
*/
public function getEssentialCategoriesWithScripts(): array
{
return array_filter(
$this->getCategoriesWithScripts->execute(),
static function (CategoryInterface $category) {
return $category->isEssential();
}
);
}
/**
* @return \Plumrocket\CookieConsent\Api\Data\CategoryInterface[]
*/
public function getOptionalCategoriesWithScripts(): array
{
return array_filter(
$this->getCategoriesWithScripts->execute(),
static function (CategoryInterface $category) {
return ! $category->isEssential();
}
);
}
/**
* @param string $html
* @return string
*/
public function prepareHtml(string $html): string
{
return str_replace(
['\'', '<script', '</script>', "\n","\t","\r", ],
['\\\'', '<scr\' + \'ipt', '</scr\' + \'ipt>', ' ', ' ', ' ', ],
$html
);
}
}
@@ -0,0 +1,73 @@
<?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) 2021 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Block\Html;
use Magento\Framework\View\Element\Html\Link;
use Magento\Framework\View\Element\Template\Context;
use Plumrocket\CookieConsent\Api\CanManageCookieInterface;
/**
* @since 1.2.0
*/
class CookieSettingsLink extends Link
{
/**
* @var \Plumrocket\CookieConsent\Api\CanManageCookieInterface
*/
private $canManageCookie;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Plumrocket\CookieConsent\Api\CanManageCookieInterface $canManageCookie
* @param array $data
*/
public function __construct(
Context $context,
CanManageCookieInterface $canManageCookie,
array $data = []
) {
parent::__construct($context, $data);
$this->canManageCookie = $canManageCookie;
}
/**
* Need to overwrite parent method to avoid build the URL
*
* @inheritDoc
*/
public function getHref(): string
{
return $this->getPath();
}
/**
* If customer cannot manage cookie we should not show link
*
* @return string
*/
protected function _toHtml()
{
if (! $this->canManageCookie->execute()) {
return '';
}
return parent::_toHtml();
}
}
@@ -0,0 +1,109 @@
<?php
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2025 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Block\Html;
use Magento\Framework\Code\Minifier\Adapter\Js\JShrink;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
/**
* @since 2.0.4
*/
class HeadScripts extends Template
{
public const SCRIPT_TAG_REPLACEMENT = 'prcookie-head-script';
/**
* @var \Magento\Framework\Code\Minifier\Adapter\Js\JShrink
*/
private $jsMinifier;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\Code\Minifier\Adapter\Js\JShrink $jsMinifier
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param array $data
*/
public function __construct(
Context $context,
JShrink $jsMinifier,
ObjectManagerInterface $objectManager,
array $data = []
) {
parent::__construct($context, $data);
$this->jsMinifier = $jsMinifier;
/**
* @TODO Refactor when leave support of Magento 2.3.7 and less
*/
$this->secureHtmlRenderer = class_exists(SecureHtmlRenderer::class)
? $objectManager->get(SecureHtmlRenderer::class)
: null;
}
protected function _toHtml()
{
$html = parent::_toHtml();
preg_match_all('/<script[\s\S]*?\/script>/', $html, $scriptTags);
$scriptTags = array_shift($scriptTags);
foreach ($scriptTags as $scriptTag) {
try {
$modifiedScriptTag = $this->modifyScriptTag($scriptTag);
} catch (\Exception $e) {
continue;
}
$html = str_replace($scriptTag, $modifiedScriptTag, $html);
}
return $html;
}
/**
* Modify script tag to prevent from being moved to footer
*
* @param string $scriptTag
* @return string
* @throws \Exception
*/
private function modifyScriptTag(string $scriptTag): string
{
/**
* @TODO Refactor when leave support of Magento 2.3.7 and less
*/
if (! $this->secureHtmlRenderer) {
preg_match('#<script[\s\S]*?>([^`]*?)<\/script>#', $scriptTag, $matches);
if(isset($matches[1])) {
$originalTagContent = $matches[1];
$minifiedContent = $this->jsMinifier->minify($originalTagContent);
$scriptTag = str_replace($originalTagContent, $minifiedContent, $scriptTag);
}
return str_replace(
['<script', '/script>'],
['<' . self::SCRIPT_TAG_REPLACEMENT, '/'.self::SCRIPT_TAG_REPLACEMENT.'>'],
$scriptTag
);
}
$doc = new \DOMDocument();
$doc->loadHTML($scriptTag);
$scriptNode = $doc->getElementsByTagName('script')->item(0);
$tagAttributes = array_column(iterator_to_array($scriptNode->attributes), 'nodeValue', 'name');
$tagContent = $this->jsMinifier->minify($scriptNode->textContent);
return $this->secureHtmlRenderer->renderTag(self::SCRIPT_TAG_REPLACEMENT, $tagAttributes, $tagContent, false);
}
}