PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.1
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.1
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 / Utils / Glob.php
wp-staging / Framework / Utils Last commit date
Cache 1 week ago DBPermissions.php 1 week ago DataEncoder.php 1 week ago DatabaseOptions.php 1 week ago Env.php 1 week ago Escape.php 1 week ago Glob.php 1 week ago Hooks.php 1 week ago Math.php 6 days ago PluginInfo.php 1 week ago Sanitize.php 1 week ago ServerVars.php 1 week ago SlashMode.php 1 week ago Strings.php 1 week ago Times.php 1 week ago Urls.php 1 week ago Version.php 1 week ago WpDefaultDirectories.php 1 week ago
Glob.php
99 lines
1 <?php
2
3 namespace WPStaging\Framework\Utils;
4
5
6
7
8
9 /**
10 * Glob matches globbing patterns against text.
11 *
12 * if match_glob("foo.*", "foo.bar") echo "matched\n";
13 *
14 * // prints foo.bar and foo.baz
15 * $regex = glob_to_regex("foo.*");
16 * for (array('foo.bar', 'foo.baz', 'foo', 'bar') as $t)
17 * {
18 * if (/$regex/) echo "matched: $car\n";
19 * }
20 *
21 * Glob implements glob(3) style matching that can be used to match
22 * against text, rather than fetching names from a filesystem.
23 *
24 * Based on the Perl Text::Glob module.
25 *
26 * @author Fabien Potencier <fabien@symfony.com> PHP port
27 * @author Richard Clamp <richardc@unixbeard.net> Perl version
28 * @copyright 2004-2005 Fabien Potencier <fabien@symfony.com>
29 * @copyright 2002 Richard Clamp <richardc@unixbeard.net>
30 */
31 class Glob
32 {
33
34
35
36
37
38
39
40
41
42
43 public static function toRegex($glob, $strictLeadingDot = \true, $strictWildcardSlash = \true, $delimiter = '#')
44 {
45 $firstByte = \true;
46 $escaping = \false;
47 $inCurlies = 0;
48 $regex = '';
49 $sizeGlob = \strlen($glob);
50 for ($i = 0; $i < $sizeGlob; ++$i) {
51 $car = $glob[$i];
52 if ($firstByte) {
53 if ($strictLeadingDot && '.' !== $car) {
54 $regex .= '(?=[^\\.])';
55 }
56
57 $firstByte = \false;
58 }
59
60 if ('/' === $car) {
61 $firstByte = \true;
62 }
63
64 if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
65 $regex .= "\\{$car}";
66 } elseif ('*' === $car) {
67 $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
68 } elseif ('?' === $car) {
69 $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
70 } elseif ('{' === $car) {
71 $regex .= $escaping ? '\\{' : '(';
72 if (!$escaping) {
73 ++$inCurlies;
74 }
75 } elseif ('}' === $car && $inCurlies) {
76 $regex .= $escaping ? '}' : ')';
77 if (!$escaping) {
78 --$inCurlies;
79 }
80 } elseif (',' === $car && $inCurlies) {
81 $regex .= $escaping ? ',' : '|';
82 } elseif ('\\' === $car) {
83 if ($escaping) {
84 $regex .= '\\\\';
85 $escaping = \false;
86 } else {
87 $escaping = \true;
88 }
89 continue;
90 } else {
91 $regex .= $car;
92 }
93 $escaping = \false;
94 }
95
96 return $delimiter . '^' . $regex . '$' . $delimiter;
97 }
98 }
99