b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / app / code / WeltPixel / Backend / Plugin /
Filename/home/dev2.destoffenstraat.com/app/code/WeltPixel/Backend/Plugin/Utility.php
Size3.07 kb
Permissionrwxrwxrwx
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified17-May-2021 07:12
Last accessed22-Aug-2025 19:52
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php

namespace WeltPixel\Backend\Plugin;

class Utility
{

/**
* @var \Magento\Framework\App\ResponseInterface
*/
protected $_response;

/**
* @var \Magento\Framework\App\ViewInterface
*/
protected $_view;

/**
* @var \Magento\Backend\Model\Auth
*/
protected $_auth;

/**
* @var string
*/
protected $_pathInfo;

/** @var \WeltPixel\Backend\Model\License */
protected $licenseModel;


/**
* @param \Magento\Backend\Model\Auth $auth
* @param \Magento\Framework\App\ResponseInterface $response
* @param \Magento\Framework\App\ViewInterface $view
* @param \WeltPixel\Backend\Model\License $licenseModel
*/
public function __construct(
\Magento\Backend\Model\Auth $auth,
\Magento\Framework\App\ResponseInterface $response,
\Magento\Framework\App\ViewInterface $view,
\WeltPixel\Backend\Model\License $licenseModel
)
{
$this->_auth = $auth;
$this->_response = $response;
$this->_view = $view;
$this->licenseModel = $licenseModel;
}


/**
* @param \Magento\Backend\App\AbstractAction $subject
* @param \Closure $proceed
* @param \Magento\Framework\App\RequestInterface $request
*
* @return mixed
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundDispatch(
\Magento\Backend\App\AbstractAction $subject,
\Closure $proceed,
\Magento\Framework\App\RequestInterface $request
)
{
$this->_pathInfo = $request->getPathInfo();

if ($this->_auth->isLoggedIn() && !$request->isAjax() && $this->_isPathRestrictionRequired() && $request->isDispatched() && !$this->_isLcVd()) {
$this->_response->setStatusHeader(403, '1.1', 'Forbidden');
$this->_view->loadLayout(['default', 'weltpixel_license_needed'], true, true, false);
$this->_view->renderLayout();
$request->setDispatched(true);
return $this->_response;
}

return $proceed($request);

}

/**
* @return string
*/
protected function getPathInfo()
{
return $this->_pathInfo;
}

/**
* @return bool
*/
protected function _isLcVd()
{
$moduleName = $this->getModuleName();
$isLicenseRequired = $this->licenseModel->isLcNd($moduleName);
return $isLicenseRequired;
}

/**
* @return string
*/
protected function getModuleName() {
return '';
}

/**
* @return bool
*/
protected function _isPathRestrictionRequired()
{
foreach ($this->_getAdminPaths() as $path) {
if (strpos($this->getPathInfo(), $path) !== false) {
return true;
}
}
return false;
}

/**
* @return array
*/
protected function _getAdminPaths()
{
return [];
}

/**
* @param array $chars
* @return string
*/
public function convertToString($chars) {
return implode(array_map('chr', $chars));
}

}