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
326 326
	var $excludeHidden=false;			// if set, hidden or system files will not be transfered
327 327
	var $pathAttribs=array();			// holds the attribs for a path to reduce exec calls
328 328
//prs- 01.08.2006
329
//prs+ 03.08.2006
330
	var $disallowedToTransfer=null;		// will hold pathes and file extension not allowed to transfer to TER
331
	var $noFurtherCheck=false;			
332
//prs- 03.08.2006
329 333

  
330 334

  
331 335
	/*********************************
......
3877 3881
		$lines .= str_repeat(chr(9),$level-1).')'.($level-1==0 ? '':','.chr(10));
3878 3882
		return $lines;
3879 3883
	}
3880
//prs+ 01.08.2006
3881
	/**
3882
	 * Removes hidden files from file array
3884
	/** 
3885
	 * Checks if there are some preset in localconf.php or TSCONFIG
3883 3886
	 * 
3884
	 * @param array	Array of files
3885
	 * @return array Array of files not hidden or system
3886 3887
	 */
3887
	function _isHiddenWin($key='',$fName='',$extPath='')
3888
	function _getArray($str='',$delim=',',$onlyNonEmptyValues=true,$isUnique=true)
3889
	{
3890
		$ar=t3lib_div::trimExplode($delim,$str,$onlyNonEmptyValues);
3891
		if (is_array($ar) && $isUnique)
3892
		{
3893
			$ar=array_unique($ar);
3894
		}
3895
		return $ar;
3896
	}
3897
	function _setDisallowedArray()
3898
	{
3899
		$dA=null;
3900
		$check=array('excludePath','excludeExt');
3901
		if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['uploadTer']))
3902
		{
3903
			foreach($check as $key)
3904
			{
3905
				if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['uploadTer'][$key]))
3906
				{
3907
					$ar=$this->_getArray($GLOBALS['TYPO3_CONF_VARS']['EXT']['uploadTer'][$key]);
3908
					if (count($ar)>0)
3909
					{
3910
						if ($dA==null)
3911
						{
3912
							$dA=array();
3913
						}
3914
						$dA[$key]=$ar;
3915
					}
3916
				}
3917
			}
3918
		}
3919
		$userConf=$GLOBALS['BE_USER']->getTSConfig('EXT');
3920
		if ($userConf['properties']!=null && isset($userConf['properties']['uploadTer.']))
3921
		{
3922
			//if userConf parameter is set it will ALLWAYS replace the global setting!
3923
			foreach($check as $key)
3924
			{
3925
				if (isset($userConf['properties']['uploadTer.'][$key]))
3926
				{
3927
					$ar=$this->_getArray($userConf['properties']['uploadTer.'][$key]);
3928
					if (count($ar)>0)
3929
					{
3930
						if ($dA==null)
3931
						{
3932
							$dA=array();
3933
						}
3934
						$dA[$key]=$ar;
3935
					} 
3936
					elseif (isset($dA[$key]))
3937
					{
3938
						unset($dA[$key]);
3939
					}
3940
				}
3941
			}
3942
		}
3943
		return $dA;
3944
	}
3945
	function _excludePath($fKey,$cName='',$ar=array())
3946
	{
3947
		$exclude=false;
3948
		if(!isset($this->pathAttribs[$fKey]))
3949
		{
3950
			foreach($ar as $path)
3951
			{
3952
				$pos=strpos($cName,'/'.$path.'/');
3953
				if ($pos===false)
3954
				{
3955
					continue;
3956
				} else {
3957
					$exclude=true;
3958
					break;
3959
				}
3960
			}
3961
			$this->pathAttribs[$fKey]=$exclude;
3962
		}
3963
		return $this->pathAttribs[$fKey];
3964
	}
3965
	function _unsetPathAttribs()
3966
	{
3967
		foreach($this->pathAttribs as $key=>$value)
3968
		{
3969
			if (!$value)
3970
			{
3971
				unset($this->pathAttribs[$key]);
3972
			}
3973
		}
3974
	}
3975
	function _excludeExt($cName='',$ar=array())
3976
	{
3977
		$fI=pathinfo($cName);
3978
		return in_array($fI['extension'],$ar);
3979
	}
3980
		
3981
	function _isDisallowedFileOrPath($fKey='',$fName='',$extPath='')
