| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.4/wp-content/plugins/revslider/admin/includes/svg_sanitizer/ |
Upload File : |
<?php
/**
* @author ThemePunch <info@themepunch.com>
* @link https://www.themepunch.com/
* @copyright 2024 ThemePunch
*/
if (!defined('ABSPATH')) exit();
class RevSliderSvgSubject
{
/**
* @var DOMElement
*/
protected $element;
/**
* @var RevSliderSvgSubject[]
*/
protected $use = [];
/**
* @var RevSliderSvgSubject[]
*/
protected $usedIn = [];
/**
* @var int
*/
protected $nestingLimit;
/**
* @param DOMElement $element
* @param int $limit
*/
public function __construct($element, $limit)
{
$this->element = $element;
$this->nestingLimit = $limit;
}
/**
* @return DOMElement
*/
public function getElement()
{
return $this->element;
}
/**
* @return string
*/
public function getElementId()
{
return $this->element->getAttribute('id');
}
/**
* @param array $subjects Previously processed subjects
* @param int $level The current level of nesting.
* @return DOMElement|bool
*/
public function hasInfiniteLoop(array $subjects = [], $level = 1)
{
if ($level > $this->nestingLimit) {
return $this->getElement();
}
if (in_array($this, $subjects, true)) return true;
$subjects[] = $this;
foreach ($this->use as $subjectUse) {
$result = $subjectUse['subject']->hasInfiniteLoop($subjects, $level + 1);
if ($result instanceof DOMElement) return $result;
if ($result) return true;
}
return false;
}
/**
* @param RevSliderSvgSubject $subject
* @param string $arrName
*/
protected function doAdd($subject, $arrName)
{
if ($subject === $this) {
throw new LogicException('Cannot add self usage');
}
$id = $subject->getElementId();
if (isset($this->$arrName[$id])) {
$this->$arrName[$id]['count']++;
return;
}
$this->$arrName[$id] = [
'subject' => $subject,
'count' => 1,
];
}
/**
* @param RevSliderSvgSubject $subject
*/
public function addUse($subject)
{
$this->doAdd($subject, 'use');
}
/**
* @param RevSliderSvgSubject $subject
*/
public function addUsedIn($subject)
{
$this->doAdd($subject, 'usedIn');
}
/**
* @param string $arrName
* @param string $countFunc
* @return int
*/
protected function doCount($arrName, $countFunc)
{
$count = 0;
foreach ($this->$arrName as $subject) {
$count += $subject['count'] * max(1, $subject['subject']->$countFunc());
}
return $count;
}
/**
* @return int
*/
public function countUse()
{
return $this->doCount('use', 'countUse');
}
/**
* @return int
*/
public function countUsedIn()
{
return $this->doCount('usedIn', 'countUsedIn');
}
/**
* get all affected DOMElement's
*
* @return array
*/
public function getAffectedElements()
{
$elements = array_map(function ($subjectUse) {
return $subjectUse['subject']->getElement();
}, $this->use);
$this->usedIn = [];
$this->use = [];
return $elements;
}
}