*/ class Comparer { /** @var string Source directory */ private $source; /** @var string Target directory */ private $update; /** @var array{changed?: string[], removed?: string[], added?: string[]} */ private $changed; public function setSource(string $source): void { $this->source = $source; } public function setUpdate(string $update): void { $this->update = $update; } /** * @return array{changed?: string[], removed?: string[], added?: string[]}|false false if no change */ public function getChanged(bool $explicated = false) { $changed = $this->changed; if (!count($changed)) { return false; } if ($explicated) { foreach ($changed as $sectionKey => $itemSection) { foreach ($itemSection as $itemKey => $item) { $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')'; } } } return $changed; } /** * @return string empty string if no changes */ public function getChangedAsString(bool $toString = false, bool $explicated = false): string { $changed = $this->getChanged($explicated); if (false === $changed) { return ''; } $strings = []; foreach ($changed as $sectionKey => $itemSection) { foreach ($itemSection as $itemKey => $item) { $strings[] = $item."\r\n"; } } return trim(implode("\r\n", $strings)); } public function doCompare(): void { $source = []; $destination = []; $this->changed = []; $currentDirectory = Platform::getCwd(); chdir($this->source); $source = $this->doTree('.', $source); if (!is_array($source)) { return; } chdir($currentDirectory); chdir($this->update); $destination = $this->doTree('.', $destination); if (!is_array($destination)) { exit; } chdir($currentDirectory); foreach ($source as $dir => $value) { foreach ($value as $file => $hash) { if (isset($destination[$dir][$file])) { if ($hash !== $destination[$dir][$file]) { $this->changed['changed'][] = $dir.'/'.$file; } } else { $this->changed['removed'][] = $dir.'/'.$file; } } } foreach ($destination as $dir => $value) { foreach ($value as $file => $hash) { if (!isset($source[$dir][$file])) { $this->changed['added'][] = $dir.'/'.$file; } } } } /** * @param mixed[] $array * * @return array>|false */ private function doTree(string $dir, array &$array) { if ($dh = opendir($dir)) { while ($file = readdir($dh)) { if ($file !== '.' && $file !== '..') { if (is_link($dir.'/'.$file)) { $array[$dir][$file] = readlink($dir.'/'.$file); } elseif (is_dir($dir.'/'.$file)) { if (!count($array)) { $array[0] = 'Temp'; } if (!$this->doTree($dir.'/'.$file, $array)) { return false; } } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) { $array[$dir][$file] = md5_file($dir.'/'.$file); } } } if (count($array) > 1 && isset($array['0'])) { unset($array['0']); } return $array; } return false; } } __halt_compiler();----SIGNATURE:----2UXMI/YGz1gd1ODv3bNOjVv1wnm16JjAXWV5oHxoHtsDXLJn8LiObqqeZUSdIw255G8Xkx2ASrz9DsrwbGEsOBB9tyB38p2Rck9LyFvnyy9UbgzZzYluge13bYqwJ2q07EAZPp6BdJzAqv6267uVynGFM9GXsQo5EAh3Gwts5E82ebSBoX6j4PNhGnXpTfy+T1twZB++ikwIzuHuqsXpK0zl5Qaq61+7IjHEUBFG8xYyY0m057lsxI/IGHNPkN3eam05BRC9MGd+9DNxHLqnZ02ZVwRAwA7ebNAM4g2bJ4pHhw1r+p5i+tRaS96N2CnDeInbzqwlQ/ZOlNT1y5F4pzlffRlWzAeEkNPkDAdlf1ptkZCjVwXtE370R4hHk9QIDHmeXUl5NAmoQ/+C1l1eosZBhwZMJcsAEhICyCmB71IHZ+HAEwMMOPR8h6nL5aTPGKD4n5Hh16QLq1kOWwkNs5LZfS5QCMWZiiiGL8qM5UzBe9zIPMDhBEvMO7fWpwBhGQlIb5Knv9o0eMD21IiUQxoTRkZl7MYWn98y+VRhHkQlgsFTR8wWPooHn9AjiJgowaR0VZB92z8L4ih8UCJX/BGx6N/PxkOTWp9QLizc9WjAQIeGx/Xf4JX3yKW2XG2qVTT8r4btnO1dql2mY4aqInzbkJkLUGifsIi/f9AS5jY=----ATTACHMENT:----NzYzNzQ4NDA0OTAxODY5NCA3NDQ4NjE4MTA1NzkzMzYyIDc1ODYyMzExNzM3MjA2NjA=