Project

General

Profile

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

Administrator Admin, 2006-08-04 13:49

View differences:

class.em_index.php 4 Aug 2006 11:31:32 -0000
/**
* Module: Extension manager
*
* $Id: class.em_index.php,v 1.1 2006/08/01 12:04:25 pruss Exp $
* $Id: class.em_index.php,v 1.2 2006/08/03 11:33:04 pruss Exp $
*
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
* @author Karsten Dambekalns <karsten@typo3.org>
......
var $listRemote; // If set, connects to remote repository
var $lookUpStr; // Search string when listing local extensions
//prs+ 01.08.2006
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
/*********************************
......
</td>
</tr>
<tr class="bgColor4">
<td>Exclude hidden files:</td>
<td nowrap="nowrap">
<input type="checkbox" name="em[upload][exclude]" value="1" checked="checked" />
</td>
</tr>
<tr class="bgColor4">
<td>&nbsp;</td>
<td><input type="submit" name="submit" value="Upload extension" />
</td>
......
$lines .= str_repeat(chr(9),$level-1).')'.($level-1==0 ? '':','.chr(10));
return $lines;
}
/**
* Checks if there are some preset in localconf.php or TSCONFIG
*
*/
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 _getKey($fName)
{
return md5(dirname($fName));
}
function _getCName($fName='',$extPath='')
{
return substr($fName,strlen($extPath)-1);
}
function _isHiddenNix($fName='',$extPath='')
{
$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($fName,$extPath))
{
$fA[$key]=$fName;
}
}
return $fA;
}
/**
* Make upload array out of extension
*
......
$fileArr = array();
$fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr,$extPath);
//prs+ 01.08.2006
if ($this->excludeHidden)
{
//remove hidden or system files from fileArr;
$fileArr=$this->removeHiddenFiles($fileArr,$extPath);
}
//prs- 01.08.2006
// Calculate the total size of those files:
$totalSize = 0;
foreach($fileArr as $file) {
......
* @see makeUploadArray()
*/
function getSerializedLocalLang($file,$content) {
global $LOCAL_LANG;
$returnParts = explode('$LOCAL_LANG',$content,2);
include($file);
......
*/
function uploadExtensionToTER($em) {
$msg = '';
//prs+ 01.08.2006
$this->excludeHidden=isset($em['upload']['exclude'])&& $em['upload']['exclude'];
//prs- 01.08.2006
$response = $this->terConnection->uploadToTER($em);
if(!is_array($response)) return $response;
(3-3/9)