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 / vendor / amasty / base / Debug /
Filename/home/dev2.destoffenstraat.com/vendor/amasty/base/Debug/VarDump.php
Size4.7 kb
Permissionrw-r--r--
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified16-Aug-2022 09:35
Last accessed22-Aug-2025 22:24
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2022 Amasty (https://www.amasty.com)
* @package Magento 2 Base Package
*/

namespace Amasty\Base\Debug;

/**
* For Remote Debug
* Output is to front
* @codeCoverageIgnore
* @codingStandardsIgnoreFile
*/
class VarDump
{
/**
* @var array
*/
private static $addressPath = [
'REMOTE_ADDR',
'HTTP_X_REAL_IP',
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR'
];

/**
* @var array
*/
private static $amastyIps = [
'213.184.226.82',
'87.252.238.217',
'82.209.247.206',
];

/**
* @var int
*/
private static $objectDepthLevel = 1;

/**
* @var int
*/
private static $arrayDepthLevel = 2;

/**
* @param int $level
*/
public static function setObjectDepthLevel($level)
{
self::$objectDepthLevel = (int)$level;
}

/**
* @param int $level
*/
public static function setArrayDepthLevel($level)
{
self::$arrayDepthLevel = (int)$level;
}

public static function execute()
{
if (self::isAllowed()) {
foreach (func_get_args() as $var) {
System\Beautifier::getInstance()->beautify(self::dump($var));
}
}
}

/**
* @param array $array
* @param int $level
*
* @return array|string
*/
private static function castArray($array, $level)
{
if ($level > self::$arrayDepthLevel) {
return '...';
}
$result = [];
foreach ($array as $key => $value) {
switch (strtolower(gettype($value))) {
case 'object':
$result[$key] = self::castObject($value, $level + 1);
break;
case 'array':
$result[$key] = self::castArray($value, $level + 1);
break;
default:
$result[$key] = $value;
break;
}
}
return $result;
}

/**
* @param $object
* @param int $level
*
* @return System\AmastyDump|string
*/
private static function castObject($object, $level)
{
if ($level > self::$objectDepthLevel) {
return '...';
}
$reflection = new \ReflectionClass($object);

$amastyDump = new System\AmastyDump();

$amastyDump->className = $reflection->getName();
$amastyDump->shortClassName = $reflection->getShortName();

foreach ($reflection->getMethods() as $method) {
$amastyDump->methods[] = $method->getName();
}
foreach ($reflection->getProperties() as $property) {
$property->setAccessible(true);
$propertyValue = $property->getValue($object);
switch (strtolower(gettype($propertyValue))) {
case 'object':
$amastyDump->properties[$property->name] = self::castObject($propertyValue, $level + 1);
break;
case 'array':
$amastyDump->properties[$property->name] = self::castArray($propertyValue, $level + 1);
break;
default:
$amastyDump->properties[$property->name] = $propertyValue;
break;
}
}
return $amastyDump;
}

/**
* @param mixed $var
*
* @return AmastyDump|array|mixed
*/
public static function dump($var)
{
if (self::isAllowed()) {
switch (strtolower(gettype($var))) {
case 'object':
return self::castObject($var, 0);
case 'array':
return self::castArray($var, 0);
case 'resource':
return stream_get_meta_data($var);
default:
return $var;
}
}
}

/**
* Check for Amasty Ips
*
* @return bool
*/
public static function isAllowed()
{
foreach (self::$addressPath as $path) {
if (!empty($_SERVER[$path]) && in_array($_SERVER[$path], self::$amastyIps, true)) {
return true;
}
}

return false;
}

/**
* @param int $code
*/
public static function amastyExit($code = 0)
{
if (self::isAllowed()) {
if (class_exists(\Zend\Console\Response::class)) {
(new \Zend\Console\Response())->send();
}
}
}

/**
* @param string $string
*/
public static function amastyEcho($string)
{
if (self::isAllowed()) {
printf('%s', $string);
}
}
}