Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/php
File: elFinderVolumeLocalFileSystem.class.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// Implement similar functionality in PHP 5.2 or 5.3
[2] Fix | Delete
// http://php.net/manual/class.recursivecallbackfilteriterator.php#110974
[3] Fix | Delete
if (!class_exists('RecursiveCallbackFilterIterator', false)) {
[4] Fix | Delete
class RecursiveCallbackFilterIterator extends RecursiveFilterIterator
[5] Fix | Delete
{
[6] Fix | Delete
private $callback;
[7] Fix | Delete
[8] Fix | Delete
public function __construct(RecursiveIterator $iterator, $callback)
[9] Fix | Delete
{
[10] Fix | Delete
$this->callback = $callback;
[11] Fix | Delete
parent::__construct($iterator);
[12] Fix | Delete
}
[13] Fix | Delete
[14] Fix | Delete
public function accept()
[15] Fix | Delete
{
[16] Fix | Delete
return call_user_func($this->callback, parent::current(), parent::key(), parent::getInnerIterator());
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
public function getChildren()
[20] Fix | Delete
{
[21] Fix | Delete
return new self($this->getInnerIterator()->getChildren(), $this->callback);
[22] Fix | Delete
}
[23] Fix | Delete
}
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* elFinder driver for local filesystem.
[28] Fix | Delete
*
[29] Fix | Delete
* @author Dmitry (dio) Levashov
[30] Fix | Delete
* @author Troex Nevelin
[31] Fix | Delete
**/
[32] Fix | Delete
class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver
[33] Fix | Delete
{
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Driver id
[37] Fix | Delete
* Must be started from letter and contains [a-z0-9]
[38] Fix | Delete
* Used as part of volume id
[39] Fix | Delete
*
[40] Fix | Delete
* @var string
[41] Fix | Delete
**/
[42] Fix | Delete
protected $driverId = 'l';
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Required to count total archive files size
[46] Fix | Delete
*
[47] Fix | Delete
* @var int
[48] Fix | Delete
**/
[49] Fix | Delete
protected $archiveSize = 0;
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Is checking stat owner
[53] Fix | Delete
*
[54] Fix | Delete
* @var boolean
[55] Fix | Delete
*/
[56] Fix | Delete
protected $statOwner = false;
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Path to quarantine directory
[60] Fix | Delete
*
[61] Fix | Delete
* @var string
[62] Fix | Delete
*/
[63] Fix | Delete
private $quarantine;
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Constructor
[67] Fix | Delete
* Extend options with required fields
[68] Fix | Delete
*
[69] Fix | Delete
* @author Dmitry (dio) Levashov
[70] Fix | Delete
*/
[71] Fix | Delete
public function __construct()
[72] Fix | Delete
{
[73] Fix | Delete
$this->options['alias'] = ''; // alias to replace root dir name
[74] Fix | Delete
$this->options['dirMode'] = 0755; // new dirs mode
[75] Fix | Delete
$this->options['fileMode'] = 0644; // new files mode
[76] Fix | Delete
$this->options['rootCssClass'] = 'elfinder-navbar-root-local';
[77] Fix | Delete
$this->options['followSymLinks'] = true;
[78] Fix | Delete
$this->options['detectDirIcon'] = ''; // file name that is detected as a folder icon e.g. '.diricon.png'
[79] Fix | Delete
$this->options['keepTimestamp'] = array('copy', 'move'); // keep timestamp at inner filesystem allowed 'copy', 'move' and 'upload'
[80] Fix | Delete
$this->options['substituteImg'] = true; // support substitute image with dim command
[81] Fix | Delete
$this->options['statCorrector'] = null; // callable to correct stat data `function(&$stat, $path, $statOwner, $volumeDriveInstance){}`
[82] Fix | Delete
if (DIRECTORY_SEPARATOR === '/') {
[83] Fix | Delete
// Linux
[84] Fix | Delete
$this->options['acceptedName'] = '/^[^\.\/\x00][^\/\x00]*$/';
[85] Fix | Delete
} else {
[86] Fix | Delete
// Windows
[87] Fix | Delete
$this->options['acceptedName'] = '/^[^\.\/\x00\\\:*?"<>|][^\/\x00\\\:*?"<>|]*$/';
[88] Fix | Delete
}
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
/*********************************************************************/
[92] Fix | Delete
/* INIT AND CONFIGURE */
[93] Fix | Delete
/*********************************************************************/
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Prepare driver before mount volume.
[97] Fix | Delete
* Return true if volume is ready.
[98] Fix | Delete
*
[99] Fix | Delete
* @return bool
[100] Fix | Delete
**/
[101] Fix | Delete
protected function init()
[102] Fix | Delete
{
[103] Fix | Delete
// Normalize directory separator for windows
[104] Fix | Delete
if (DIRECTORY_SEPARATOR !== '/') {
[105] Fix | Delete
foreach (array('path', 'tmbPath', 'tmpPath', 'quarantine') as $key) {
[106] Fix | Delete
if (!empty($this->options[$key])) {
[107] Fix | Delete
$this->options[$key] = str_replace('/', DIRECTORY_SEPARATOR, $this->options[$key]);
[108] Fix | Delete
}
[109] Fix | Delete
}
[110] Fix | Delete
// PHP >= 7.1 Supports UTF-8 path on Windows
[111] Fix | Delete
if (version_compare(PHP_VERSION, '7.1', '>=')) {
[112] Fix | Delete
$this->options['encoding'] = '';
[113] Fix | Delete
$this->options['locale'] = '';
[114] Fix | Delete
}
[115] Fix | Delete
}
[116] Fix | Delete
if (!$cwd = getcwd()) {
[117] Fix | Delete
return $this->setError('elFinder LocalVolumeDriver requires a result of getcwd().');
[118] Fix | Delete
}
[119] Fix | Delete
// detect systemRoot
[120] Fix | Delete
if (!isset($this->options['systemRoot'])) {
[121] Fix | Delete
if ($cwd[0] === DIRECTORY_SEPARATOR || $this->root[0] === DIRECTORY_SEPARATOR) {
[122] Fix | Delete
$this->systemRoot = DIRECTORY_SEPARATOR;
[123] Fix | Delete
} else if (preg_match('/^([a-zA-Z]:' . preg_quote(DIRECTORY_SEPARATOR, '/') . ')/', $this->root, $m)) {
[124] Fix | Delete
$this->systemRoot = $m[1];
[125] Fix | Delete
} else if (preg_match('/^([a-zA-Z]:' . preg_quote(DIRECTORY_SEPARATOR, '/') . ')/', $cwd, $m)) {
[126] Fix | Delete
$this->systemRoot = $m[1];
[127] Fix | Delete
}
[128] Fix | Delete
}
[129] Fix | Delete
$this->root = $this->getFullPath($this->root, $cwd);
[130] Fix | Delete
if (!empty($this->options['startPath'])) {
[131] Fix | Delete
$this->options['startPath'] = $this->getFullPath($this->options['startPath'], $this->root);
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
if (is_null($this->options['syncChkAsTs'])) {
[135] Fix | Delete
$this->options['syncChkAsTs'] = true;
[136] Fix | Delete
}
[137] Fix | Delete
if (is_null($this->options['syncCheckFunc'])) {
[138] Fix | Delete
$this->options['syncCheckFunc'] = array($this, 'localFileSystemInotify');
[139] Fix | Delete
}
[140] Fix | Delete
// check 'statCorrector'
[141] Fix | Delete
if (empty($this->options['statCorrector']) || !is_callable($this->options['statCorrector'])) {
[142] Fix | Delete
$this->options['statCorrector'] = null;
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
return true;
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Configure after successfull mount.
[150] Fix | Delete
*
[151] Fix | Delete
* @return void
[152] Fix | Delete
* @throws elFinderAbortException
[153] Fix | Delete
* @author Dmitry (dio) Levashov
[154] Fix | Delete
*/
[155] Fix | Delete
protected function configure()
[156] Fix | Delete
{
[157] Fix | Delete
$hiddens = array();
[158] Fix | Delete
$root = $this->stat($this->root);
[159] Fix | Delete
[160] Fix | Delete
// check thumbnails path
[161] Fix | Delete
if (!empty($this->options['tmbPath'])) {
[162] Fix | Delete
if (strpos($this->options['tmbPath'], DIRECTORY_SEPARATOR) === false) {
[163] Fix | Delete
$hiddens['tmb'] = $this->options['tmbPath'];
[164] Fix | Delete
$this->options['tmbPath'] = $this->_abspath($this->options['tmbPath']);
[165] Fix | Delete
} else {
[166] Fix | Delete
$this->options['tmbPath'] = $this->_normpath($this->options['tmbPath']);
[167] Fix | Delete
}
[168] Fix | Delete
}
[169] Fix | Delete
// check temp path
[170] Fix | Delete
if (!empty($this->options['tmpPath'])) {
[171] Fix | Delete
if (strpos($this->options['tmpPath'], DIRECTORY_SEPARATOR) === false) {
[172] Fix | Delete
$hiddens['temp'] = $this->options['tmpPath'];
[173] Fix | Delete
$this->options['tmpPath'] = $this->_abspath($this->options['tmpPath']);
[174] Fix | Delete
} else {
[175] Fix | Delete
$this->options['tmpPath'] = $this->_normpath($this->options['tmpPath']);
[176] Fix | Delete
}
[177] Fix | Delete
}
[178] Fix | Delete
// check quarantine path
[179] Fix | Delete
$_quarantine = '';
[180] Fix | Delete
if (!empty($this->options['quarantine'])) {
[181] Fix | Delete
if (strpos($this->options['quarantine'], DIRECTORY_SEPARATOR) === false) {
[182] Fix | Delete
$_quarantine = $this->_abspath($this->options['quarantine']);
[183] Fix | Delete
$this->options['quarantine'] = '';
[184] Fix | Delete
} else {
[185] Fix | Delete
$this->options['quarantine'] = $this->_normpath($this->options['quarantine']);
[186] Fix | Delete
}
[187] Fix | Delete
} else {
[188] Fix | Delete
$_quarantine = $this->_abspath('.quarantine');
[189] Fix | Delete
}
[190] Fix | Delete
is_dir($_quarantine) && self::localRmdirRecursive($_quarantine);
[191] Fix | Delete
[192] Fix | Delete
parent::configure();
[193] Fix | Delete
[194] Fix | Delete
// check tmbPath
[195] Fix | Delete
if (!$this->tmbPath && isset($hiddens['tmb'])) {
[196] Fix | Delete
unset($hiddens['tmb']);
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
// if no thumbnails url - try detect it
[200] Fix | Delete
if ($root['read'] && !$this->tmbURL && $this->URL) {
[201] Fix | Delete
if (strpos($this->tmbPath, $this->root) === 0) {
[202] Fix | Delete
$this->tmbURL = $this->URL . str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1));
[203] Fix | Delete
if (preg_match("|[^/?&=]$|", $this->tmbURL)) {
[204] Fix | Delete
$this->tmbURL .= '/';
[205] Fix | Delete
}
[206] Fix | Delete
}
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
// set $this->tmp by options['tmpPath']
[210] Fix | Delete
$this->tmp = '';
[211] Fix | Delete
if (!empty($this->options['tmpPath'])) {
[212] Fix | Delete
if ((is_dir($this->options['tmpPath']) || mkdir($this->options['tmpPath'], $this->options['dirMode'], true)) && is_writable($this->options['tmpPath'])) {
[213] Fix | Delete
$this->tmp = $this->options['tmpPath'];
[214] Fix | Delete
} else {
[215] Fix | Delete
if (isset($hiddens['temp'])) {
[216] Fix | Delete
unset($hiddens['temp']);
[217] Fix | Delete
}
[218] Fix | Delete
}
[219] Fix | Delete
}
[220] Fix | Delete
if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
[221] Fix | Delete
$this->tmp = $tmp;
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
// check quarantine dir
[225] Fix | Delete
$this->quarantine = '';
[226] Fix | Delete
if (!empty($this->options['quarantine'])) {
[227] Fix | Delete
if ((is_dir($this->options['quarantine']) || mkdir($this->options['quarantine'], $this->options['dirMode'], true)) && is_writable($this->options['quarantine'])) {
[228] Fix | Delete
$this->quarantine = $this->options['quarantine'];
[229] Fix | Delete
} else {
[230] Fix | Delete
if (isset($hiddens['quarantine'])) {
[231] Fix | Delete
unset($hiddens['quarantine']);
[232] Fix | Delete
}
[233] Fix | Delete
}
[234] Fix | Delete
} else if ($_path = elFinder::getCommonTempPath()) {
[235] Fix | Delete
$this->quarantine = $_path;
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
if (!$this->quarantine) {
[239] Fix | Delete
if (!$this->tmp) {
[240] Fix | Delete
$this->archivers['extract'] = array();
[241] Fix | Delete
$this->disabled[] = 'extract';
[242] Fix | Delete
} else {
[243] Fix | Delete
$this->quarantine = $this->tmp;
[244] Fix | Delete
}
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
if ($hiddens) {
[248] Fix | Delete
foreach ($hiddens as $hidden) {
[249] Fix | Delete
$this->attributes[] = array(
[250] Fix | Delete
'pattern' => '~^' . preg_quote(DIRECTORY_SEPARATOR . $hidden, '~') . '$~',
[251] Fix | Delete
'read' => false,
[252] Fix | Delete
'write' => false,
[253] Fix | Delete
'locked' => true,
[254] Fix | Delete
'hidden' => true
[255] Fix | Delete
);
[256] Fix | Delete
}
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
if (!empty($this->options['keepTimestamp'])) {
[260] Fix | Delete
$this->options['keepTimestamp'] = array_flip($this->options['keepTimestamp']);
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
$this->statOwner = (!empty($this->options['statOwner']));
[264] Fix | Delete
[265] Fix | Delete
// enable WinRemoveTailDots plugin on Windows server
[266] Fix | Delete
if (DIRECTORY_SEPARATOR !== '/') {
[267] Fix | Delete
if (!isset($this->options['plugin'])) {
[268] Fix | Delete
$this->options['plugin'] = array();
[269] Fix | Delete
}
[270] Fix | Delete
$this->options['plugin']['WinRemoveTailDots'] = array('enable' => true);
[271] Fix | Delete
}
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
/**
[275] Fix | Delete
* Long pooling sync checker
[276] Fix | Delete
* This function require server command `inotifywait`
[277] Fix | Delete
* If `inotifywait` need full path, Please add `define('ELFINER_INOTIFYWAIT_PATH', '/PATH_TO/inotifywait');` into connector.php
[278] Fix | Delete
*
[279] Fix | Delete
* @param string $path
[280] Fix | Delete
* @param int $standby
[281] Fix | Delete
* @param number $compare
[282] Fix | Delete
*
[283] Fix | Delete
* @return number|bool
[284] Fix | Delete
* @throws elFinderAbortException
[285] Fix | Delete
*/
[286] Fix | Delete
public function localFileSystemInotify($path, $standby, $compare)
[287] Fix | Delete
{
[288] Fix | Delete
if (isset($this->sessionCache['localFileSystemInotify_disable'])) {
[289] Fix | Delete
return false;
[290] Fix | Delete
}
[291] Fix | Delete
$path = realpath($path);
[292] Fix | Delete
$mtime = filemtime($path);
[293] Fix | Delete
if (!$mtime) {
[294] Fix | Delete
return false;
[295] Fix | Delete
}
[296] Fix | Delete
if ($mtime != $compare) {
[297] Fix | Delete
return $mtime;
[298] Fix | Delete
}
[299] Fix | Delete
$inotifywait = defined('ELFINER_INOTIFYWAIT_PATH') ? ELFINER_INOTIFYWAIT_PATH : 'inotifywait';
[300] Fix | Delete
$standby = max(1, intval($standby));
[301] Fix | Delete
$cmd = $inotifywait . ' ' . escapeshellarg($path) . ' -t ' . $standby . ' -e moved_to,moved_from,move,close_write,delete,delete_self';
[302] Fix | Delete
$this->procExec($cmd, $o, $r);
[303] Fix | Delete
if ($r === 0) {
[304] Fix | Delete
// changed
[305] Fix | Delete
clearstatcache();
[306] Fix | Delete
if (file_exists($path)) {
[307] Fix | Delete
$mtime = filemtime($path); // error on busy?
[308] Fix | Delete
return $mtime ? $mtime : time();
[309] Fix | Delete
} else {
[310] Fix | Delete
// target was removed
[311] Fix | Delete
return 0;
[312] Fix | Delete
}
[313] Fix | Delete
} else if ($r === 2) {
[314] Fix | Delete
// not changed (timeout)
[315] Fix | Delete
return $compare;
[316] Fix | Delete
}
[317] Fix | Delete
// error
[318] Fix | Delete
// cache to $_SESSION
[319] Fix | Delete
$this->sessionCache['localFileSystemInotify_disable'] = true;
[320] Fix | Delete
$this->session->set($this->id, $this->sessionCache);
[321] Fix | Delete
return false;
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
/*********************************************************************/
[325] Fix | Delete
/* FS API */
[326] Fix | Delete
/*********************************************************************/
[327] Fix | Delete
[328] Fix | Delete
/*********************** paths/urls *************************/
[329] Fix | Delete
[330] Fix | Delete
/**
[331] Fix | Delete
* Return parent directory path
[332] Fix | Delete
*
[333] Fix | Delete
* @param string $path file path
[334] Fix | Delete
*
[335] Fix | Delete
* @return string
[336] Fix | Delete
* @author Dmitry (dio) Levashov
[337] Fix | Delete
**/
[338] Fix | Delete
protected function _dirname($path)
[339] Fix | Delete
{
[340] Fix | Delete
return dirname($path);
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
/**
[344] Fix | Delete
* Return file name
[345] Fix | Delete
*
[346] Fix | Delete
* @param string $path file path
[347] Fix | Delete
*
[348] Fix | Delete
* @return string
[349] Fix | Delete
* @author Dmitry (dio) Levashov
[350] Fix | Delete
**/
[351] Fix | Delete
protected function _basename($path)
[352] Fix | Delete
{
[353] Fix | Delete
return basename($path);
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
/**
[357] Fix | Delete
* Join dir name and file name and retur full path
[358] Fix | Delete
*
[359] Fix | Delete
* @param string $dir
[360] Fix | Delete
* @param string $name
[361] Fix | Delete
*
[362] Fix | Delete
* @return string
[363] Fix | Delete
* @author Dmitry (dio) Levashov
[364] Fix | Delete
**/
[365] Fix | Delete
protected function _joinPath($dir, $name)
[366] Fix | Delete
{
[367] Fix | Delete
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
[368] Fix | Delete
$path = realpath($dir . DIRECTORY_SEPARATOR . $name);
[369] Fix | Delete
// realpath() returns FALSE if the file does not exist
[370] Fix | Delete
if ($path === false || strpos($path, $this->root) !== 0) {
[371] Fix | Delete
if (DIRECTORY_SEPARATOR !== '/') {
[372] Fix | Delete
$dir = str_replace('/', DIRECTORY_SEPARATOR, $dir);
[373] Fix | Delete
$name = str_replace('/', DIRECTORY_SEPARATOR, $name);
[374] Fix | Delete
}
[375] Fix | Delete
// Directory traversal measures
[376] Fix | Delete
if (strpos($dir, '..' . DIRECTORY_SEPARATOR) !== false || substr($dir, -2) == '..') {
[377] Fix | Delete
$dir = $this->root;
[378] Fix | Delete
}
[379] Fix | Delete
if (strpos($name, '..' . DIRECTORY_SEPARATOR) !== false) {
[380] Fix | Delete
$name = basename($name);
[381] Fix | Delete
}
[382] Fix | Delete
$path = $dir . DIRECTORY_SEPARATOR . $name;
[383] Fix | Delete
}
[384] Fix | Delete
return $path;
[385] Fix | Delete
}
[386] Fix | Delete
[387] Fix | Delete
/**
[388] Fix | Delete
* Return normalized path, this works the same as os.path.normpath() in Python
[389] Fix | Delete
*
[390] Fix | Delete
* @param string $path path
[391] Fix | Delete
*
[392] Fix | Delete
* @return string
[393] Fix | Delete
* @author Troex Nevelin
[394] Fix | Delete
**/
[395] Fix | Delete
protected function _normpath($path)
[396] Fix | Delete
{
[397] Fix | Delete
if (empty($path)) {
[398] Fix | Delete
return '.';
[399] Fix | Delete
}
[400] Fix | Delete
[401] Fix | Delete
$changeSep = (DIRECTORY_SEPARATOR !== '/');
[402] Fix | Delete
if ($changeSep) {
[403] Fix | Delete
$drive = '';
[404] Fix | Delete
if (preg_match('/^([a-zA-Z]:)(.*)/', $path, $m)) {
[405] Fix | Delete
$drive = $m[1];
[406] Fix | Delete
$path = $m[2] ? $m[2] : '/';
[407] Fix | Delete
}
[408] Fix | Delete
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
if (strpos($path, '/') === 0) {
[412] Fix | Delete
$initial_slashes = true;
[413] Fix | Delete
} else {
[414] Fix | Delete
$initial_slashes = false;
[415] Fix | Delete
}
[416] Fix | Delete
[417] Fix | Delete
if (($initial_slashes)
[418] Fix | Delete
&& (strpos($path, '//') === 0)
[419] Fix | Delete
&& (strpos($path, '///') === false)) {
[420] Fix | Delete
$initial_slashes = 2;
[421] Fix | Delete
}
[422] Fix | Delete
[423] Fix | Delete
$initial_slashes = (int)$initial_slashes;
[424] Fix | Delete
[425] Fix | Delete
$comps = explode('/', $path);
[426] Fix | Delete
$new_comps = array();
[427] Fix | Delete
foreach ($comps as $comp) {
[428] Fix | Delete
if (in_array($comp, array('', '.'))) {
[429] Fix | Delete
continue;
[430] Fix | Delete
}
[431] Fix | Delete
[432] Fix | Delete
if (($comp != '..')
[433] Fix | Delete
|| (!$initial_slashes && !$new_comps)
[434] Fix | Delete
|| ($new_comps && (end($new_comps) == '..'))) {
[435] Fix | Delete
array_push($new_comps, $comp);
[436] Fix | Delete
} elseif ($new_comps) {
[437] Fix | Delete
array_pop($new_comps);
[438] Fix | Delete
}
[439] Fix | Delete
}
[440] Fix | Delete
$comps = $new_comps;
[441] Fix | Delete
$path = implode('/', $comps);
[442] Fix | Delete
if ($initial_slashes) {
[443] Fix | Delete
$path = str_repeat('/', $initial_slashes) . $path;
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
if ($changeSep) {
[447] Fix | Delete
$path = $drive . str_replace('/', DIRECTORY_SEPARATOR, $path);
[448] Fix | Delete
}
[449] Fix | Delete
[450] Fix | Delete
return $path ? $path : '.';
[451] Fix | Delete
}
[452] Fix | Delete
[453] Fix | Delete
/**
[454] Fix | Delete
* Return file path related to root dir
[455] Fix | Delete
*
[456] Fix | Delete
* @param string $path file path
[457] Fix | Delete
*
[458] Fix | Delete
* @return string
[459] Fix | Delete
* @author Dmitry (dio) Levashov
[460] Fix | Delete
**/
[461] Fix | Delete
protected function _relpath($path)
[462] Fix | Delete
{
[463] Fix | Delete
if ($path === $this->root) {
[464] Fix | Delete
return '';
[465] Fix | Delete
} else {
[466] Fix | Delete
if (strpos($path, $this->root) === 0) {
[467] Fix | Delete
return ltrim(substr($path, strlen($this->root)), DIRECTORY_SEPARATOR);
[468] Fix | Delete
} else {
[469] Fix | Delete
// for link
[470] Fix | Delete
return $path;
[471] Fix | Delete
}
[472] Fix | Delete
}
[473] Fix | Delete
}
[474] Fix | Delete
[475] Fix | Delete
/**
[476] Fix | Delete
* Convert path related to root dir into real path
[477] Fix | Delete
*
[478] Fix | Delete
* @param string $path file path
[479] Fix | Delete
*
[480] Fix | Delete
* @return string
[481] Fix | Delete
* @author Dmitry (dio) Levashov
[482] Fix | Delete
**/
[483] Fix | Delete
protected function _abspath($path)
[484] Fix | Delete
{
[485] Fix | Delete
if ($path === DIRECTORY_SEPARATOR) {
[486] Fix | Delete
return $this->root;
[487] Fix | Delete
} else {
[488] Fix | Delete
$path = $this->_normpath($path);
[489] Fix | Delete
if (strpos($path, $this->systemRoot) === 0) {
[490] Fix | Delete
return $path;
[491] Fix | Delete
} else if (DIRECTORY_SEPARATOR !== '/' && preg_match('/^[a-zA-Z]:' . preg_quote(DIRECTORY_SEPARATOR, '/') . '/', $path)) {
[492] Fix | Delete
return $path;
[493] Fix | Delete
} else {
[494] Fix | Delete
return $this->_joinPath($this->root, $path);
[495] Fix | Delete
}
[496] Fix | Delete
}
[497] Fix | Delete
}
[498] Fix | Delete
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function