Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/MWP/Action/Incremen...
File: Abstract.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* This file is part of the ManageWP Worker plugin.
[2] Fix | Delete
*
[3] Fix | Delete
* (c) ManageWP LLC <contact@managewp.com>
[4] Fix | Delete
*
[5] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[6] Fix | Delete
* file that was distributed with this source code.
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
class MWP_Action_IncrementalBackup_Abstract extends MWP_Action_Abstract
[10] Fix | Delete
{
[11] Fix | Delete
/**
[12] Fix | Delete
* @param array $result
[13] Fix | Delete
*
[14] Fix | Delete
* @return array
[15] Fix | Delete
*/
[16] Fix | Delete
protected function createResult(array $result)
[17] Fix | Delete
{
[18] Fix | Delete
return array(
[19] Fix | Delete
'result' => $result,
[20] Fix | Delete
'server' => $this->getServerStatistics()->toArray(),
[21] Fix | Delete
);
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Get file real path given a path relative to WordPress root.
[26] Fix | Delete
*
[27] Fix | Delete
* @param string $relativePath
[28] Fix | Delete
*
[29] Fix | Delete
* @param bool $virtual Don't do real filesystem touch, simulate instead
[30] Fix | Delete
*
[31] Fix | Delete
* @return string
[32] Fix | Delete
*/
[33] Fix | Delete
protected function getRealPath($relativePath, $virtual = false)
[34] Fix | Delete
{
[35] Fix | Delete
if ($virtual) {
[36] Fix | Delete
return $this->virtualGetAbsolutePath(untrailingslashit(ABSPATH).'/'.$relativePath);
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
return realpath(untrailingslashit(ABSPATH).'/'.$relativePath);
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* @return MWP_IncrementalBackup_Model_ServerStatistics
[44] Fix | Delete
*/
[45] Fix | Delete
private function getServerStatistics()
[46] Fix | Delete
{
[47] Fix | Delete
return MWP_IncrementalBackup_Model_ServerStatistics::factory();
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* @param string $path
[52] Fix | Delete
*
[53] Fix | Delete
* @return string
[54] Fix | Delete
*/
[55] Fix | Delete
private function virtualGetAbsolutePath($path)
[56] Fix | Delete
{
[57] Fix | Delete
$originalPath = $path;
[58] Fix | Delete
[59] Fix | Delete
$isWindows = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
[60] Fix | Delete
[61] Fix | Delete
if ($isWindows) {
[62] Fix | Delete
$path = str_replace('\\', '/', $path);
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
$parts = array_filter(explode('/', $path), 'strlen');
[66] Fix | Delete
$absolutes = array();
[67] Fix | Delete
foreach ($parts as $part) {
[68] Fix | Delete
if ('.' == $part) {
[69] Fix | Delete
continue;
[70] Fix | Delete
}
[71] Fix | Delete
if ('..' == $part) {
[72] Fix | Delete
array_pop($absolutes);
[73] Fix | Delete
} else {
[74] Fix | Delete
$absolutes[] = $part;
[75] Fix | Delete
}
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
if (strpos($originalPath, '\\\\') === 0) { // NAS mount
[79] Fix | Delete
return '//'.implode(DIRECTORY_SEPARATOR, $absolutes);
[80] Fix | Delete
} elseif (strpos($path, '/') === 0) {
[81] Fix | Delete
return '/'.implode(DIRECTORY_SEPARATOR, $absolutes);
[82] Fix | Delete
} else {
[83] Fix | Delete
return implode(DIRECTORY_SEPARATOR, $absolutes);
[84] Fix | Delete
}
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function