Project

General

Profile

Bug #16419 » class.em_index.060804.diff.diff

Administrator Admin, 2006-08-04 13:49

View differences:

class.em_index.php 4 Aug 2006 11:31:32 -0000
var $excludeHidden=false; // if set, hidden or system files will not be transfered
var $pathAttribs=array(); // holds the attribs for a path to reduce exec calls
//prs- 01.08.2006
//prs+ 03.08.2006
var $disallowedToTransfer=null; // will hold pathes and file extension not allowed to transfer to TER
var $noFurtherCheck=false;
//prs- 03.08.2006
/*********************************
......
$lines .= str_repeat(chr(9),$level-1).')'.($level-1==0 ? '':','.chr(10));
return $lines;
}
//prs+ 01.08.2006
/**
* Removes hidden files from file array
/**
* Checks if there are some preset in localconf.php or TSCONFIG
*
* @param array Array of files
* @return array Array of files not hidden or system
*/
function _isHiddenWin($key='',$fName='',$extPath='')
function _getArray($str='',$delim=',',$onlyNonEmptyValues=true,$isUnique=true)
{
$ar=t3lib_div::trimExplode($delim,$str,$onlyNonEmptyValues);
if (is_array($ar) && $isUnique)
{
$ar=array_unique($ar);
}
return $ar;
}
function _setDisallowedArray()
{
$dA=null;
$check=array('excludePath','excludeExt');
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['uploadTer']))
{
foreach($check as $key)
{
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['uploadTer'][$key]))
{
$ar=$this->_getArray($GLOBALS['TYPO3_CONF_VARS']['EXT']['uploadTer'][$key]);
if (count($ar)>0)
{
if ($dA==null)
{
$dA=array();
}
$dA[$key]=$ar;
}
}
}
}
$userConf=$GLOBALS['BE_USER']->getTSConfig('EXT');
if ($userConf['properties']!=null && isset($userConf['properties']['uploadTer.']))
{
//if userConf parameter is set it will ALLWAYS replace the global setting!
foreach($check as $key)
{
if (isset($userConf['properties']['uploadTer.'][$key]))
{
$ar=$this->_getArray($userConf['properties']['uploadTer.'][$key]);
if (count($ar)>0)
{
if ($dA==null)
{
$dA=array();
}
$dA[$key]=$ar;
}
elseif (isset($dA[$key]))
{
unset($dA[$key]);
}
}
}
}
return $dA;
}
function _excludePath($fKey,$cName='',$ar=array())
{
$exclude=false;
if(!isset($this->pathAttribs[$fKey]))
{
foreach($ar as $path)
{
$pos=strpos($cName,'/'.$path.'/');
if ($pos===false)
{
continue;
} else {
$exclude=true;
break;
}
}
$this->pathAttribs[$fKey]=$exclude;
}
return $this->pathAttribs[$fKey];
}
function _unsetPathAttribs()
{
foreach($this->pathAttribs as $key=>$value)
{
if (!$value)
{
unset($this->pathAttribs[$key]);
}
}
}
function _excludeExt($cName='',$ar=array())
{
$fI=pathinfo($cName);
return in_array($fI['extension'],$ar);
}
function _isDisallowedFileOrPath($fKey='',$fName='',$extPath='')
{
$isDisallowed=false;
if ($this->noFurtherCheck)
{
return $isDisallowed;
}
if ($this->disallowedToTransfer==null)
{
$this->disallowedToTransfer=$this->_setDisallowedArray();
if (!is_array($this->disallowedToTransfer))
{
$this->noFurtherCheck=true;
}
}
if ($this->noFurtherCheck)
{
return $isDisallowed;
}
$cName=$this->_getCName($fName,$extPath);
/*
* We have to reset all NONE setted, i.e. value=false
* otherwise it won't get checked
*/
$this->_unsetPathAttribs();
foreach ($this->disallowedToTransfer as $key=>$array)
{
switch($key)
{
case 'excludePath':
$isDisallowed = $isDisallowed || $this->_excludePath($fKey,$cName,$array);
break;
case 'excludeExt':
$isDisallowed = $isDisallowed || $this->_excludeExt($cName,$array);
break;
default:
//not defined items so far
break;
}
if ($isDisallowed)
{
break;
}
}
return $isDisallowed;
}
function _isHiddenWin($fName='',$extPath='')
{
/*
* On windows S and H attribute is set on index 3 or 4
......
$str=substr(exec('attrib '.$fName),0,6);
$isHidden=strpos($str,'S') || strpos($str,'H');
$isHidden=($isHidden===false)?false:true;
$key=$this->_getKey($fName);
if (!isset($this->pathAttribs[$key]))
{
$d=substr((exec('attrib '.dirname($fName))),0,6);
$this->pathAttribs[$key]=(strpos($d,'S') || strpos($d,'H'));
$this->pathAttribs[$key]=($this->pathAttribs[$key]===false)?false:true;
}
if (!($isHidden && $this->pathAttribs[$key]))
{
$isHidden=$this->_isDisallowedFileOrPath($key,$fName,$extPath);
}
return ($isHidden || $this->pathAttribs[$key]);
}
function _isHiddenNix($key='',$fName='',$extPath='')
function _getKey($fName)
{
return md5(dirname($fName));
}
function _getCName($fName='',$extPath='')
{
return substr($fName,strlen($extPath)-1);
}
function _isHiddenNix($fName='',$extPath='')
{
$cName=substr($fName,strlen($extPath)-1);
$pos=strpos($fName,'/.');
return ($pos===false)?false:true;
$cName=$this->_getCName($fName,$extPath);
$pos=strpos($cName,'/.');
$isHidden=($pos===false)?false:true;
if (!$isHidden)
{
$key=$this->_getKey($fName);
$isHidden=$this->_isDisallowedFileOrPath($key,$fName,$extPath);
}
return $isHidden;
}
/**
* Removes hidden files from file array
*
* @param array Array of files
* @return array Array of files not hidden or system
*/
function removeHiddenFiles($fileArr=array(),$extPath='')
{
$fA=array();
$func=(TYPO3_OS=='WIN')?'_isHiddenWin':'_isHiddenNix';
foreach($fileArr as $key=>$fName)
{
if (! $this->$func($key,$fName,$extPath))
if (! $this->$func($fName,$extPath))
{
$fA[$key]=$fName;
}
}
return $fA;
}
//prs- 01.08.2006
/**
* Make upload array out of extension
*
......
* @see makeUploadArray()
*/
function getSerializedLocalLang($file,$content) {
global $LOCAL_LANG;
$returnParts = explode('$LOCAL_LANG',$content,2);
include($file);
(4-4/9)