Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/php
File: elFinderVolumeDriver.class.php
if (!$deny && ($allow === true)) { // match only allow
[4500] Fix | Delete
$res = true;
[4501] Fix | Delete
}// else (both match | no match | match only deny) { deny }
[4502] Fix | Delete
} else { // array('deny', 'allow'), default is to 'allow' - this is the default rule
[4503] Fix | Delete
$res = true; // default is allow
[4504] Fix | Delete
if (($deny === true) && !$allow) { // match only deny
[4505] Fix | Delete
$res = false;
[4506] Fix | Delete
} // else (both match | no match | match only allow) { allow }
[4507] Fix | Delete
}
[4508] Fix | Delete
return $res;
[4509] Fix | Delete
}
[4510] Fix | Delete
[4511] Fix | Delete
/**
[4512] Fix | Delete
* Return fileinfo
[4513] Fix | Delete
*
[4514] Fix | Delete
* @param string $path file cache
[4515] Fix | Delete
*
[4516] Fix | Delete
* @return array|bool
[4517] Fix | Delete
* @author Dmitry (dio) Levashov
[4518] Fix | Delete
**/
[4519] Fix | Delete
protected function stat($path)
[4520] Fix | Delete
{
[4521] Fix | Delete
if ($path === false || is_null($path)) {
[4522] Fix | Delete
return false;
[4523] Fix | Delete
}
[4524] Fix | Delete
$is_root = ($path == $this->root);
[4525] Fix | Delete
if ($is_root) {
[4526] Fix | Delete
$rootKey = $this->getRootstatCachekey();
[4527] Fix | Delete
if ($this->sessionCaching['rootstat'] && !isset($this->sessionCache['rootstat'])) {
[4528] Fix | Delete
$this->sessionCache['rootstat'] = array();
[4529] Fix | Delete
}
[4530] Fix | Delete
if (!isset($this->cache[$path]) && !$this->isMyReload()) {
[4531] Fix | Delete
// need $path as key for netmount/netunmount
[4532] Fix | Delete
if ($this->sessionCaching['rootstat'] && isset($this->sessionCache['rootstat'][$rootKey])) {
[4533] Fix | Delete
if ($ret = $this->sessionCache['rootstat'][$rootKey]) {
[4534] Fix | Delete
if ($this->options['rootRev'] === $ret['rootRev']) {
[4535] Fix | Delete
if (isset($this->options['phash'])) {
[4536] Fix | Delete
$ret['isroot'] = 1;
[4537] Fix | Delete
$ret['phash'] = $this->options['phash'];
[4538] Fix | Delete
}
[4539] Fix | Delete
return $ret;
[4540] Fix | Delete
}
[4541] Fix | Delete
}
[4542] Fix | Delete
}
[4543] Fix | Delete
}
[4544] Fix | Delete
}
[4545] Fix | Delete
$rootSessCache = false;
[4546] Fix | Delete
if (isset($this->cache[$path])) {
[4547] Fix | Delete
$ret = $this->cache[$path];
[4548] Fix | Delete
} else {
[4549] Fix | Delete
if ($is_root && !empty($this->options['rapidRootStat']) && is_array($this->options['rapidRootStat']) && !$this->needOnline) {
[4550] Fix | Delete
$ret = $this->updateCache($path, $this->options['rapidRootStat'], true);
[4551] Fix | Delete
} else {
[4552] Fix | Delete
$ret = $this->updateCache($path, $this->convEncOut($this->_stat($this->convEncIn($path))), true);
[4553] Fix | Delete
if ($is_root && !empty($rootKey) && $this->sessionCaching['rootstat']) {
[4554] Fix | Delete
$rootSessCache = true;
[4555] Fix | Delete
}
[4556] Fix | Delete
}
[4557] Fix | Delete
}
[4558] Fix | Delete
if ($is_root) {
[4559] Fix | Delete
if ($ret) {
[4560] Fix | Delete
$this->rootModified = false;
[4561] Fix | Delete
if ($rootSessCache) {
[4562] Fix | Delete
$this->sessionCache['rootstat'][$rootKey] = $ret;
[4563] Fix | Delete
}
[4564] Fix | Delete
if (isset($this->options['phash'])) {
[4565] Fix | Delete
$ret['isroot'] = 1;
[4566] Fix | Delete
$ret['phash'] = $this->options['phash'];
[4567] Fix | Delete
}
[4568] Fix | Delete
} else if (!empty($rootKey) && $this->sessionCaching['rootstat']) {
[4569] Fix | Delete
unset($this->sessionCache['rootstat'][$rootKey]);
[4570] Fix | Delete
}
[4571] Fix | Delete
}
[4572] Fix | Delete
return $ret;
[4573] Fix | Delete
}
[4574] Fix | Delete
[4575] Fix | Delete
/**
[4576] Fix | Delete
* Get root stat extra key values
[4577] Fix | Delete
*
[4578] Fix | Delete
* @return array stat extras
[4579] Fix | Delete
* @author Naoki Sawada
[4580] Fix | Delete
*/
[4581] Fix | Delete
protected function getRootStatExtra()
[4582] Fix | Delete
{
[4583] Fix | Delete
$stat = array();
[4584] Fix | Delete
if ($this->rootName) {
[4585] Fix | Delete
$stat['name'] = $this->rootName;
[4586] Fix | Delete
}
[4587] Fix | Delete
$stat['rootRev'] = $this->options['rootRev'];
[4588] Fix | Delete
$stat['options'] = $this->options(null);
[4589] Fix | Delete
return $stat;
[4590] Fix | Delete
}
[4591] Fix | Delete
[4592] Fix | Delete
/**
[4593] Fix | Delete
* Return fileinfo based on filename
[4594] Fix | Delete
* For item ID based path file system
[4595] Fix | Delete
* Please override if needed on each drivers
[4596] Fix | Delete
*
[4597] Fix | Delete
* @param string $path file cache
[4598] Fix | Delete
*
[4599] Fix | Delete
* @return array
[4600] Fix | Delete
*/
[4601] Fix | Delete
protected function isNameExists($path)
[4602] Fix | Delete
{
[4603] Fix | Delete
return $this->stat($path);
[4604] Fix | Delete
}
[4605] Fix | Delete
[4606] Fix | Delete
/**
[4607] Fix | Delete
* Put file stat in cache and return it
[4608] Fix | Delete
*
[4609] Fix | Delete
* @param string $path file path
[4610] Fix | Delete
* @param array $stat file stat
[4611] Fix | Delete
*
[4612] Fix | Delete
* @return array
[4613] Fix | Delete
* @author Dmitry (dio) Levashov
[4614] Fix | Delete
**/
[4615] Fix | Delete
protected function updateCache($path, $stat)
[4616] Fix | Delete
{
[4617] Fix | Delete
if (empty($stat) || !is_array($stat)) {
[4618] Fix | Delete
return $this->cache[$path] = array();
[4619] Fix | Delete
}
[4620] Fix | Delete
[4621] Fix | Delete
if (func_num_args() > 2) {
[4622] Fix | Delete
$fromStat = func_get_arg(2);
[4623] Fix | Delete
} else {
[4624] Fix | Delete
$fromStat = false;
[4625] Fix | Delete
}
[4626] Fix | Delete
[4627] Fix | Delete
$stat['hash'] = $this->encode($path);
[4628] Fix | Delete
[4629] Fix | Delete
$root = $path == $this->root;
[4630] Fix | Delete
$parent = '';
[4631] Fix | Delete
[4632] Fix | Delete
if ($root) {
[4633] Fix | Delete
$stat = array_merge($stat, $this->getRootStatExtra());
[4634] Fix | Delete
} else {
[4635] Fix | Delete
if (!isset($stat['name']) || $stat['name'] === '') {
[4636] Fix | Delete
$stat['name'] = $this->basenameCE($path);
[4637] Fix | Delete
}
[4638] Fix | Delete
if (empty($stat['phash'])) {
[4639] Fix | Delete
$parent = $this->dirnameCE($path);
[4640] Fix | Delete
$stat['phash'] = $this->encode($parent);
[4641] Fix | Delete
} else {
[4642] Fix | Delete
$parent = $this->decode($stat['phash']);
[4643] Fix | Delete
}
[4644] Fix | Delete
}
[4645] Fix | Delete
[4646] Fix | Delete
// name check
[4647] Fix | Delete
if (isset($stat['name']) && !$jeName = json_encode($stat['name'])) {
[4648] Fix | Delete
return $this->cache[$path] = array();
[4649] Fix | Delete
}
[4650] Fix | Delete
// fix name if required
[4651] Fix | Delete
if ($this->options['utf8fix'] && $this->options['utf8patterns'] && $this->options['utf8replace']) {
[4652] Fix | Delete
$stat['name'] = json_decode(str_replace($this->options['utf8patterns'], $this->options['utf8replace'], $jeName));
[4653] Fix | Delete
}
[4654] Fix | Delete
[4655] Fix | Delete
if (!isset($stat['size'])) {
[4656] Fix | Delete
$stat['size'] = 'unknown';
[4657] Fix | Delete
}
[4658] Fix | Delete
[4659] Fix | Delete
$mime = isset($stat['mime']) ? $stat['mime'] : '';
[4660] Fix | Delete
if ($isDir = ($mime === 'directory')) {
[4661] Fix | Delete
$stat['volumeid'] = $this->id;
[4662] Fix | Delete
} else {
[4663] Fix | Delete
if (empty($stat['mime']) || $stat['size'] == 0) {
[4664] Fix | Delete
$stat['mime'] = $this->mimetype($stat['name'], true, $stat['size'], $mime);
[4665] Fix | Delete
} else {
[4666] Fix | Delete
$stat['mime'] = $this->mimeTypeNormalize($stat['mime'], $stat['name']);
[4667] Fix | Delete
}
[4668] Fix | Delete
}
[4669] Fix | Delete
[4670] Fix | Delete
$stat['read'] = intval($this->attr($path, 'read', isset($stat['read']) ? !!$stat['read'] : null, $isDir));
[4671] Fix | Delete
$stat['write'] = intval($this->attr($path, 'write', isset($stat['write']) ? !!$stat['write'] : null, $isDir));
[4672] Fix | Delete
if ($root) {
[4673] Fix | Delete
$stat['locked'] = 1;
[4674] Fix | Delete
if ($this->options['type'] !== '') {
[4675] Fix | Delete
$stat['type'] = $this->options['type'];
[4676] Fix | Delete
}
[4677] Fix | Delete
} else {
[4678] Fix | Delete
// lock when parent directory is not writable
[4679] Fix | Delete
if (!isset($stat['locked'])) {
[4680] Fix | Delete
$pstat = $this->stat($parent);
[4681] Fix | Delete
if (isset($pstat['write']) && !$pstat['write']) {
[4682] Fix | Delete
$stat['locked'] = true;
[4683] Fix | Delete
}
[4684] Fix | Delete
}
[4685] Fix | Delete
if ($this->attr($path, 'locked', isset($stat['locked']) ? !!$stat['locked'] : null, $isDir)) {
[4686] Fix | Delete
$stat['locked'] = 1;
[4687] Fix | Delete
} else {
[4688] Fix | Delete
unset($stat['locked']);
[4689] Fix | Delete
}
[4690] Fix | Delete
}
[4691] Fix | Delete
[4692] Fix | Delete
if ($root) {
[4693] Fix | Delete
unset($stat['hidden']);
[4694] Fix | Delete
} elseif ($this->attr($path, 'hidden', isset($stat['hidden']) ? !!$stat['hidden'] : null, $isDir)
[4695] Fix | Delete
|| !$this->mimeAccepted($stat['mime'])) {
[4696] Fix | Delete
$stat['hidden'] = 1;
[4697] Fix | Delete
} else {
[4698] Fix | Delete
unset($stat['hidden']);
[4699] Fix | Delete
}
[4700] Fix | Delete
[4701] Fix | Delete
if ($stat['read'] && empty($stat['hidden'])) {
[4702] Fix | Delete
[4703] Fix | Delete
if ($isDir) {
[4704] Fix | Delete
// caching parent's subdirs
[4705] Fix | Delete
if ($parent) {
[4706] Fix | Delete
$this->updateSubdirsCache($parent, true);
[4707] Fix | Delete
}
[4708] Fix | Delete
// for dir - check for subdirs
[4709] Fix | Delete
if ($this->options['checkSubfolders']) {
[4710] Fix | Delete
if (!isset($stat['dirs']) && intval($this->options['checkSubfolders']) === -1) {
[4711] Fix | Delete
$stat['dirs'] = -1;
[4712] Fix | Delete
}
[4713] Fix | Delete
if (isset($stat['dirs'])) {
[4714] Fix | Delete
if ($stat['dirs']) {
[4715] Fix | Delete
if ($stat['dirs'] == -1) {
[4716] Fix | Delete
$stat['dirs'] = ($this->sessionCaching['subdirs'] && isset($this->sessionCache['subdirs'][$path])) ? (int)$this->sessionCache['subdirs'][$path] : -1;
[4717] Fix | Delete
} else {
[4718] Fix | Delete
$stat['dirs'] = 1;
[4719] Fix | Delete
}
[4720] Fix | Delete
} else {
[4721] Fix | Delete
unset($stat['dirs']);
[4722] Fix | Delete
}
[4723] Fix | Delete
} elseif (!empty($stat['alias']) && !empty($stat['target'])) {
[4724] Fix | Delete
$stat['dirs'] = isset($this->cache[$stat['target']])
[4725] Fix | Delete
? intval(isset($this->cache[$stat['target']]['dirs']))
[4726] Fix | Delete
: $this->subdirsCE($stat['target']);
[4727] Fix | Delete
[4728] Fix | Delete
} elseif ($this->subdirsCE($path)) {
[4729] Fix | Delete
$stat['dirs'] = 1;
[4730] Fix | Delete
}
[4731] Fix | Delete
} else {
[4732] Fix | Delete
$stat['dirs'] = 1;
[4733] Fix | Delete
}
[4734] Fix | Delete
if ($this->options['dirUrlOwn'] === true) {
[4735] Fix | Delete
// Set `null` to use the client option `commandsOptions.info.nullUrlDirLinkSelf = true`
[4736] Fix | Delete
$stat['url'] = null;
[4737] Fix | Delete
} else if ($this->options['dirUrlOwn'] === 'hide') {
[4738] Fix | Delete
// to hide link in info dialog of the elFinder client
[4739] Fix | Delete
$stat['url'] = '';
[4740] Fix | Delete
}
[4741] Fix | Delete
} else {
[4742] Fix | Delete
// for files - check for thumbnails
[4743] Fix | Delete
$p = isset($stat['target']) ? $stat['target'] : $path;
[4744] Fix | Delete
if ($this->tmbURL && !isset($stat['tmb']) && $this->canCreateTmb($p, $stat)) {
[4745] Fix | Delete
$tmb = $this->gettmb($p, $stat);
[4746] Fix | Delete
$stat['tmb'] = $tmb ? $tmb : 1;
[4747] Fix | Delete
}
[4748] Fix | Delete
[4749] Fix | Delete
}
[4750] Fix | Delete
if (!isset($stat['url']) && $this->URL && $this->encoding) {
[4751] Fix | Delete
$_path = str_replace($this->separator, '/', substr($path, strlen($this->root) + 1));
[4752] Fix | Delete
$stat['url'] = rtrim($this->URL, '/') . '/' . str_replace('%2F', '/', rawurlencode((substr(PHP_OS, 0, 3) === 'WIN') ? $_path : $this->convEncIn($_path, true)));
[4753] Fix | Delete
}
[4754] Fix | Delete
} else {
[4755] Fix | Delete
if ($isDir) {
[4756] Fix | Delete
unset($stat['dirs']);
[4757] Fix | Delete
}
[4758] Fix | Delete
}
[4759] Fix | Delete
[4760] Fix | Delete
if (!empty($stat['alias']) && !empty($stat['target'])) {
[4761] Fix | Delete
$stat['thash'] = $this->encode($stat['target']);
[4762] Fix | Delete
//$this->cache[$stat['target']] = $stat;
[4763] Fix | Delete
unset($stat['target']);
[4764] Fix | Delete
}
[4765] Fix | Delete
[4766] Fix | Delete
$this->cache[$path] = $stat;
[4767] Fix | Delete
[4768] Fix | Delete
if (!$fromStat && $root && $this->sessionCaching['rootstat']) {
[4769] Fix | Delete
// to update session cache
[4770] Fix | Delete
$this->stat($path);
[4771] Fix | Delete
}
[4772] Fix | Delete
[4773] Fix | Delete
return $stat;
[4774] Fix | Delete
}
[4775] Fix | Delete
[4776] Fix | Delete
/**
[4777] Fix | Delete
* Get stat for folder content and put in cache
[4778] Fix | Delete
*
[4779] Fix | Delete
* @param string $path
[4780] Fix | Delete
*
[4781] Fix | Delete
* @return void
[4782] Fix | Delete
* @author Dmitry (dio) Levashov
[4783] Fix | Delete
**/
[4784] Fix | Delete
protected function cacheDir($path)
[4785] Fix | Delete
{
[4786] Fix | Delete
$this->dirsCache[$path] = array();
[4787] Fix | Delete
$hasDir = false;
[4788] Fix | Delete
[4789] Fix | Delete
foreach ($this->scandirCE($path) as $p) {
[4790] Fix | Delete
if (($stat = $this->stat($p)) && empty($stat['hidden'])) {
[4791] Fix | Delete
if (!$hasDir && $stat['mime'] === 'directory') {
[4792] Fix | Delete
$hasDir = true;
[4793] Fix | Delete
}
[4794] Fix | Delete
$this->dirsCache[$path][] = $p;
[4795] Fix | Delete
}
[4796] Fix | Delete
}
[4797] Fix | Delete
[4798] Fix | Delete
$this->updateSubdirsCache($path, $hasDir);
[4799] Fix | Delete
}
[4800] Fix | Delete
[4801] Fix | Delete
/**
[4802] Fix | Delete
* Clean cache
[4803] Fix | Delete
*
[4804] Fix | Delete
* @return void
[4805] Fix | Delete
* @author Dmitry (dio) Levashov
[4806] Fix | Delete
**/
[4807] Fix | Delete
protected function clearcache()
[4808] Fix | Delete
{
[4809] Fix | Delete
$this->cache = $this->dirsCache = array();
[4810] Fix | Delete
}
[4811] Fix | Delete
[4812] Fix | Delete
/**
[4813] Fix | Delete
* Return file mimetype
[4814] Fix | Delete
*
[4815] Fix | Delete
* @param string $path file path
[4816] Fix | Delete
* @param string|bool $name
[4817] Fix | Delete
* @param integer $size
[4818] Fix | Delete
* @param string $mime was notified from the volume driver
[4819] Fix | Delete
*
[4820] Fix | Delete
* @return string
[4821] Fix | Delete
* @author Dmitry (dio) Levashov
[4822] Fix | Delete
*/
[4823] Fix | Delete
protected function mimetype($path, $name = '', $size = null, $mime = null)
[4824] Fix | Delete
{
[4825] Fix | Delete
$type = '';
[4826] Fix | Delete
$nameCheck = false;
[4827] Fix | Delete
[4828] Fix | Delete
if ($name === '') {
[4829] Fix | Delete
$name = $path;
[4830] Fix | Delete
} else if ($name === true) {
[4831] Fix | Delete
$name = $path;
[4832] Fix | Delete
$nameCheck = true;
[4833] Fix | Delete
}
[4834] Fix | Delete
if (!$this instanceof elFinderVolumeLocalFileSystem) {
[4835] Fix | Delete
$nameCheck = true;
[4836] Fix | Delete
}
[4837] Fix | Delete
$ext = (false === $pos = strrpos($name, '.')) ? '' : strtolower(substr($name, $pos + 1));
[4838] Fix | Delete
if (!$nameCheck && $size === null) {
[4839] Fix | Delete
$size = file_exists($path) ? filesize($path) : -1;
[4840] Fix | Delete
}
[4841] Fix | Delete
if (!$nameCheck && is_readable($path) && $size > 0) {
[4842] Fix | Delete
// detecting by contents
[4843] Fix | Delete
if ($this->mimeDetect === 'finfo') {
[4844] Fix | Delete
$type = finfo_file($this->finfo, $path);
[4845] Fix | Delete
} else if ($this->mimeDetect === 'mime_content_type') {
[4846] Fix | Delete
$type = mime_content_type($path);
[4847] Fix | Delete
}
[4848] Fix | Delete
if ($type) {
[4849] Fix | Delete
$type = explode(';', $type);
[4850] Fix | Delete
$type = trim($type[0]);
[4851] Fix | Delete
if ($ext && preg_match('~^application/(?:octet-stream|(?:x-)?zip|xml)$~', $type)) {
[4852] Fix | Delete
// load default MIME table file "mime.types"
[4853] Fix | Delete
if (!elFinderVolumeDriver::$mimetypesLoaded) {
[4854] Fix | Delete
elFinderVolumeDriver::loadMimeTypes();
[4855] Fix | Delete
}
[4856] Fix | Delete
if (isset(elFinderVolumeDriver::$mimetypes[$ext])) {
[4857] Fix | Delete
$type = elFinderVolumeDriver::$mimetypes[$ext];
[4858] Fix | Delete
}
[4859] Fix | Delete
} else if ($ext === 'js' && preg_match('~^text/~', $type)) {
[4860] Fix | Delete
$type = 'text/javascript';
[4861] Fix | Delete
}
[4862] Fix | Delete
}
[4863] Fix | Delete
}
[4864] Fix | Delete
if (!$type) {
[4865] Fix | Delete
// detecting by filename
[4866] Fix | Delete
$type = elFinderVolumeDriver::mimetypeInternalDetect($name);
[4867] Fix | Delete
if ($type === 'unknown') {
[4868] Fix | Delete
if ($mime) {
[4869] Fix | Delete
$type = $mime;
[4870] Fix | Delete
} else {
[4871] Fix | Delete
$type = ($size == 0) ? 'text/plain' : $this->options['mimeTypeUnknown'];
[4872] Fix | Delete
}
[4873] Fix | Delete
}
[4874] Fix | Delete
}
[4875] Fix | Delete
[4876] Fix | Delete
// mime type normalization
[4877] Fix | Delete
$type = $this->mimeTypeNormalize($type, $name, $ext);
[4878] Fix | Delete
[4879] Fix | Delete
return $type;
[4880] Fix | Delete
}
[4881] Fix | Delete
[4882] Fix | Delete
/**
[4883] Fix | Delete
* Load file of mime.types
[4884] Fix | Delete
*
[4885] Fix | Delete
* @param string $mimeTypesFile The mime types file
[4886] Fix | Delete
*/
[4887] Fix | Delete
static protected function loadMimeTypes($mimeTypesFile = '')
[4888] Fix | Delete
{
[4889] Fix | Delete
if (!elFinderVolumeDriver::$mimetypesLoaded) {
[4890] Fix | Delete
elFinderVolumeDriver::$mimetypesLoaded = true;
[4891] Fix | Delete
$file = false;
[4892] Fix | Delete
if (!empty($mimeTypesFile) && file_exists($mimeTypesFile)) {
[4893] Fix | Delete
$file = $mimeTypesFile;
[4894] Fix | Delete
} elseif (elFinder::$defaultMimefile && file_exists(elFinder::$defaultMimefile)) {
[4895] Fix | Delete
$file = elFinder::$defaultMimefile;
[4896] Fix | Delete
} elseif (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mime.types')) {
[4897] Fix | Delete
$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mime.types';
[4898] Fix | Delete
} elseif (file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'mime.types')) {
[4899] Fix | Delete
$file = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'mime.types';
[4900] Fix | Delete
}
[4901] Fix | Delete
[4902] Fix | Delete
if ($file && file_exists($file)) {
[4903] Fix | Delete
$mimecf = file($file);
[4904] Fix | Delete
[4905] Fix | Delete
foreach ($mimecf as $line_num => $line) {
[4906] Fix | Delete
if (!preg_match('/^\s*#/', $line)) {
[4907] Fix | Delete
$mime = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
[4908] Fix | Delete
for ($i = 1, $size = count($mime); $i < $size; $i++) {
[4909] Fix | Delete
if (!isset(self::$mimetypes[$mime[$i]])) {
[4910] Fix | Delete
self::$mimetypes[$mime[$i]] = $mime[0];
[4911] Fix | Delete
}
[4912] Fix | Delete
}
[4913] Fix | Delete
}
[4914] Fix | Delete
}
[4915] Fix | Delete
}
[4916] Fix | Delete
}
[4917] Fix | Delete
}
[4918] Fix | Delete
[4919] Fix | Delete
/**
[4920] Fix | Delete
* Detect file mimetype using "internal" method or Loading mime.types with $path = ''
[4921] Fix | Delete
*
[4922] Fix | Delete
* @param string $path file path
[4923] Fix | Delete
*
[4924] Fix | Delete
* @return string
[4925] Fix | Delete
* @author Dmitry (dio) Levashov
[4926] Fix | Delete
**/
[4927] Fix | Delete
static protected function mimetypeInternalDetect($path = '')
[4928] Fix | Delete
{
[4929] Fix | Delete
// load default MIME table file "mime.types"
[4930] Fix | Delete
if (!elFinderVolumeDriver::$mimetypesLoaded) {
[4931] Fix | Delete
elFinderVolumeDriver::loadMimeTypes();
[4932] Fix | Delete
}
[4933] Fix | Delete
$ext = '';
[4934] Fix | Delete
if ($path) {
[4935] Fix | Delete
$pinfo = pathinfo($path);
[4936] Fix | Delete
$ext = isset($pinfo['extension']) ? strtolower($pinfo['extension']) : '';
[4937] Fix | Delete
}
[4938] Fix | Delete
$res = ($ext && isset(elFinderVolumeDriver::$mimetypes[$ext])) ? elFinderVolumeDriver::$mimetypes[$ext] : 'unknown';
[4939] Fix | Delete
// Recursive check if MIME type is unknown with multiple extensions
[4940] Fix | Delete
if ($res === 'unknown' && strpos($pinfo['filename'], '.')) {
[4941] Fix | Delete
return elFinderVolumeDriver::mimetypeInternalDetect($pinfo['filename']);
[4942] Fix | Delete
} else {
[4943] Fix | Delete
return $res;
[4944] Fix | Delete
}
[4945] Fix | Delete
}
[4946] Fix | Delete
[4947] Fix | Delete
/**
[4948] Fix | Delete
* Return file/total directory size infomation
[4949] Fix | Delete
*
[4950] Fix | Delete
* @param string $path file path
[4951] Fix | Delete
*
[4952] Fix | Delete
* @return array
[4953] Fix | Delete
* @throws elFinderAbortException
[4954] Fix | Delete
* @author Dmitry (dio) Levashov
[4955] Fix | Delete
*/
[4956] Fix | Delete
protected function countSize($path)
[4957] Fix | Delete
{
[4958] Fix | Delete
[4959] Fix | Delete
elFinder::checkAborted();
[4960] Fix | Delete
[4961] Fix | Delete
$result = array('size' => 0, 'files' => 0, 'dirs' => 0);
[4962] Fix | Delete
$stat = $this->stat($path);
[4963] Fix | Delete
[4964] Fix | Delete
if (empty($stat) || !$stat['read'] || !empty($stat['hidden'])) {
[4965] Fix | Delete
$result['size'] = 'unknown';
[4966] Fix | Delete
return $result;
[4967] Fix | Delete
}
[4968] Fix | Delete
[4969] Fix | Delete
if ($stat['mime'] !== 'directory') {
[4970] Fix | Delete
$result['size'] = intval($stat['size']);
[4971] Fix | Delete
$result['files'] = 1;
[4972] Fix | Delete
return $result;
[4973] Fix | Delete
}
[4974] Fix | Delete
[4975] Fix | Delete
$result['dirs'] = 1;
[4976] Fix | Delete
$subdirs = $this->options['checkSubfolders'];
[4977] Fix | Delete
$this->options['checkSubfolders'] = true;
[4978] Fix | Delete
foreach ($this->getScandir($path) as $stat) {
[4979] Fix | Delete
if ($isDir = ($stat['mime'] === 'directory' && $stat['read'])) {
[4980] Fix | Delete
++$result['dirs'];
[4981] Fix | Delete
} else {
[4982] Fix | Delete
++$result['files'];
[4983] Fix | Delete
}
[4984] Fix | Delete
$res = $isDir
[4985] Fix | Delete
? $this->countSize($this->decode($stat['hash']))
[4986] Fix | Delete
: (isset($stat['size']) ? array('size' => intval($stat['size'])) : array());
[4987] Fix | Delete
if (!empty($res['size']) && is_numeric($res['size'])) {
[4988] Fix | Delete
$result['size'] += $res['size'];
[4989] Fix | Delete
}
[4990] Fix | Delete
if (!empty($res['files']) && is_numeric($res['files'])) {
[4991] Fix | Delete
$result['files'] += $res['files'];
[4992] Fix | Delete
}
[4993] Fix | Delete
if (!empty($res['dirs']) && is_numeric($res['dirs'])) {
[4994] Fix | Delete
$result['dirs'] += $res['dirs'];
[4995] Fix | Delete
--$result['dirs'];
[4996] Fix | Delete
}
[4997] Fix | Delete
}
[4998] Fix | Delete
$this->options['checkSubfolders'] = $subdirs;
[4999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function