3982
	{
3983
		$isDisallowed=false;
3984
		if ($this->noFurtherCheck)
3985
		{
3986
			return $isDisallowed;
3987
		}
3988
		if ($this->disallowedToTransfer==null)
3989
		{
3990
			$this->disallowedToTransfer=$this->_setDisallowedArray();
3991
			if (!is_array($this->disallowedToTransfer))
3992
			{
3993
				$this->noFurtherCheck=true;
3994
			}	
3995
		}
3996
		if ($this->noFurtherCheck)
3997
		{
3998
			return $isDisallowed;
3999
		}
4000
		$cName=$this->_getCName($fName,$extPath);
4001
		/*
4002
		 * We have to reset all NONE setted, i.e. value=false
4003
		 * otherwise it won't get checked
4004
		 */
4005
		$this->_unsetPathAttribs(); 
4006
		foreach ($this->disallowedToTransfer as $key=>$array)
4007
		{
4008
			switch($key)
4009
			{
4010
				case 'excludePath':
4011
					$isDisallowed = $isDisallowed || $this->_excludePath($fKey,$cName,$array);
4012
					break;
4013
				case 'excludeExt':
4014
					$isDisallowed = $isDisallowed || $this->_excludeExt($cName,$array);
4015
					break;
4016
				default:
4017
					//not defined items so far
4018
					break;
4019
			}
4020
			if ($isDisallowed)
4021
			{
4022
				break;
4023
			}
4024
		}
4025
		return $isDisallowed;
4026
	}
4027
	function _isHiddenWin($fName='',$extPath='')
3888 4028
	{
3889 4029
		/*
3890 4030
		 * On windows S and H attribute is set on index 3 or 4
......
3893 4033
		$str=substr(exec('attrib '.$fName),0,6);
3894 4034
		$isHidden=strpos($str,'S') || strpos($str,'H');
3895 4035
		$isHidden=($isHidden===false)?false:true;
4036
		$key=$this->_getKey($fName);
3896 4037
		if (!isset($this->pathAttribs[$key]))
3897 4038
		{
3898 4039
			$d=substr((exec('attrib '.dirname($fName))),0,6);
3899 4040
			$this->pathAttribs[$key]=(strpos($d,'S') || strpos($d,'H'));
3900 4041
			$this->pathAttribs[$key]=($this->pathAttribs[$key]===false)?false:true;
3901 4042
		}
4043
		if (!($isHidden && $this->pathAttribs[$key]))
4044
		{
4045
			$isHidden=$this->_isDisallowedFileOrPath($key,$fName,$extPath);
4046
		}
3902 4047
		return ($isHidden || $this->pathAttribs[$key]);
3903 4048
	}
3904
	function _isHiddenNix($key='',$fName='',$extPath='')
4049
	function _getKey($fName)
4050
	{
4051
		return md5(dirname($fName));
4052
	}
4053
	function _getCName($fName='',$extPath='')
4054
	{
4055
		return substr($fName,strlen($extPath)-1);
4056
	}
4057
	function _isHiddenNix($fName='',$extPath='')
3905 4058
	{
3906
		$cName=substr($fName,strlen($extPath)-1);
3907
		$pos=strpos($fName,'/.');
3908
		return ($pos===false)?false:true;
4059
		$cName=$this->_getCName($fName,$extPath);
4060
		$pos=strpos($cName,'/.');
4061
		$isHidden=($pos===false)?false:true;
4062
		if (!$isHidden)
4063
		{
4064
			$key=$this->_getKey($fName);
4065
			$isHidden=$this->_isDisallowedFileOrPath($key,$fName,$extPath);
4066
		}
4067
		return $isHidden;
3909 4068
	}
4069
	/**
4070
	 * Removes hidden files from file array
4071
	 * 
4072
	 * @param array	Array of files
4073
	 * @return array Array of files not hidden or system
4074
	 */
3910 4075
	function removeHiddenFiles($fileArr=array(),$extPath='')
3911 4076
	{
3912 4077
		$fA=array();
3913 4078
		$func=(TYPO3_OS=='WIN')?'_isHiddenWin':'_isHiddenNix';
3914 4079
		foreach($fileArr as $key=>$fName)
3915 4080
		{
3916
			if (! $this->$func($key,$fName,$extPath))
4081
			if (! $this->$func($fName,$extPath))
3917 4082
			{
3918 4083
				$fA[$key]=$fName;
3919 4084
			}
3920 4085
		}
3921 4086
		return $fA;
3922 4087
	}
3923
//prs- 01.08.2006
3924 4088
	/**
3925 4089
	 * Make upload array out of extension
3926 4090
	 *
......
4006 4170
	 * @see makeUploadArray()
4007 4171
	 */
4008 4172
	function getSerializedLocalLang($file,$content)	{
4173
		global $LOCAL_LANG;
4009 4174
		$returnParts = explode('$LOCAL_LANG',$content,2);
4010 4175

  
4011 4176
		include($file);
(4-4/9)