Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/php
File: elFinderVolumeFTP.class.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Simple elFinder driver for FTP
[3] Fix | Delete
*
[4] Fix | Delete
* @author Dmitry (dio) Levashov
[5] Fix | Delete
* @author Cem (discofever)
[6] Fix | Delete
**/
[7] Fix | Delete
class elFinderVolumeFTP extends elFinderVolumeDriver
[8] Fix | Delete
{
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Driver id
[12] Fix | Delete
* Must be started from letter and contains [a-z0-9]
[13] Fix | Delete
* Used as part of volume id
[14] Fix | Delete
*
[15] Fix | Delete
* @var string
[16] Fix | Delete
**/
[17] Fix | Delete
protected $driverId = 'f';
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* FTP Connection Instance
[21] Fix | Delete
*
[22] Fix | Delete
* @var resource a FTP stream
[23] Fix | Delete
**/
[24] Fix | Delete
protected $connect = null;
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Directory for tmp files
[28] Fix | Delete
* If not set driver will try to use tmbDir as tmpDir
[29] Fix | Delete
*
[30] Fix | Delete
* @var string
[31] Fix | Delete
**/
[32] Fix | Delete
protected $tmpPath = '';
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Last FTP error message
[36] Fix | Delete
*
[37] Fix | Delete
* @var string
[38] Fix | Delete
**/
[39] Fix | Delete
protected $ftpError = '';
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* FTP server output list as ftp on linux
[43] Fix | Delete
*
[44] Fix | Delete
* @var bool
[45] Fix | Delete
**/
[46] Fix | Delete
protected $ftpOsUnix;
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* FTP LIST command option
[50] Fix | Delete
*
[51] Fix | Delete
* @var string
[52] Fix | Delete
*/
[53] Fix | Delete
protected $ftpListOption = '-al';
[54] Fix | Delete
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Is connected server Pure FTPd?
[58] Fix | Delete
*
[59] Fix | Delete
* @var bool
[60] Fix | Delete
*/
[61] Fix | Delete
protected $isPureFtpd = false;
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Is connected server with FTPS?
[65] Fix | Delete
*
[66] Fix | Delete
* @var bool
[67] Fix | Delete
*/
[68] Fix | Delete
protected $isFTPS = false;
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Tmp folder path
[72] Fix | Delete
*
[73] Fix | Delete
* @var string
[74] Fix | Delete
**/
[75] Fix | Delete
protected $tmp = '';
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* FTP command `MLST` support
[79] Fix | Delete
*
[80] Fix | Delete
* @var bool
[81] Fix | Delete
*/
[82] Fix | Delete
private $MLSTsupprt = false;
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Calling cacheDir() target path with non-MLST
[86] Fix | Delete
*
[87] Fix | Delete
* @var string
[88] Fix | Delete
*/
[89] Fix | Delete
private $cacheDirTarget = '';
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* Constructor
[93] Fix | Delete
* Extend options with required fields
[94] Fix | Delete
*
[95] Fix | Delete
* @author Dmitry (dio) Levashov
[96] Fix | Delete
* @author Cem (DiscoFever)
[97] Fix | Delete
*/
[98] Fix | Delete
public function __construct()
[99] Fix | Delete
{
[100] Fix | Delete
$opts = array(
[101] Fix | Delete
'host' => 'localhost',
[102] Fix | Delete
'user' => '',
[103] Fix | Delete
'pass' => '',
[104] Fix | Delete
'port' => 21,
[105] Fix | Delete
'mode' => 'passive',
[106] Fix | Delete
'ssl' => false,
[107] Fix | Delete
'path' => '/',
[108] Fix | Delete
'timeout' => 20,
[109] Fix | Delete
'owner' => true,
[110] Fix | Delete
'tmbPath' => '',
[111] Fix | Delete
'tmpPath' => '',
[112] Fix | Delete
'separator' => '/',
[113] Fix | Delete
'checkSubfolders' => -1,
[114] Fix | Delete
'dirMode' => 0755,
[115] Fix | Delete
'fileMode' => 0644,
[116] Fix | Delete
'rootCssClass' => 'elfinder-navbar-root-ftp',
[117] Fix | Delete
'ftpListOption' => '-al',
[118] Fix | Delete
);
[119] Fix | Delete
$this->options = array_merge($this->options, $opts);
[120] Fix | Delete
$this->options['mimeDetect'] = 'internal';
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* Prepare
[125] Fix | Delete
* Call from elFinder::netmout() before volume->mount()
[126] Fix | Delete
*
[127] Fix | Delete
* @param $options
[128] Fix | Delete
*
[129] Fix | Delete
* @return array volume root options
[130] Fix | Delete
* @author Naoki Sawada
[131] Fix | Delete
*/
[132] Fix | Delete
public function netmountPrepare($options)
[133] Fix | Delete
{
[134] Fix | Delete
if (!empty($_REQUEST['encoding']) && iconv('UTF-8', $_REQUEST['encoding'], '') !== false) {
[135] Fix | Delete
$options['encoding'] = $_REQUEST['encoding'];
[136] Fix | Delete
if (!empty($_REQUEST['locale']) && setlocale(LC_ALL, $_REQUEST['locale'])) {
[137] Fix | Delete
setlocale(LC_ALL, elFinder::$locale);
[138] Fix | Delete
$options['locale'] = $_REQUEST['locale'];
[139] Fix | Delete
}
[140] Fix | Delete
}
[141] Fix | Delete
if (!empty($_REQUEST['FTPS'])) {
[142] Fix | Delete
$options['ssl'] = true;
[143] Fix | Delete
}
[144] Fix | Delete
$options['statOwner'] = true;
[145] Fix | Delete
$options['allowChmodReadOnly'] = true;
[146] Fix | Delete
$options['acceptedName'] = '#^[^/\\?*:|"<>]*[^./\\?*:|"<>]$#';
[147] Fix | Delete
return $options;
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
/*********************************************************************/
[151] Fix | Delete
/* INIT AND CONFIGURE */
[152] Fix | Delete
/*********************************************************************/
[153] Fix | Delete
[154] Fix | Delete
/**
[155] Fix | Delete
* Prepare FTP connection
[156] Fix | Delete
* Connect to remote server and check if credentials are correct, if so, store the connection id in $ftp_conn
[157] Fix | Delete
*
[158] Fix | Delete
* @return bool
[159] Fix | Delete
* @author Dmitry (dio) Levashov
[160] Fix | Delete
* @author Cem (DiscoFever)
[161] Fix | Delete
**/
[162] Fix | Delete
protected function init()
[163] Fix | Delete
{
[164] Fix | Delete
if (!$this->options['host']
[165] Fix | Delete
|| !$this->options['port']) {
[166] Fix | Delete
return $this->setError('Required options undefined.');
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
if (!$this->options['user']) {
[170] Fix | Delete
$this->options['user'] = 'anonymous';
[171] Fix | Delete
$this->options['pass'] = '';
[172] Fix | Delete
}
[173] Fix | Delete
if (!$this->options['path']) {
[174] Fix | Delete
$this->options['path'] = '/';
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
// make ney mount key
[178] Fix | Delete
$this->netMountKey = md5(join('-', array('ftp', $this->options['host'], $this->options['port'], $this->options['path'], $this->options['user'])));
[179] Fix | Delete
[180] Fix | Delete
if (!function_exists('ftp_connect')) {
[181] Fix | Delete
return $this->setError('FTP extension not loaded.');
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
// remove protocol from host
[185] Fix | Delete
$scheme = parse_url($this->options['host'], PHP_URL_SCHEME);
[186] Fix | Delete
[187] Fix | Delete
if ($scheme) {
[188] Fix | Delete
$this->options['host'] = substr($this->options['host'], strlen($scheme) + 3);
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
// normalize root path
[192] Fix | Delete
$this->root = $this->options['path'] = $this->_normpath($this->options['path']);
[193] Fix | Delete
[194] Fix | Delete
if (empty($this->options['alias'])) {
[195] Fix | Delete
$this->options['alias'] = $this->options['user'] . '@' . $this->options['host'];
[196] Fix | Delete
if (!empty($this->options['netkey'])) {
[197] Fix | Delete
elFinder::$instance->updateNetVolumeOption($this->options['netkey'], 'alias', $this->options['alias']);
[198] Fix | Delete
}
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
$this->rootName = $this->options['alias'];
[202] Fix | Delete
$this->options['separator'] = '/';
[203] Fix | Delete
[204] Fix | Delete
if (is_null($this->options['syncChkAsTs'])) {
[205] Fix | Delete
$this->options['syncChkAsTs'] = true;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
if (isset($this->options['ftpListOption'])) {
[209] Fix | Delete
$this->ftpListOption = $this->options['ftpListOption'];
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
return $this->needOnline? $this->connect() : true;
[213] Fix | Delete
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
[217] Fix | Delete
/**
[218] Fix | Delete
* Configure after successfull mount.
[219] Fix | Delete
*
[220] Fix | Delete
* @return void
[221] Fix | Delete
* @throws elFinderAbortException
[222] Fix | Delete
* @author Dmitry (dio) Levashov
[223] Fix | Delete
*/
[224] Fix | Delete
protected function configure()
[225] Fix | Delete
{
[226] Fix | Delete
parent::configure();
[227] Fix | Delete
[228] Fix | Delete
if (!empty($this->options['tmpPath'])) {
[229] Fix | Delete
if ((is_dir($this->options['tmpPath']) || mkdir($this->options['tmpPath'], 0755, true)) && is_writable($this->options['tmpPath'])) {
[230] Fix | Delete
$this->tmp = $this->options['tmpPath'];
[231] Fix | Delete
}
[232] Fix | Delete
}
[233] Fix | Delete
if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
[234] Fix | Delete
$this->tmp = $tmp;
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
// fallback of $this->tmp
[238] Fix | Delete
if (!$this->tmp && $this->tmbPathWritable) {
[239] Fix | Delete
$this->tmp = $this->tmbPath;
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
if (!$this->tmp) {
[243] Fix | Delete
$this->disabled[] = 'mkfile';
[244] Fix | Delete
$this->disabled[] = 'paste';
[245] Fix | Delete
$this->disabled[] = 'duplicate';
[246] Fix | Delete
$this->disabled[] = 'upload';
[247] Fix | Delete
$this->disabled[] = 'edit';
[248] Fix | Delete
$this->disabled[] = 'archive';
[249] Fix | Delete
$this->disabled[] = 'extract';
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
// echo $this->tmp;
[253] Fix | Delete
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
/**
[257] Fix | Delete
* Connect to ftp server
[258] Fix | Delete
*
[259] Fix | Delete
* @return bool
[260] Fix | Delete
* @author Dmitry (dio) Levashov
[261] Fix | Delete
**/
[262] Fix | Delete
protected function connect()
[263] Fix | Delete
{
[264] Fix | Delete
$withSSL = empty($this->options['ssl']) ? '' : ' with SSL';
[265] Fix | Delete
if ($withSSL) {
[266] Fix | Delete
if (!function_exists('ftp_ssl_connect') || !($this->connect = ftp_ssl_connect($this->options['host'], $this->options['port'], $this->options['timeout']))) {
[267] Fix | Delete
return $this->setError('Unable to connect to FTP server ' . $this->options['host'] . $withSSL);
[268] Fix | Delete
}
[269] Fix | Delete
$this->isFTPS = true;
[270] Fix | Delete
} else {
[271] Fix | Delete
if (!($this->connect = ftp_connect($this->options['host'], $this->options['port'], $this->options['timeout']))) {
[272] Fix | Delete
return $this->setError('Unable to connect to FTP server ' . $this->options['host']);
[273] Fix | Delete
}
[274] Fix | Delete
}
[275] Fix | Delete
if (!ftp_login($this->connect, $this->options['user'], $this->options['pass'])) {
[276] Fix | Delete
$this->umount();
[277] Fix | Delete
return $this->setError('Unable to login into ' . $this->options['host'] . $withSSL);
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
// try switch utf8 mode
[281] Fix | Delete
if ($this->encoding) {
[282] Fix | Delete
ftp_raw($this->connect, 'OPTS UTF8 OFF');
[283] Fix | Delete
} else {
[284] Fix | Delete
ftp_raw($this->connect, 'OPTS UTF8 ON');
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
$help = ftp_raw($this->connect, 'HELP');
[288] Fix | Delete
$this->isPureFtpd = stripos(implode(' ', $help), 'Pure-FTPd') !== false;
[289] Fix | Delete
[290] Fix | Delete
if (!$this->isPureFtpd) {
[291] Fix | Delete
// switch off extended passive mode - may be usefull for some servers
[292] Fix | Delete
// this command, for pure-ftpd, doesn't work and takes a timeout in some pure-ftpd versions
[293] Fix | Delete
ftp_raw($this->connect, 'epsv4 off');
[294] Fix | Delete
}
[295] Fix | Delete
// enter passive mode if required
[296] Fix | Delete
$pasv = ($this->options['mode'] == 'passive');
[297] Fix | Delete
if (!ftp_pasv($this->connect, $pasv)) {
[298] Fix | Delete
if ($pasv) {
[299] Fix | Delete
$this->options['mode'] = 'active';
[300] Fix | Delete
}
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
// enter root folder
[304] Fix | Delete
if (!ftp_chdir($this->connect, $this->root)
[305] Fix | Delete
|| $this->root != ftp_pwd($this->connect)) {
[306] Fix | Delete
$this->umount();
[307] Fix | Delete
return $this->setError('Unable to open root folder.');
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
// check for MLST support
[311] Fix | Delete
$features = ftp_raw($this->connect, 'FEAT');
[312] Fix | Delete
if (!is_array($features)) {
[313] Fix | Delete
$this->umount();
[314] Fix | Delete
return $this->setError('Server does not support command FEAT.');
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
foreach ($features as $feat) {
[318] Fix | Delete
if (strpos(trim($feat), 'MLST') === 0) {
[319] Fix | Delete
$this->MLSTsupprt = true;
[320] Fix | Delete
break;
[321] Fix | Delete
}
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
return true;
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
/**
[328] Fix | Delete
* Call ftp_rawlist with option prefix
[329] Fix | Delete
*
[330] Fix | Delete
* @param string $path
[331] Fix | Delete
*
[332] Fix | Delete
* @return array
[333] Fix | Delete
*/
[334] Fix | Delete
protected function ftpRawList($path)
[335] Fix | Delete
{
[336] Fix | Delete
if ($this->isPureFtpd) {
[337] Fix | Delete
$path = str_replace(' ', '\ ', $path);
[338] Fix | Delete
}
[339] Fix | Delete
if ($this->ftpListOption) {
[340] Fix | Delete
$path = $this->ftpListOption . ' ' . $path;
[341] Fix | Delete
}
[342] Fix | Delete
$res = ftp_rawlist($this->connect, $path);
[343] Fix | Delete
if ($res === false) {
[344] Fix | Delete
$res = array();
[345] Fix | Delete
}
[346] Fix | Delete
return $res;
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
/*********************************************************************/
[350] Fix | Delete
/* FS API */
[351] Fix | Delete
/*********************************************************************/
[352] Fix | Delete
[353] Fix | Delete
/**
[354] Fix | Delete
* Close opened connection
[355] Fix | Delete
*
[356] Fix | Delete
* @return void
[357] Fix | Delete
* @author Dmitry (dio) Levashov
[358] Fix | Delete
**/
[359] Fix | Delete
public function umount()
[360] Fix | Delete
{
[361] Fix | Delete
$this->connect && ftp_close($this->connect);
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
[365] Fix | Delete
/**
[366] Fix | Delete
* Parse line from ftp_rawlist() output and return file stat (array)
[367] Fix | Delete
*
[368] Fix | Delete
* @param string $raw line from ftp_rawlist() output
[369] Fix | Delete
* @param $base
[370] Fix | Delete
* @param bool $nameOnly
[371] Fix | Delete
*
[372] Fix | Delete
* @return array
[373] Fix | Delete
* @author Dmitry Levashov
[374] Fix | Delete
*/
[375] Fix | Delete
protected function parseRaw($raw, $base, $nameOnly = false)
[376] Fix | Delete
{
[377] Fix | Delete
static $now;
[378] Fix | Delete
static $lastyear;
[379] Fix | Delete
[380] Fix | Delete
if (!$now) {
[381] Fix | Delete
$now = time();
[382] Fix | Delete
$lastyear = date('Y') - 1;
[383] Fix | Delete
}
[384] Fix | Delete
[385] Fix | Delete
$info = preg_split("/\s+/", $raw, 8);
[386] Fix | Delete
if (isset($info[7])) {
[387] Fix | Delete
list($info[7], $info[8]) = explode(' ', $info[7], 2);
[388] Fix | Delete
}
[389] Fix | Delete
$stat = array();
[390] Fix | Delete
[391] Fix | Delete
if (!isset($this->ftpOsUnix)) {
[392] Fix | Delete
$this->ftpOsUnix = !preg_match('/\d/', substr($info[0], 0, 1));
[393] Fix | Delete
}
[394] Fix | Delete
if (!$this->ftpOsUnix) {
[395] Fix | Delete
$info = $this->normalizeRawWindows($raw);
[396] Fix | Delete
}
[397] Fix | Delete
[398] Fix | Delete
if (count($info) < 9 || $info[8] == '.' || $info[8] == '..') {
[399] Fix | Delete
return false;
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
$name = $info[8];
[403] Fix | Delete
[404] Fix | Delete
if (preg_match('|(.+)\-\>(.+)|', $name, $m)) {
[405] Fix | Delete
$name = trim($m[1]);
[406] Fix | Delete
// check recursive processing
[407] Fix | Delete
if ($this->cacheDirTarget && $this->_joinPath($base, $name) !== $this->cacheDirTarget) {
[408] Fix | Delete
return array();
[409] Fix | Delete
}
[410] Fix | Delete
if (!$nameOnly) {
[411] Fix | Delete
$target = trim($m[2]);
[412] Fix | Delete
if (substr($target, 0, 1) !== $this->separator) {
[413] Fix | Delete
$target = $this->getFullPath($target, $base);
[414] Fix | Delete
}
[415] Fix | Delete
$target = $this->_normpath($target);
[416] Fix | Delete
$stat['name'] = $name;
[417] Fix | Delete
$stat['target'] = $target;
[418] Fix | Delete
return $stat;
[419] Fix | Delete
}
[420] Fix | Delete
}
[421] Fix | Delete
[422] Fix | Delete
if ($nameOnly) {
[423] Fix | Delete
return array('name' => $name);
[424] Fix | Delete
}
[425] Fix | Delete
[426] Fix | Delete
if (is_numeric($info[5]) && !$info[6] && !$info[7]) {
[427] Fix | Delete
// by normalizeRawWindows()
[428] Fix | Delete
$stat['ts'] = $info[5];
[429] Fix | Delete
} else {
[430] Fix | Delete
$stat['ts'] = strtotime($info[5] . ' ' . $info[6] . ' ' . $info[7]);
[431] Fix | Delete
if ($stat['ts'] && $stat['ts'] > $now && strpos($info[7], ':') !== false) {
[432] Fix | Delete
$stat['ts'] = strtotime($info[5] . ' ' . $info[6] . ' ' . $lastyear . ' ' . $info[7]);
[433] Fix | Delete
}
[434] Fix | Delete
if (empty($stat['ts'])) {
[435] Fix | Delete
$stat['ts'] = strtotime($info[6] . ' ' . $info[5] . ' ' . $info[7]);
[436] Fix | Delete
if ($stat['ts'] && $stat['ts'] > $now && strpos($info[7], ':') !== false) {
[437] Fix | Delete
$stat['ts'] = strtotime($info[6] . ' ' . $info[5] . ' ' . $lastyear . ' ' . $info[7]);
[438] Fix | Delete
}
[439] Fix | Delete
}
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
if ($this->options['statOwner']) {
[443] Fix | Delete
$stat['owner'] = $info[2];
[444] Fix | Delete
$stat['group'] = $info[3];
[445] Fix | Delete
$stat['perm'] = substr($info[0], 1);
[446] Fix | Delete
//
[447] Fix | Delete
// if not exists owner in LS ftp ==> isowner = true
[448] Fix | Delete
// if is defined as option : 'owner' => true isowner = true
[449] Fix | Delete
//
[450] Fix | Delete
// if exist owner in LS ftp and 'owner' => False isowner = result of owner(file) == user(logged with ftp)
[451] Fix | Delete
//
[452] Fix | Delete
$stat['isowner'] = isset($stat['owner']) ? ($this->options['owner'] ? true : ($stat['owner'] == $this->options['user'])) : true;
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
$owner_computed = isset($stat['isowner']) ? $stat['isowner'] : $this->options['owner'];
[456] Fix | Delete
$perm = $this->parsePermissions($info[0], $owner_computed);
[457] Fix | Delete
$stat['name'] = $name;
[458] Fix | Delete
$stat['mime'] = substr(strtolower($info[0]), 0, 1) == 'd' ? 'directory' : $this->mimetype($stat['name'], true);
[459] Fix | Delete
$stat['size'] = $stat['mime'] == 'directory' ? 0 : $info[4];
[460] Fix | Delete
$stat['read'] = $perm['read'];
[461] Fix | Delete
$stat['write'] = $perm['write'];
[462] Fix | Delete
[463] Fix | Delete
return $stat;
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
/**
[467] Fix | Delete
* Normalize MS-DOS style FTP LIST Raw line
[468] Fix | Delete
*
[469] Fix | Delete
* @param string $raw line from FTP LIST (MS-DOS style)
[470] Fix | Delete
*
[471] Fix | Delete
* @return array
[472] Fix | Delete
* @author Naoki Sawada
[473] Fix | Delete
**/
[474] Fix | Delete
protected function normalizeRawWindows($raw)
[475] Fix | Delete
{
[476] Fix | Delete
$info = array_pad(array(), 9, '');
[477] Fix | Delete
$item = preg_replace('#\s+#', ' ', trim($raw), 3);
[478] Fix | Delete
list($date, $time, $size, $name) = explode(' ', $item, 4);
[479] Fix | Delete
$format = strlen($date) === 8 ? 'm-d-yH:iA' : 'Y-m-dH:i';
[480] Fix | Delete
$dateObj = DateTime::createFromFormat($format, $date . $time);
[481] Fix | Delete
$info[5] = strtotime($dateObj->format('Y-m-d H:i'));
[482] Fix | Delete
$info[8] = $name;
[483] Fix | Delete
if ($size === '<DIR>') {
[484] Fix | Delete
$info[4] = 0;
[485] Fix | Delete
$info[0] = 'drwxr-xr-x';
[486] Fix | Delete
} else {
[487] Fix | Delete
$info[4] = (int)$size;
[488] Fix | Delete
$info[0] = '-rw-r--r--';
[489] Fix | Delete
}
[490] Fix | Delete
return $info;
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
/**
[494] Fix | Delete
* Parse permissions string. Return array(read => true/false, write => true/false)
[495] Fix | Delete
*
[496] Fix | Delete
* @param string $perm permissions string 'rwx' + 'rwx' + 'rwx'
[497] Fix | Delete
* ^ ^ ^
[498] Fix | Delete
* | | +-> others
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function