HEX
Server: nginx/1.24.0
System: Linux server 6.12.74+deb13+1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.74-2 (2026-03-08) x86_64
User: www (1001)
PHP: 8.5.2
Disabled: 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
Upload Files
File: /www/wwwroot/claudiayancor.duckdns.org/wp-content/plugins/photonic/Components/Stack_Trace.php
<?php

namespace Photonic_Plugin\Components;

use Photonic_Plugin\Layouts\Core_Layout;
use Photonic_Plugin\Modules\Core;

class Stack_Trace implements Printable {
	public $events = [];

	public function add_to_first_open_event($new_event) {
		$found = false;
		foreach ($this->events as $id => $event) {
			if (isset($event['start']) && !isset($event['end'])) {
				// Ongoing event. Need to add to this.
				$found = true;
				if (!isset($event['children'])) {
					$children = new Stack_Trace();
				}
				else {
					$children = $event['children'];
				}
				$children->add_to_first_open_event($new_event);
				$event['children'] = $children;
				$this->events[$id] = $event;
			}
			if ($found) {
				break;
			}
		}
		if (!$found) {
			$this->events[] = [
				'event' => $new_event,
				'start' => microtime(true),
			];
		}
	}

	public function pop_from_first_open_event() {
		$found = false;
		foreach ($this->events as $id => $event) {
			if (isset($event['start']) && !isset($event['end'])) {
				// Ongoing event. Need to pop this or its open child
				$found = true;
				$found_child = false;
				if (isset($event['children'])) {
					/** @var Stack_Trace $children */
					$children = $event['children'];
					$found_child = $children->pop_from_first_open_event();
					$event['children'] = $children;
				}
				if (!$found_child) {
					$event['end'] = microtime(true);
					$event['time'] = $event['end'] - $event['start'];
				}
				$this->events[$id] = $event;
			}
			if ($found) {
				break;
			}
		}
		return $found;
	}

	private function get_nested_element($indent = "\t") {
		$ret = '';
		foreach ($this->events as $trace) {
			$trace_items = [];
			foreach ($trace as $key => $trace_item) {
				if ('children' !== $key) {
					$trace_items[] = strtoupper(substr($key, 0, 1)) . substr($key, 1) . ': ' . $trace_item;
				}
			}
			$ret .= $indent . implode(', ', $trace_items) . "\n";
			if (!empty($trace['children'])) {
				/** @var Stack_Trace $children */
				$children = $trace['children'];
				$ret .= $children->get_nested_element($indent . "\t");
			}
		}
		return $ret;
	}


	public function html(Core $module, Core_Layout $layout = null, $print = false) {
		$ret = "<!--\n";
		$ret .= "Stats for Platform: {$module->provider}, Gallery: {$module->gallery_index}\n";
		$ret .= $this->get_nested_element();
		$ret .= "-->\n";

		if ($print) {
			echo wp_kses_post($ret);
		}

		return wp_kses_post($ret);
	}
}