PHP 8.2.31
Preview: Siteplus.php Size: 1.79 KB
//opt/cpanel/ea-wappspector/src/Matchers/Siteplus.php

<?php

declare(strict_types=1);

namespace Plesk\Wappspector\Matchers;

use League\Flysystem\Filesystem;
use Plesk\Wappspector\Helper\InspectorHelper;
use Plesk\Wappspector\MatchResult\EmptyMatchResult;
use Plesk\Wappspector\MatchResult\MatchResultInterface;
use Plesk\Wappspector\MatchResult\Siteplus as MatchResult;

class Siteplus implements MatcherInterface
{
    private const PUBLISH_DIR_PATH = '/bundle/publish';

    public function match(Filesystem $fs, string $path): MatchResultInterface
    {
        $rTrimPath = rtrim($path, '/');

        $inspectorHelper = new InspectorHelper();

        if (!$inspectorHelper->fileContainsString($fs, $rTrimPath . '/index.html', 'edit.site')) {
            return new EmptyMatchResult();
        }

        if (!$fs->directoryExists($rTrimPath . self::PUBLISH_DIR_PATH)) {
            return new EmptyMatchResult();
        }

        $publishDirList = $fs->listContents($rTrimPath . self::PUBLISH_DIR_PATH, false);

        // do not check if the item is a directory as on the server when the files a copied the type of the
        // directory is determined as 'file'.
        // By default, there should be just 1 directory in the publish directory
        $versionDirPath = $publishDirList->toArray()[0]['path'] ?? null;

        if ($versionDirPath === null) {
            return new EmptyMatchResult();
        }

        return $inspectorHelper->fileContainsString($fs, $versionDirPath . '/bundle.js', 'siteplus')
            ? new MatchResult($rTrimPath, $this->getSiteplusVersion($versionDirPath))
            : new EmptyMatchResult();
    }

    private function getSiteplusVersion(string $versionDirPath): string
    {
        // get the last part of the path
        $versionDirPathParts = explode('/', $versionDirPath);
        return end($versionDirPathParts);
    }
}

Directory Contents

Dirs: 0 × Files: 23

Name Size Perms Modified Actions
1.02 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.14 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.09 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.05 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.63 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.72 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
3.79 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.90 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
343 B lrw-r--r-- 2026-05-14 15:20:35
Edit Download
866 B lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.07 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.41 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
742 B lrw-r--r-- 2026-05-14 15:20:35
Edit Download
713 B lrw-r--r-- 2026-05-14 15:20:35
Edit Download
976 B lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.79 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
980 B lrw-r--r-- 2026-05-14 15:20:35
Edit Download
905 B lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.77 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
982 B lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.97 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.48 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download
1.64 KB lrw-r--r-- 2026-05-14 15:20:35
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).