PAYONE-GmbH /
magento-2
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
||
| 5 | * it under the terms of the GNU Lesser General Public License as published by |
||
| 6 | * the Free Software Foundation, either version 3 of the License, or |
||
| 7 | * (at your option) any later version. |
||
| 8 | * |
||
| 9 | * PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 12 | * GNU Lesser General Public License for more details. |
||
| 13 | * |
||
| 14 | * You should have received a copy of the GNU Lesser General Public License |
||
| 15 | * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
||
| 16 | * |
||
| 17 | * PHP version 5 |
||
| 18 | * |
||
| 19 | * @category Payone |
||
| 20 | * @package Payone_Magento2_Plugin |
||
| 21 | * @author FATCHIP GmbH <[email protected]> |
||
| 22 | * @copyright 2003 - 2016 Payone GmbH |
||
| 23 | * @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
||
| 24 | * @link http://www.payone.de |
||
| 25 | */ |
||
| 26 | |||
| 27 | namespace Payone\Core\Helper; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Helper class for everything that has to do with the server environment |
||
| 31 | */ |
||
| 32 | class Environment extends \Payone\Core\Helper\Base |
||
| 33 | { |
||
| 34 | /** |
||
| 35 | * @var \Magento\Framework\App\RequestInterface |
||
|
0 ignored issues
–
show
|
|||
| 36 | */ |
||
| 37 | protected $request; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Constructor |
||
| 41 | * |
||
| 42 | * @param \Magento\Framework\App\Helper\Context $context |
||
| 43 | * @param \Magento\Store\Model\StoreManagerInterface $storeManager |
||
| 44 | * @param \Payone\Core\Helper\Shop $shopHelper |
||
| 45 | * @param \Magento\Framework\App\State $state |
||
| 46 | * @param \Magento\Framework\App\RequestInterface $request |
||
| 47 | */ |
||
| 48 | public function __construct( |
||
| 49 | \Magento\Framework\App\Helper\Context $context, |
||
|
0 ignored issues
–
show
The type
Magento\Framework\App\Helper\Context was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 50 | \Magento\Store\Model\StoreManagerInterface $storeManager, |
||
|
0 ignored issues
–
show
The type
Magento\Store\Model\StoreManagerInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 51 | \Payone\Core\Helper\Shop $shopHelper, |
||
| 52 | \Magento\Framework\App\State $state, |
||
|
0 ignored issues
–
show
The type
Magento\Framework\App\State was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 53 | \Magento\Framework\App\RequestInterface $request |
||
| 54 | ) { |
||
| 55 | parent::__construct($context, $storeManager, $shopHelper, $state); |
||
| 56 | $this->request = $request; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Get encoding |
||
| 61 | * |
||
| 62 | * @return string |
||
| 63 | */ |
||
| 64 | public function getEncoding() |
||
| 65 | { |
||
| 66 | return 'UTF-8'; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Get the IP of the requesting client |
||
| 71 | * |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | public function getRemoteIp() |
||
| 75 | { |
||
| 76 | $blProxyMode = (bool)$this->getConfigParam('proxy_mode', 'processing', 'payone_misc'); |
||
| 77 | $sClientIp = $this->request->getClientIp($blProxyMode); // may return a comma separated ip list like "<client>, <proxy1>, <proxy2>" |
||
| 78 | $aSplitIp = explode(",", $sClientIp); // split by comma |
||
| 79 | return trim(current($aSplitIp)); // return first array element |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Validate if the user-ip-address is in the configured whitelist |
||
| 84 | * |
||
| 85 | * @return bool |
||
| 86 | */ |
||
| 87 | public function isRemoteIpValid() |
||
| 88 | { |
||
| 89 | $sRemoteIp = $this->getRemoteIp(); |
||
| 90 | $sValidIps = $this->getConfigParam('valid_ips', 'processing', 'payone_misc'); |
||
| 91 | $aWhitelist = explode("\n", $sValidIps ?? ''); |
||
| 92 | $aWhitelist = array_filter(array_map('trim', $aWhitelist)); |
||
| 93 | if (array_search($sRemoteIp, $aWhitelist) !== false) { |
||
| 94 | return true; |
||
| 95 | } |
||
| 96 | foreach ($aWhitelist as $sIP) { |
||
| 97 | if (stripos($sIP, '*') !== false) { |
||
| 98 | $sIP = str_replace(array("\r", "\n"), '', $sIP); |
||
| 99 | $sDelimiter = '/'; |
||
| 100 | |||
| 101 | $sRegex = preg_quote($sIP, $sDelimiter); |
||
| 102 | $sRegex = str_replace('\*', '\d{1,3}', $sRegex); |
||
| 103 | $sRegex = $sDelimiter.'^'.$sRegex.'$'.$sDelimiter; |
||
| 104 | |||
| 105 | preg_match($sRegex, $sRemoteIp, $aMatches); |
||
| 106 | if (is_array($aMatches) && !empty($aMatches) && $aMatches[0] == $sRemoteIp) { |
||
| 107 | return true; |
||
| 108 | } |
||
| 109 | } |
||
| 110 | } |
||
| 111 | return false; |
||
| 112 | } |
||
| 113 | } |
||
| 114 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths