PluginProbe
ManageWP Worker / 4.9.35
ManageWP Worker v4.9.35
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / src / MWP / Action / IncrementalBackup / AbstractFiles.php

AbstractFiles.php in ManageWP Worker 4.9.35, at src/MWP/Action/IncrementalBackup/AbstractFiles.php

85 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * This file is part of the ManageWP Worker plugin.
4 *
5 * (c) ManageWP LLC <[email protected]>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11 class MWP_Action_IncrementalBackup_AbstractFiles extends MWP_Action_IncrementalBackup_Abstract
12 {
13
14 /** @var bool */
15 protected $isWindows;
16
17 public function __construct()
18 {
19 $this->isWindows = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
20 }
21
22 /**
23 * Replace Windows \\ with / on set of files
24 *
25 * @param $files
26 *
27 * @return array
28 */
29 protected function replaceWindowsPaths($files)
30 {
31 if ($this->isWindows) {
32 foreach ($files as $key => $file) {
33 $files[$key]['path'] = str_replace('\\', '/', $file['path']);
34 }
35 }
36
37 return $files;
38 }
39
40 /**
41 * Replace Windows \\ with /
42 *
43 * @param $path
44 *
45 * @return string
46 */
47 protected function replaceWindowsPath($path)
48 {
49 if ($this->isWindows) {
50 $path = str_replace('\\', '/', $path);
51 }
52
53 return $path;
54 }
55
56 /**
57 * Return encoded path for user across systems
58 *
59 * @param $path
60 *
61 * @return string
62 */
63 protected function pathEncode($path)
64 {
65 $split = explode('/', $path);
66 $encodedPaths = array_map("urlencode", $split);
67 $encodedPath = implode('/', $encodedPaths);
68
69 return $encodedPath;
70 }
71
72 /**
73 * Return decoded path
74 *
75 * @param $path
76 *
77 * @return string
78 */
79 protected function pathDecode($path)
80 {
81
82 return urldecode($path);
83 }
84 }
85