PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.1
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.1
4.11.2 4.11.1 4.11.0 4.10.0 4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Framework / Filesystem / PathChecker.php
wp-staging / Framework / Filesystem Last commit date
Filters 1 week ago Scanning 1 week ago AbstractFileObject.php 1 week ago AbstractFilesystemScanner.php 1 week ago DebugLogReader.php 1 week ago DirectoryListing.php 1 week ago DirectorySize.php 1 week ago DiskWriteCheck.php 1 week ago FileObject.php 1 week ago Filesystem.php 1 week ago FilesystemExceptions.php 5 years ago FilesystemScanner.php 1 week ago FilesystemScannerDto.php 1 week ago FilterableDirectoryIterator.php 1 week ago LegacyFileRulesTrait.php 1 week ago LogCleanup.php 1 week ago LogFiles.php 1 week ago MissingFileException.php 3 years ago OPcache.php 1 week ago PartIdentifier.php 1 week ago PathChecker.php 1 week ago PathIdentifier.php 1 week ago Permissions.php 1 week ago WpUploadsFolderSymlinker.php 1 week ago
PathChecker.php
88 lines
1 <?php
2
3 namespace WPStaging\Framework\Filesystem;
4
5 use UnexpectedValueException;
6 use WPStaging\Framework\Adapter\Directory;
7
8
9
10
11
12
13 class PathChecker
14 {
15
16 private $filesystem;
17
18
19 private $directory;
20
21
22 private $pathIdentifier;
23
24
25
26
27
28
29
30
31 public function __construct(Filesystem $filesystem, Directory $directory, PathIdentifier $pathIdentifier)
32 {
33 $this->filesystem = $filesystem;
34 $this->directory = $directory;
35 $this->pathIdentifier = $pathIdentifier;
36 }
37
38
39
40
41
42
43
44
45
46
47
48
49
50 public function isPathInPathsList(string $path, array $list, bool $isRelative = false, $basePath = null): bool
51 {
52 if (empty($basePath)) {
53 $basePath = $this->directory->getAbsPath();
54 }
55
56 $basePath = $this->filesystem->normalizePath($basePath);
57 $path = $this->filesystem->normalizePath($path);
58
59 if ($isRelative) {
60 $path = '/' . ltrim(str_replace($basePath, '', $path), '/');
61 }
62
63 foreach ($list as $pathItem) {
64 $pathItem = $this->filesystem->normalizePath($pathItem);
65 try {
66 $pathItem = $this->pathIdentifier->transformIdentifiableToPath($pathItem);
67 } catch (UnexpectedValueException $ex) {
68 }
69
70
71 if ($isRelative) {
72 $pathItem = '/' . ltrim(str_replace($basePath, '', $pathItem), '/');
73 }
74
75 if ($path === $pathItem) {
76 return true;
77 }
78
79
80 if (strpos($path, $pathItem . '/') === 0) {
81 return true;
82 }
83 }
84
85 return false;
86 }
87 }
88