Bug #22158 ยป t3lib_div-self.patch
t3lib/class.t3lib_div.php (working copy) | ||
---|---|---|
if(empty($var)) return;
|
||
$value = isset($_POST[$var]) ? $_POST[$var] : $_GET[$var];
|
||
if (isset($value)) {
|
||
if (is_array($value)) { t3lib_div::stripSlashesOnArray($value); } else { $value = stripslashes($value); }
|
||
if (is_array($value)) { self::stripSlashesOnArray($value); } else { $value = stripslashes($value); }
|
||
}
|
||
return $value;
|
||
}
|
||
... | ... | |
$postParameter = is_array($_POST[$parameter]) ? $_POST[$parameter] : array();
|
||
$getParameter = is_array($_GET[$parameter]) ? $_GET[$parameter] : array();
|
||
$mergedParameters = t3lib_div::array_merge_recursive_overrule($getParameter, $postParameter);
|
||
t3lib_div::stripSlashesOnArray($mergedParameters);
|
||
$mergedParameters = self::array_merge_recursive_overrule($getParameter, $postParameter);
|
||
self::stripSlashesOnArray($mergedParameters);
|
||
return $mergedParameters;
|
||
}
|
||
... | ... | |
public static function _GET($var=NULL) {
|
||
$value = ($var === NULL) ? $_GET : (empty($var) ? NULL : $_GET[$var]);
|
||
if (isset($value)) { // Removes slashes since TYPO3 has added them regardless of magic_quotes setting.
|
||
if (is_array($value)) { t3lib_div::stripSlashesOnArray($value); } else { $value = stripslashes($value); }
|
||
if (is_array($value)) { self::stripSlashesOnArray($value); } else { $value = stripslashes($value); }
|
||
}
|
||
return $value;
|
||
}
|
||
... | ... | |
public static function _POST($var=NULL) {
|
||
$value = ($var === NULL) ? $_POST : (empty($var) ? NULL : $_POST[$var]);
|
||
if (isset($value)) { // Removes slashes since TYPO3 has added them regardless of magic_quotes setting.
|
||
if (is_array($value)) { t3lib_div::stripSlashesOnArray($value); } else { $value = stripslashes($value); }
|
||
if (is_array($value)) { self::stripSlashesOnArray($value); } else { $value = stripslashes($value); }
|
||
}
|
||
return $value;
|
||
}
|
||
... | ... | |
// ADDS slashes since TYPO3 standard currently is that slashes MUST be applied (regardless of magic_quotes setting).
|
||
if (strcmp($key,'')) {
|
||
if (is_array($inputGet)) {
|
||
t3lib_div::addSlashesOnArray($inputGet);
|
||
self::addSlashesOnArray($inputGet);
|
||
} else {
|
||
$inputGet = addslashes($inputGet);
|
||
}
|
||
$GLOBALS['HTTP_GET_VARS'][$key] = $_GET[$key] = $inputGet;
|
||
} elseif (is_array($inputGet)) {
|
||
t3lib_div::addSlashesOnArray($inputGet);
|
||
self::addSlashesOnArray($inputGet);
|
||
$GLOBALS['HTTP_GET_VARS'] = $_GET = $inputGet;
|
||
}
|
||
}
|
||
... | ... | |
if(empty($var)) return;
|
||
$value = isset($_POST[$var]) ? $_POST[$var] : $_GET[$var];
|
||
if (isset($value) && is_string($value)) { $value = stripslashes($value); } // Originally check '&& get_magic_quotes_gpc() ' but the values of $_GET are always slashed regardless of get_magic_quotes_gpc() because HTTP_POST/GET_VARS are run through addSlashesOnArray in the very beginning of index_ts.php eg.
|
||
if ($strip && isset($value) && is_array($value)) { t3lib_div::stripSlashesOnArray($value); }
|
||
if ($strip && isset($value) && is_array($value)) { self::stripSlashesOnArray($value); }
|
||
return $value;
|
||
}
|
||
... | ... | |
$returnCode='';
|
||
if ($gfxConf['gif_compress'] && strtolower(substr($theFile,-4,4))=='.gif') { // GIF...
|
||
if (($type=='IM' || !$type) && $gfxConf['im'] && $gfxConf['im_path_lzw']) { // IM
|
||
$cmd = t3lib_div::imageMagickCommand('convert', '"'.$theFile.'" "'.$theFile.'"', $gfxConf['im_path_lzw']);
|
||
$cmd = self::imageMagickCommand('convert', '"'.$theFile.'" "'.$theFile.'"', $gfxConf['im_path_lzw']);
|
||
exec($cmd);
|
||
$returnCode='IM';
|
||
... | ... | |
&& strtolower(substr($theFile,-4,4))=='.png'
|
||
&& @is_file($theFile)) { // IM
|
||
$newFile = substr($theFile,0,-4).'.gif';
|
||
$cmd = t3lib_div::imageMagickCommand('convert', '"'.$theFile.'" "'.$newFile.'"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']);
|
||
$cmd = self::imageMagickCommand('convert', '"'.$theFile.'" "'.$newFile.'"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']);
|
||
exec($cmd);
|
||
$theFile = $newFile;
|
||
// unlink old file?? May be bad idea bacause TYPO3 would then recreate the file every time as TYPO3 thinks the file is not generated because it's missing!! So do not unlink $theFile here!!
|
||
... | ... | |
return $theFile;
|
||
} else {
|
||
$newFile = PATH_site.'typo3temp/readPG_'.md5($theFile.'|'.filemtime($theFile)).($output_png?'.png':'.gif');
|
||
$cmd = t3lib_div::imageMagickCommand('convert', '"'.$theFile.'" "'.$newFile.'"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path']);
|
||
$cmd = self::imageMagickCommand('convert', '"'.$theFile.'" "'.$newFile.'"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path']);
|
||
exec($cmd);
|
||
if (@is_file($newFile)) return $newFile;
|
||
}
|
||
... | ... | |
public static function fixed_lgd_pre($string,$chars) {
|
||
self::logDeprecatedFunction();
|
||
return strrev(t3lib_div::fixed_lgd(strrev($string),$chars));
|
||
return strrev(self::fixed_lgd(strrev($string),$chars));
|
||
}
|
||
/**
|
||
... | ... | |
return $GLOBALS['TSFE']->csConvObj->crop($charSet, $string, $chars, $appendString);
|
||
} else {
|
||
// this case should not happen
|
||
$csConvObj = t3lib_div::makeInstance('t3lib_cs');
|
||
$csConvObj = self::makeInstance('t3lib_cs');
|
||
return $csConvObj->crop('iso-8859-1', $string, $chars, $appendString);
|
||
}
|
||
}
|
||
... | ... | |
$lines = explode(chr(10),$str);
|
||
$outArr=array();
|
||
foreach ($lines as $lStr) {
|
||
$outArr[] = t3lib_div::breakLinesForEmail($lStr,$implChar,$charWidth);
|
||
$outArr[] = self::breakLinesForEmail($lStr,$implChar,$charWidth);
|
||
}
|
||
return implode(chr(10),$outArr);
|
||
}
|
||
... | ... | |
} elseif ($list === '*') {
|
||
return true;
|
||
}
|
||
if (strpos($baseIP, ':') !== false && t3lib_div::validIPv6($baseIP)) {
|
||
return t3lib_div::cmpIPv6($baseIP, $list);
|
||
if (strpos($baseIP, ':') !== false && self::validIPv6($baseIP)) {
|
||
return self::cmpIPv6($baseIP, $list);
|
||
} else {
|
||
return t3lib_div::cmpIPv4($baseIP, $list);
|
||
return self::cmpIPv4($baseIP, $list);
|
||
}
|
||
}
|
||
... | ... | |
public static function cmpIPv4($baseIP, $list) {
|
||
$IPpartsReq = explode('.',$baseIP);
|
||
if (count($IPpartsReq)==4) {
|
||
$values = t3lib_div::trimExplode(',',$list,1);
|
||
$values = self::trimExplode(',',$list,1);
|
||
foreach($values as $test) {
|
||
list($test,$mask) = explode('/',$test);
|
||
... | ... | |
*/
|
||
public static function cmpIPv6($baseIP, $list) {
|
||
$success = false; // Policy default: Deny connection
|
||
$baseIP = t3lib_div::normalizeIPv6($baseIP);
|
||
$baseIP = self::normalizeIPv6($baseIP);
|
||
$values = t3lib_div::trimExplode(',',$list,1);
|
||
$values = self::trimExplode(',',$list,1);
|
||
foreach ($values as $test) {
|
||
list($test,$mask) = explode('/',$test);
|
||
if (t3lib_div::validIPv6($test)) {
|
||
$test = t3lib_div::normalizeIPv6($test);
|
||
if (self::validIPv6($test)) {
|
||
$test = self::normalizeIPv6($test);
|
||
if (intval($mask)) {
|
||
switch ($mask) { // test on /48 /64
|
||
case '48':
|
||
$testBin = substr(t3lib_div::IPv6Hex2Bin($test), 0, 48);
|
||
$baseIPBin = substr(t3lib_div::IPv6Hex2Bin($baseIP), 0, 48);
|
||
$testBin = substr(self::IPv6Hex2Bin($test), 0, 48);
|
||
$baseIPBin = substr(self::IPv6Hex2Bin($baseIP), 0, 48);
|
||
$success = strcmp($testBin, $baseIPBin)==0 ? true : false;
|
||
break;
|
||
case '64':
|
||
$testBin = substr(t3lib_div::IPv6Hex2Bin($test), 0, 64);
|
||
$baseIPBin = substr(t3lib_div::IPv6Hex2Bin($baseIP), 0, 64);
|
||
$testBin = substr(self::IPv6Hex2Bin($test), 0, 64);
|
||
$baseIPBin = substr(self::IPv6Hex2Bin($baseIP), 0, 64);
|
||
$success = strcmp($testBin, $baseIPBin)==0 ? true : false;
|
||
break;
|
||
default:
|
||
$success = false;
|
||
}
|
||
} else {
|
||
if (t3lib_div::validIPv6($test)) { // test on full ip address 128 bits
|
||
$testBin = t3lib_div::IPv6Hex2Bin($test);
|
||
$baseIPBin = t3lib_div::IPv6Hex2Bin($baseIP);
|
||
if (self::validIPv6($test)) { // test on full ip address 128 bits
|
||
$testBin = self::IPv6Hex2Bin($test);
|
||
$baseIPBin = self::IPv6Hex2Bin($baseIP);
|
||
$success = strcmp($testBin, $baseIPBin)==0 ? true : false;
|
||
}
|
||
}
|
||
... | ... | |
public static function cmpFQDN($baseIP, $list) {
|
||
if (count(explode('.',$baseIP))==4) {
|
||
$resolvedHostName = explode('.', gethostbyaddr($baseIP));
|
||
$values = t3lib_div::trimExplode(',',$list,1);
|
||
$values = self::trimExplode(',',$list,1);
|
||
foreach($values as $test) {
|
||
$hostNameParts = explode('.',$test);
|
||
... | ... | |
global $TYPO3_CONF_VARS;
|
||
$currVersionStr = $TYPO3_CONF_VARS['SYS']['compat_version'] ? $TYPO3_CONF_VARS['SYS']['compat_version'] : TYPO3_branch;
|
||
if (t3lib_div::int_from_ver($currVersionStr) < t3lib_div::int_from_ver($verNumberStr)) {
|
||
if (self::int_from_ver($currVersionStr) < self::int_from_ver($verNumberStr)) {
|
||
return FALSE;
|
||
} else {
|
||
return TRUE;
|
||
... | ... | |
if (is_array($in_list)) die('t3lib_div::uniqueList() does NOT support array arguments anymore! Only string comma lists!');
|
||
if (isset($secondParameter)) die('t3lib_div::uniqueList() does NOT support more than a single argument value anymore. You have specified more than one.');
|
||
return implode(',',array_unique(t3lib_div::trimExplode(',',$in_list,1)));
|
||
return implode(',',array_unique(self::trimExplode(',',$in_list,1)));
|
||
}
|
||
/**
|
||
... | ... | |
* @return string Processed input value. See function description.
|
||
*/
|
||
public static function dirname($path) {
|
||
$p = t3lib_div::revExplode('/',$path,2);
|
||
$p = self::revExplode('/',$path,2);
|
||
return count($p)==2 ? $p[0] : '';
|
||
}
|
||
... | ... | |
*/
|
||
public static function modifyHTMLColor($color,$R,$G,$B) {
|
||
// This takes a hex-color (# included!) and adds $R, $G and $B to the HTML-color (format: #xxxxxx) and returns the new color
|
||
$nR = t3lib_div::intInRange(hexdec(substr($color,1,2))+$R,0,255);
|
||
$nG = t3lib_div::intInRange(hexdec(substr($color,3,2))+$G,0,255);
|
||
$nB = t3lib_div::intInRange(hexdec(substr($color,5,2))+$B,0,255);
|
||
$nR = self::intInRange(hexdec(substr($color,1,2))+$R,0,255);
|
||
$nG = self::intInRange(hexdec(substr($color,3,2))+$G,0,255);
|
||
$nB = self::intInRange(hexdec(substr($color,5,2))+$B,0,255);
|
||
return '#'.
|
||
substr('0'.dechex($nR),-2).
|
||
substr('0'.dechex($nG),-2).
|
||
... | ... | |
* @see modifyHTMLColor()
|
||
*/
|
||
public static function modifyHTMLColorAll($color,$all) {
|
||
return t3lib_div::modifyHTMLColor($color,$all,$all,$all);
|
||
return self::modifyHTMLColor($color,$all,$all,$all);
|
||
}
|
||
/**
|
||
... | ... | |
$valueLenO=strcspn($string,'(');
|
||
$valueLenC=strcspn($string,')');
|
||
if ($valueLenC==strlen($string) || $valueLenC < $valueLenO) {
|
||
$value = t3lib_div::calcPriority(substr($string,0,$valueLenC));
|
||
$value = self::calcPriority(substr($string,0,$valueLenC));
|
||
$string = $value.substr($string,$valueLenC+1);
|
||
return $string;
|
||
} else {
|
||
$string = substr($string,0,$valueLenO).t3lib_div::calcParenthesis(substr($string,$valueLenO+1));
|
||
$string = substr($string,0,$valueLenO).self::calcParenthesis(substr($string,$valueLenO+1));
|
||
}
|
||
// Security:
|
||
$securC--;
|
||
... | ... | |
public static function removeArrayEntryByValue(array $array, $cmpValue) {
|
||
foreach ($array as $k => $v) {
|
||
if (is_array($v)) {
|
||
$array[$k] = t3lib_div::removeArrayEntryByValue($v, $cmpValue);
|
||
$array[$k] = self::removeArrayEntryByValue($v, $cmpValue);
|
||
} elseif (!strcmp($v, $cmpValue)) {
|
||
unset($array[$k]);
|
||
}
|
||
... | ... | |
if ($array) {
|
||
// Convert strings to arrays:
|
||
if (is_string($keepItems)) {
|
||
$keepItems = t3lib_div::trimExplode(',', $keepItems);
|
||
$keepItems = self::trimExplode(',', $keepItems);
|
||
}
|
||
// create_function() returns a string:
|
||
if (!is_string($getValueFunc)) {
|
||
... | ... | |
foreach($theArray as $Akey => $AVal) {
|
||
$thisKeyName = $name ? $name.'['.$Akey.']' : $Akey;
|
||
if (is_array($AVal)) {
|
||
$str = t3lib_div::implodeArrayForUrl($thisKeyName,$AVal,$str,$skipBlank,$rawurlencodeParamName);
|
||
$str = self::implodeArrayForUrl($thisKeyName,$AVal,$str,$skipBlank,$rawurlencodeParamName);
|
||
} else {
|
||
if (!$skipBlank || strcmp($AVal,'')) {
|
||
$str.='&'.($rawurlencodeParamName ? rawurlencode($thisKeyName) : $thisKeyName).
|
||
... | ... | |
* @return array Output array with selected variables.
|
||
*/
|
||
public static function compileSelectedGetVarsFromArray($varList,array $getArray,$GPvarAlt=1) {
|
||
$keys = t3lib_div::trimExplode(',',$varList,1);
|
||
$keys = self::trimExplode(',',$varList,1);
|
||
$outArr = array();
|
||
foreach($keys as $v) {
|
||
if (isset($getArray[$v])) {
|
||
$outArr[$v] = $getArray[$v];
|
||
} elseif ($GPvarAlt) {
|
||
$outArr[$v] = t3lib_div::_GP($v);
|
||
$outArr[$v] = self::_GP($v);
|
||
}
|
||
}
|
||
return $outArr;
|
||
... | ... | |
public static function addSlashesOnArray(array &$theArray) {
|
||
foreach ($theArray as &$value) {
|
||
if (is_array($value)) {
|
||
t3lib_div::addSlashesOnArray($value);
|
||
self::addSlashesOnArray($value);
|
||
} else {
|
||
$value = addslashes($value);
|
||
}
|
||
... | ... | |
public static function stripSlashesOnArray(array &$theArray) {
|
||
foreach ($theArray as &$value) {
|
||
if (is_array($value)) {
|
||
t3lib_div::stripSlashesOnArray($value);
|
||
self::stripSlashesOnArray($value);
|
||
} else {
|
||
$value = stripslashes($value);
|
||
}
|
||
... | ... | |
* @return array
|
||
*/
|
||
public static function slashArray(array $arr,$cmd) {
|
||
if ($cmd=='strip') t3lib_div::stripSlashesOnArray($arr);
|
||
if ($cmd=='add') t3lib_div::addSlashesOnArray($arr);
|
||
if ($cmd=='strip') self::stripSlashesOnArray($arr);
|
||
if ($cmd=='add') self::addSlashesOnArray($arr);
|
||
return $arr;
|
||
}
|
||
... | ... | |
foreach ($arr1 as $key => $val) {
|
||
if(is_array($arr0[$key])) {
|
||
if (is_array($arr1[$key])) {
|
||
$arr0[$key] = t3lib_div::array_merge_recursive_overrule($arr0[$key],$arr1[$key],$notAddKeys,$includeEmtpyValues);
|
||
$arr0[$key] = self::array_merge_recursive_overrule($arr0[$key],$arr1[$key],$notAddKeys,$includeEmtpyValues);
|
||
}
|
||
} else {
|
||
if ($notAddKeys) {
|
||
... | ... | |
foreach ($ts as $key => $value) {
|
||
if (is_array($value)) {
|
||
$key = rtrim($key, '.');
|
||
$out[$key] = t3lib_div::removeDotsFromTS($value);
|
||
$out[$key] = self::removeDotsFromTS($value);
|
||
} else {
|
||
$out[$key] = $value;
|
||
}
|
||
... | ... | |
* @return array Array with the attribute values.
|
||
*/
|
||
public static function get_tag_attributes($tag) {
|
||
$components = t3lib_div::split_tag_attributes($tag);
|
||
$components = self::split_tag_attributes($tag);
|
||
$name = ''; // attribute name is stored here
|
||
$valuemode = false;
|
||
$attributes = array();
|
||
... | ... | |
public static function implodeParams(array $arr,$xhtmlSafe=FALSE,$dontOmitBlankAttribs=FALSE) {
|
||
self::logDeprecatedFunction();
|
||
return t3lib_div::implodeAttributes($arr,$xhtmlSafe,$dontOmitBlankAttribs);
|
||
return self::implodeAttributes($arr,$xhtmlSafe,$dontOmitBlankAttribs);
|
||
}
|
||
/**
|
||
... | ... | |
$startPoint+1,
|
||
$key-$startPoint-1
|
||
);
|
||
#$oldtagi=array('XMLvalue'=>t3lib_div::xmlRecompileFromStructValArray($partArray));
|
||
$oldtagi['XMLvalue']=t3lib_div::xmlRecompileFromStructValArray($partArray);
|
||
#$oldtagi=array('XMLvalue'=>self::xmlRecompileFromStructValArray($partArray));
|
||
$oldtagi['XMLvalue']=self::xmlRecompileFromStructValArray($partArray);
|
||
} else {
|
||
$oldtagi['XMLvalue']=$oldtagi['values'][0];
|
||
}
|
||
... | ... | |
// Return XML:
|
||
return '<?xml version="1.0" encoding="'.htmlspecialchars($charset).'" standalone="yes" ?>'.chr(10).
|
||
t3lib_div::array2xml($array,'',0,$docTag,0, $options);
|
||
self::array2xml($array,'',0,$docTag,0, $options);
|
||
}
|
||
/**
|
||
... | ... | |
if(isset($options['grandParentTagMap'][$stackData['grandParentTagName'].'/'.$stackData['parentTagName']])) { // Use tag based on grand-parent + parent tag name
|
||
$attr.=' index="'.htmlspecialchars($tagName).'"';
|
||
$tagName = (string)$options['grandParentTagMap'][$stackData['grandParentTagName'].'/'.$stackData['parentTagName']];
|
||
}elseif(isset($options['parentTagMap'][$stackData['parentTagName'].':_IS_NUM']) && t3lib_div::testInt($tagName)) { // Use tag based on parent tag name + if current tag is numeric
|
||
}elseif(isset($options['parentTagMap'][$stackData['parentTagName'].':_IS_NUM']) && self::testInt($tagName)) { // Use tag based on parent tag name + if current tag is numeric
|
||
$attr.=' index="'.htmlspecialchars($tagName).'"';
|
||
$tagName = (string)$options['parentTagMap'][$stackData['parentTagName'].':_IS_NUM'];
|
||
}elseif(isset($options['parentTagMap'][$stackData['parentTagName'].':'.$tagName])) { // Use tag based on parent tag name + current tag
|
||
... | ... | |
}
|
||
$content = $nl .
|
||
t3lib_div::array2xml(
|
||
self::array2xml(
|
||
$v,
|
||
$NSprefix,
|
||
$level+1,
|
||
... | ... | |
public static function xmlGetHeaderAttribs($xmlData) {
|
||
$match = array();
|
||
if (preg_match('/^\s*<\?xml([^>]*)\?\>/', $xmlData, $match)) {
|
||
return t3lib_div::get_tag_attributes($match[1]);
|
||
return self::get_tag_attributes($match[1]);
|
||
}
|
||
}
|
||
... | ... | |
}
|
||
catch(JSMinException $e) {
|
||
$error = 'Error while minifying JavaScript: ' . $e->getMessage();
|
||
t3lib_div::devLog($error, 't3lib_div', 2,
|
||
self::devLog($error, 't3lib_div', 2,
|
||
array('JavaScript' => $script, 'Stack trace' => $e->getTrace()));
|
||
}
|
||
return $script;
|
||
... | ... | |
if ($res===false) return false;
|
||
if ($changePermissions) { // Change the permissions only if the file has just been created
|
||
t3lib_div::fixPermissions($file);
|
||
self::fixPermissions($file);
|
||
}
|
||
return true;
|
||
... | ... | |
$fI['dirname'].= '/';
|
||
// Check parts:
|
||
if (t3lib_div::validPathStr($filepath) && $fI['basename'] && strlen($fI['basename'])<60) {
|
||
if (self::validPathStr($filepath) && $fI['basename'] && strlen($fI['basename'])<60) {
|
||
if (defined('PATH_site')) {
|
||
$dirName = PATH_site.'typo3temp/'; // Setting main temporary directory name (standard)
|
||
if (@is_dir($dirName)) {
|
||
if (t3lib_div::isFirstPartOfStr($fI['dirname'],$dirName)) {
|
||
if (self::isFirstPartOfStr($fI['dirname'],$dirName)) {
|
||
// Checking if the "subdir" is found:
|
||
$subdir = substr($fI['dirname'],strlen($dirName));
|
||
... | ... | |
if (preg_match('/^[[:alnum:]_]+\/$/',$subdir) || preg_match('/^[[:alnum:]_]+\/[[:alnum:]_]+\/$/',$subdir)) {
|
||
$dirName.= $subdir;
|
||
if (!@is_dir($dirName)) {
|
||
t3lib_div::mkdir_deep(PATH_site.'typo3temp/', $subdir);
|
||
self::mkdir_deep(PATH_site.'typo3temp/', $subdir);
|
||
}
|
||
} else return 'Subdir, "'.$subdir.'", was NOT on the form "[[:alnum:]_]/" or "[[:alnum:]_]/[[:alnum:]_]/"';
|
||
}
|
||
// Checking dir-name again (sub-dir might have been created):
|
||
if (@is_dir($dirName)) {
|
||
if ($filepath == $dirName.$fI['basename']) {
|
||
t3lib_div::writeFile($filepath, $content);
|
||
self::writeFile($filepath, $content);
|
||
if (!@is_file($filepath)) return 'File not written to disk! Write permission error in filesystem?';
|
||
} else return 'Calculated filelocation didn\'t match input $filepath!';
|
||
} else return '"'.$dirName.'" is not a directory!';
|
||
... | ... | |
* @return string If error, returns error string.
|
||
*/
|
||
public static function mkdir_deep($destination,$deepDir) {
|
||
$allParts = t3lib_div::trimExplode('/',$deepDir,1);
|
||
$allParts = self::trimExplode('/',$deepDir,1);
|
||
$root = '';
|
||
foreach($allParts as $part) {
|
||
$root.= $part.'/';
|
||
if (!is_dir($destination.$root)) {
|
||
t3lib_div::mkdir($destination.$root);
|
||
self::mkdir($destination.$root);
|
||
if (!@is_dir($destination.$root)) {
|
||
return 'Error: The directory "'.$destination.$root.'" could not be created...';
|
||
}
|
||
... | ... | |
if ($removeNonEmpty==true && $handle = opendir($path)) {
|
||
while ($OK && false !== ($file = readdir($handle))) {
|
||
if ($file=='.' || $file=='..') continue;
|
||
$OK = t3lib_div::rmdir($path.'/'.$file,$removeNonEmpty);
|
||
$OK = self::rmdir($path.'/'.$file,$removeNonEmpty);
|
||
}
|
||
closedir($handle);
|
||
}
|
||
... | ... | |
if (@is_file($path.'/'.$entry)) {
|
||
$fI = pathinfo($entry);
|
||
$key = md5($path.'/'.$entry); // Don't change this ever - extensions may depend on the fact that the hash is an md5 of the path! (import/export extension)
|
||
if ((!strlen($extensionList) || t3lib_div::inList($extensionList,strtolower($fI['extension']))) && (!strlen($excludePattern) || !preg_match('/^'.$excludePattern.'$/',$entry))) {
|
||
if ((!strlen($extensionList) || self::inList($extensionList,strtolower($fI['extension']))) && (!strlen($excludePattern) || !preg_match('/^'.$excludePattern.'$/',$entry))) {
|
||
$filearray[$key]=($prependPath?$path.'/':'').$entry;
|
||
if ($order=='mtime') {$sortarray[$key]=filemtime($path.'/'.$entry);}
|
||
elseif ($order) {$sortarray[$key]=$entry;}
|
||
... | ... | |
*/
|
||
public static function getAllFilesAndFoldersInPath(array $fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99,$excludePattern='') {
|
||
if ($regDirs) $fileArr[] = $path;
|
||
$fileArr = array_merge($fileArr, t3lib_div::getFilesInDir($path,$extList,1,1,$excludePattern));
|
||
$fileArr = array_merge($fileArr, self::getFilesInDir($path,$extList,1,1,$excludePattern));
|
||
$dirs = t3lib_div::get_dirs($path);
|
||
$dirs = self::get_dirs($path);
|
||
if (is_array($dirs) && $recursivityLevels>0) {
|
||
foreach ($dirs as $subdirs) {
|
||
if ((string)$subdirs!='' && (!strlen($excludePattern) || !preg_match('/^'.$excludePattern.'$/',$subdirs))) {
|
||
$fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr,$path.$subdirs.'/',$extList,$regDirs,$recursivityLevels-1,$excludePattern);
|
||
$fileArr = self::getAllFilesAndFoldersInPath($fileArr,$path.$subdirs.'/',$extList,$regDirs,$recursivityLevels-1,$excludePattern);
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
*/
|
||
public static function removePrefixPathFromList(array $fileArr,$prefixToRemove) {
|
||
foreach ($fileArr as $k => &$absFileRef) {
|
||
if (t3lib_div::isFirstPartOfStr($absFileRef, $prefixToRemove)) {
|
||
if (self::isFirstPartOfStr($absFileRef, $prefixToRemove)) {
|
||
$absFileRef = substr($absFileRef, strlen($prefixToRemove));
|
||
} else {
|
||
return 'ERROR: One or more of the files was NOT prefixed with the prefix-path!';
|
||
... | ... | |
public static function locationHeaderUrl($path) {
|
||
$uI = parse_url($path);
|
||
if (substr($path,0,1)=='/') { // relative to HOST
|
||
$path = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').$path;
|
||
$path = self::getIndpEnv('TYPO3_REQUEST_HOST').$path;
|
||
} elseif (!$uI['scheme']) { // No scheme either
|
||
$path = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').$path;
|
||
$path = self::getIndpEnv('TYPO3_REQUEST_DIR').$path;
|
||
}
|
||
return $path;
|
||
}
|
||
... | ... | |
<td valign="top"><font face="Verdana,Arial" size="1">'.htmlspecialchars((string)$key).'</font></td>
|
||
<td>';
|
||
if (is_array($val)) {
|
||
$result.=t3lib_div::view_array($val);
|
||
$result.=self::view_array($val);
|
||
} elseif (is_object($val)) {
|
||
$string = get_class($val);
|
||
if (method_exists($val, '__toString')) {
|
||
... | ... | |
* @see view_array()
|
||
*/
|
||
public static function print_array($array_in) {
|
||
echo t3lib_div::view_array($array_in);
|
||
echo self::view_array($array_in);
|
||
}
|
||
/**
|
||
... | ... | |
ob_start();
|
||
}
|
||
if ($brOrHeader && !t3lib_div::testInt($brOrHeader)) {
|
||
if ($brOrHeader && !self::testInt($brOrHeader)) {
|
||
echo '<table class="typo3-debug" border="0" cellpadding="0" cellspacing="0" bgcolor="white" style="border:0px; margin-top:3px; margin-bottom:3px;"><tr><td style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;">'.htmlspecialchars((string)$brOrHeader).'</td></tr><tr><td>';
|
||
} elseif ($brOrHeader<0) {
|
||
for($a=0;$a<abs(intval($brOrHeader));$a++){echo '<br />';}
|
||
}
|
||
if (is_array($var)) {
|
||
t3lib_div::print_array($var);
|
||
self::print_array($var);
|
||
} elseif (is_object($var)) {
|
||
echo '<b>|Object:<pre>';
|
||
print_r($var);
|
||
... | ... | |
echo '<b>| debug |</b>';
|
||
}
|
||
if ($brOrHeader && !t3lib_div::testInt($brOrHeader)) {
|
||
if ($brOrHeader && !self::testInt($brOrHeader)) {
|
||
echo '</td></tr></table>';
|
||
} elseif ($brOrHeader>0) {
|
||
for($a=0;$a<intval($brOrHeader);$a++){echo '<br />';}
|
||
... | ... | |
$tCells = array();
|
||
foreach($headerColumns as $key) {
|
||
$tCells[] = '
|
||
<td><font face="Verdana,Arial" size="1">'.(is_array($singleRow[$key]) ? t3lib_div::debugRows($singleRow[$key],'',TRUE) : htmlspecialchars($singleRow[$key])).'</font></td>';
|
||
<td><font face="Verdana,Arial" size="1">'.(is_array($singleRow[$key]) ? self::debugRows($singleRow[$key],'',TRUE) : htmlspecialchars($singleRow[$key])).'</font></td>';
|
||
}
|
||
$tRows[] = '
|
||
<tr>'.implode('',$tCells).'
|
||
... | ... | |
* @return string
|
||
*/
|
||
public static function getThisUrl() {
|
||
$p=parse_url(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')); // Url of this script
|
||
$dir=t3lib_div::dirname($p['path']).'/'; // Strip file
|
||
$p=parse_url(self::getIndpEnv('TYPO3_REQUEST_SCRIPT')); // Url of this script
|
||
$dir=self::dirname($p['path']).'/'; // Strip file
|
||
$url = str_replace('//','/',$p['host'].($p['port']?':'.$p['port']:'').$dir);
|
||
return $url;
|
||
}
|
||
... | ... | |
* @return string
|
||
*/
|
||
public static function linkThisScript(array $getParams = array()) {
|
||
$parts = t3lib_div::getIndpEnv('SCRIPT_NAME');
|
||
$params = t3lib_div::_GET();
|
||
$parts = self::getIndpEnv('SCRIPT_NAME');
|
||
$params = self::_GET();
|
||
foreach ($getParams as $key => $value) {
|
||
if ($value !== '') {
|
||
... | ... | |
}
|
||
}
|
||
$pString = t3lib_div::implodeArrayForUrl('', $params);
|
||
$pString = self::implodeArrayForUrl('', $params);
|
||
return $pString ? $parts . '?' . preg_replace('/^&/', '', $pString) : $parts;
|
||
}
|
||
... | ... | |
if ($parts['query']) {
|
||
parse_str($parts['query'],$getP);
|
||
}
|
||
$getP = t3lib_div::array_merge_recursive_overrule($getP,$getParams);
|
||
$getP = self::array_merge_recursive_overrule($getP,$getParams);
|
||
$uP = explode('?',$url);
|
||
$params = t3lib_div::implodeArrayForUrl('',$getP);
|
||
$params = self::implodeArrayForUrl('',$getP);
|
||
$outurl = $uP[0].($params ? '?'.substr($params, 1) : '');
|
||
return $outurl;
|
||
... | ... | |
case 'SCRIPT_NAME':
|
||
$retVal = (PHP_SAPI=='cgi'||PHP_SAPI=='cgi-fcgi')&&($_SERVER['ORIG_PATH_INFO']?$_SERVER['ORIG_PATH_INFO']:$_SERVER['PATH_INFO']) ? ($_SERVER['ORIG_PATH_INFO']?$_SERVER['ORIG_PATH_INFO']:$_SERVER['PATH_INFO']) : ($_SERVER['ORIG_SCRIPT_NAME']?$_SERVER['ORIG_SCRIPT_NAME']:$_SERVER['SCRIPT_NAME']);
|
||
// add a prefix if TYPO3 is behind a proxy: ext-domain.com => int-server.com/prefix
|
||
if (t3lib_div::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
|
||
if (t3lib_div::getIndpEnv('TYPO3_SSL') && $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL']) {
|
||
if (self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
|
||
if (self::getIndpEnv('TYPO3_SSL') && $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL']) {
|
||
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'].$retVal;
|
||
} elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix']) {
|
||
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'].$retVal;
|
||
... | ... | |
list($v,$n) = explode('|',$GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar']);
|
||
$retVal = $GLOBALS[$v][$n];
|
||
} elseif (!$_SERVER['REQUEST_URI']) { // This is for ISS/CGI which does not have the REQUEST_URI available.
|
||
$retVal = '/'.ltrim(t3lib_div::getIndpEnv('SCRIPT_NAME'), '/').
|
||
$retVal = '/'.ltrim(self::getIndpEnv('SCRIPT_NAME'), '/').
|
||
($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:'');
|
||
} else {
|
||
$retVal = $_SERVER['REQUEST_URI'];
|
||
}
|
||
// add a prefix if TYPO3 is behind a proxy: ext-domain.com => int-server.com/prefix
|
||
if (t3lib_div::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
|
||
if (t3lib_div::getIndpEnv('TYPO3_SSL') && $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL']) {
|
||
if (self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
|
||
if (self::getIndpEnv('TYPO3_SSL') && $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL']) {
|
||
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'].$retVal;
|
||
} elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix']) {
|
||
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'].$retVal;
|
||
... | ... | |
// $_SERVER['PATH_INFO']!=$_SERVER['SCRIPT_NAME'] is necessary because some servers (Windows/CGI) are seen to set PATH_INFO equal to script_name
|
||
// Further, there must be at least one '/' in the path - else the PATH_INFO value does not make sense.
|
||
// IF 'PATH_INFO' never works for our purpose in TYPO3 with CGI-servers, then 'PHP_SAPI=='cgi'' might be a better check. Right now strcmp($_SERVER['PATH_INFO'],t3lib_div::getIndpEnv('SCRIPT_NAME')) will always return false for CGI-versions, but that is only as long as SCRIPT_NAME is set equal to PATH_INFO because of PHP_SAPI=='cgi' (see above)
|
||
// if (strcmp($_SERVER['PATH_INFO'],t3lib_div::getIndpEnv('SCRIPT_NAME')) && count(explode('/',$_SERVER['PATH_INFO']))>1) {
|
||
// if (strcmp($_SERVER['PATH_INFO'],self::getIndpEnv('SCRIPT_NAME')) && count(explode('/',$_SERVER['PATH_INFO']))>1) {
|
||
if (PHP_SAPI!='cgi' && PHP_SAPI!='cgi-fcgi') {
|
||
$retVal = $_SERVER['PATH_INFO'];
|
||
}
|
||
break;
|
||
case 'TYPO3_REV_PROXY':
|
||
$retVal = t3lib_div::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP']);
|
||
$retVal = self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP']);
|
||
break;
|
||
case 'REMOTE_ADDR':
|
||
$retVal = $_SERVER['REMOTE_ADDR'];
|
||
if (t3lib_div::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
|
||
$ip = t3lib_div::trimExplode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
|
||
if (self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
|
||
$ip = self::trimExplode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
|
||
// choose which IP in list to use
|
||
if (count($ip)) {
|
||
switch ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyHeaderMultiValue']) {
|
||
... | ... | |
break;
|
||
}
|
||
}
|
||
if (t3lib_div::validIP($ip)) {
|
||
if (self::validIP($ip)) {
|
||
$retVal = $ip;
|
||
}
|
||
}
|
||
break;
|
||
case 'HTTP_HOST':
|
||
$retVal = $_SERVER['HTTP_HOST'];
|
||
if (t3lib_div::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
|
||
$host = t3lib_div::trimExplode(',', $_SERVER['HTTP_X_FORWARDED_HOST']);
|
||
if (self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
|
||
$host = self::trimExplode(',', $_SERVER['HTTP_X_FORWARDED_HOST']);
|
||
// choose which host in list to use
|
||
if (count($host)) {
|
||
switch ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyHeaderMultiValue']) {
|
||
... | ... | |
case 'TYPO3_DOCUMENT_ROOT':
|
||
// Some CGI-versions (LA13CGI) and mod-rewrite rules on MODULE versions will deliver a 'wrong' DOCUMENT_ROOT (according to our description). Further various aliases/mod_rewrite rules can disturb this as well.
|
||
// Therefore the DOCUMENT_ROOT is now always calculated as the SCRIPT_FILENAME minus the end part shared with SCRIPT_NAME.
|
||
$SFN = t3lib_div::getIndpEnv('SCRIPT_FILENAME');
|
||
$SN_A = explode('/',strrev(t3lib_div::getIndpEnv('SCRIPT_NAME')));
|
||
$SFN = self::getIndpEnv('SCRIPT_FILENAME');
|
||
$SN_A = explode('/',strrev(self::getIndpEnv('SCRIPT_NAME')));
|
||
$SFN_A = explode('/',strrev($SFN));
|
||
$acc = array();
|
||
foreach ($SN_A as $kk => $vv) {
|
||
... | ... | |
$retVal = $DR;
|
||
break;
|
||
case 'TYPO3_HOST_ONLY':
|
||
$p = explode(':',t3lib_div::getIndpEnv('HTTP_HOST'));
|
||
$p = explode(':',self::getIndpEnv('HTTP_HOST'));
|
||
$retVal = $p[0];
|
||
break;
|
||
case 'TYPO3_PORT':
|
||
$p = explode(':',t3lib_div::getIndpEnv('HTTP_HOST'));
|
||
$p = explode(':',self::getIndpEnv('HTTP_HOST'));
|
||
$retVal = $p[1];
|
||
break;
|
||
case 'TYPO3_REQUEST_HOST':
|
||
$retVal = (t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://').
|
||
t3lib_div::getIndpEnv('HTTP_HOST');
|
||
$retVal = (self::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://').
|
||
self::getIndpEnv('HTTP_HOST');
|
||
break;
|
||
case 'TYPO3_REQUEST_URL':
|
||
$retVal = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::getIndpEnv('REQUEST_URI');
|
||
$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST').self::getIndpEnv('REQUEST_URI');
|
||
break;
|
||
case 'TYPO3_REQUEST_SCRIPT':
|
||
$retVal = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::getIndpEnv('SCRIPT_NAME');
|
||
$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST').self::getIndpEnv('SCRIPT_NAME');
|
||
break;
|
||
case 'TYPO3_REQUEST_DIR':
|
||
$retVal = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
|
||
$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST').self::dirname(self::getIndpEnv('SCRIPT_NAME')).'/';
|
||
break;
|
||
case 'TYPO3_SITE_URL':
|
||
if (defined('PATH_thisScript') && defined('PATH_site')) {
|
||
$lPath = substr(dirname(PATH_thisScript),strlen(PATH_site)).'/';
|
||
$url = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR');
|
||
$url = self::getIndpEnv('TYPO3_REQUEST_DIR');
|
||
$siteUrl = substr($url,0,-strlen($lPath));
|
||
if (substr($siteUrl,-1)!='/') $siteUrl.='/';
|
||
$retVal = $siteUrl;
|
||
}
|
||
break;
|
||
case 'TYPO3_SITE_PATH':
|
||
$retVal = substr(t3lib_div::getIndpEnv('TYPO3_SITE_URL'), strlen(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST')));
|
||
$retVal = substr(self::getIndpEnv('TYPO3_SITE_URL'), strlen(self::getIndpEnv('TYPO3_REQUEST_HOST')));
|
||
break;
|
||
case 'TYPO3_SITE_SCRIPT':
|
||
$retVal = substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL')));
|
||
$retVal = substr(self::getIndpEnv('TYPO3_REQUEST_URL'),strlen(self::getIndpEnv('TYPO3_SITE_URL')));
|
||
break;
|
||
case 'TYPO3_SSL':
|
||
$proxySSL = trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxySSL']);
|
||
if ($proxySSL == '*') {
|
||
$proxySSL = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'];
|
||
}
|
||
if (t3lib_div::cmpIP($_SERVER['REMOTE_ADDR'], $proxySSL)) {
|
||
if (self::cmpIP($_SERVER['REMOTE_ADDR'], $proxySSL)) {
|
||
$retVal = true;
|
||
} else {
|
||
$retVal = $_SERVER['SSL_SESSION_ID'] || !strcasecmp($_SERVER['HTTPS'], 'on') || !strcmp($_SERVER['HTTPS'], '1') ? true : false; // see http://bugs.typo3.org/view.php?id=3909
|
||
... | ... | |
case '_ARRAY':
|
||
$out = array();
|
||
// Here, list ALL possible keys to this function for debug display.
|
||
$envTestVars = t3lib_div::trimExplode(',','
|
||
$envTestVars = self::trimExplode(',','
|
||
HTTP_HOST,
|
||
TYPO3_HOST_ONLY,
|
||
TYPO3_PORT,
|
||
... | ... | |
HTTP_USER_AGENT,
|
||
HTTP_ACCEPT_LANGUAGE',1);
|
||
foreach ($envTestVars as $v) {
|
||
$out[$v]=t3lib_div::getIndpEnv($v);
|
||
$out[$v]=self::getIndpEnv($v);
|
||
}
|
||
reset($out);
|
||
$retVal = $out;
|
||
... | ... | |
* @return array Parsed information about the HTTP_USER_AGENT in categories BROWSER, VERSION, SYSTEM and FORMSTYLE
|
||
*/
|
||
public static function clientInfo($useragent='') {
|
||
if (!$useragent) $useragent=t3lib_div::getIndpEnv('HTTP_USER_AGENT');
|
||
if (!$useragent) $useragent=self::getIndpEnv('HTTP_USER_AGENT');
|
||
$bInfo=array();
|
||
// Which browser?
|
||
... | ... | |
public static function getHostname($requestHost=TRUE) {
|
||
$host = '';
|
||
if ($requestHost && (!defined('TYPO3_cliMode') || !TYPO3_cliMode)) {
|
||
$host = t3lib_div::getIndpEnv('HTTP_HOST');
|
||
$host = self::getIndpEnv('HTTP_HOST');
|
||
}
|
||
if (!$host) {
|
||
// will fail for PHP 4.1 and 4.2
|
||
... | ... | |
if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
|
||
$filename = t3lib_extMgm::extPath($extKey).$local;
|
||
}
|
||
} elseif (!t3lib_div::isAbsPath($filename)) { // relative. Prepended with $relPathPrefix
|
||
} elseif (!self::isAbsPath($filename)) { // relative. Prepended with $relPathPrefix
|
||
$filename=$relPathPrefix.$filename;
|
||
} elseif ($onlyRelative && !t3lib_div::isFirstPartOfStr($filename,$relPathPrefix)) { // absolute, but set to blank if not allowed
|
||
} elseif ($onlyRelative && !self::isFirstPartOfStr($filename,$relPathPrefix)) { // absolute, but set to blank if not allowed
|
||
$filename='';
|
||
}
|
||
if (strcmp($filename,'') && t3lib_div::validPathStr($filename)) { // checks backpath.
|
||
if (strcmp($filename,'') && self::validPathStr($filename)) { // checks backpath.
|
||
return $filename;
|
||
}
|
||
}
|
||
... | ... | |
* @return boolean
|
||
*/
|
||
public static function isAllowedAbsPath($path) {
|
||
if (t3lib_div::isAbsPath($path) &&
|
||
t3lib_div::validPathStr($path) &&
|
||
( t3lib_div::isFirstPartOfStr($path,PATH_site)
|
||
if (self::isAbsPath($path) &&
|
||
self::validPathStr($path) &&
|
||
( self::isFirstPartOfStr($path,PATH_site)
|
||
||
|
||
($GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'] && t3lib_div::isFirstPartOfStr($path,$GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath']))
|
||
($GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'] && self::isFirstPartOfStr($path,$GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath']))
|
||
)
|
||
) return true;
|
||
}
|
||
... | ... | |
if (!empty($url) && self::removeXSS($decodedUrl) === $decodedUrl) {
|
||
$testAbsoluteUrl = self::resolveBackPath($decodedUrl);
|
||
$testRelativeUrl = self::resolveBackPath(
|
||
t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/' . $decodedUrl
|
||
self::dirname(self::getIndpEnv('SCRIPT_NAME')) . '/' . $decodedUrl
|
||
);
|
||
// Pass if URL is on the current host:
|
||
... | ... | |
@copy($source,$destination);
|
||
}
|
||
t3lib_div::fixPermissions($destination); // Change the permissions of the file
|
||
self::fixPermissions($destination); // Change the permissions of the file
|
||
// If here the file is copied and the temporary $source is still around, so when returning false the user can try unlink to delete the $source
|
||
return $uploaded ? $uploadedResult : FALSE;
|
||
... | ... | |
*/
|
||
public static function upload_to_tempfile($uploadedFileName) {
|
||
if (is_uploaded_file($uploadedFileName)) {
|
||
$tempFile = t3lib_div::tempnam('upload_temp_');
|
||
$tempFile = self::tempnam('upload_temp_');
|
||
move_uploaded_file($uploadedFileName, $tempFile);
|
||
return @is_file($tempFile) ? $tempFile : '';
|
||
}
|
||
... | ... | |
* @see upload_to_tempfile(), tempnam()
|
||
*/
|
||
public static function unlink_tempfile($uploadedTempFileName) {
|
||
if ($uploadedTempFileName && t3lib_div::validPathStr($uploadedTempFileName) && t3lib_div::isFirstPartOfStr($uploadedTempFileName,PATH_site.'typo3temp/') && @is_file($uploadedTempFileName)) {
|
||
if ($uploadedTempFileName && self::validPathStr($uploadedTempFileName) && self::isFirstPartOfStr($uploadedTempFileName,PATH_site.'typo3temp/') && @is_file($uploadedTempFileName)) {
|
||
if (unlink($uploadedTempFileName)) return TRUE;
|
||
}
|
||
}
|
||
... | ... | |
if (is_array($uid_or_record)) {
|
||
$recCopy_temp=array();
|
||
if ($fields) {
|
||
$fieldArr = t3lib_div::trimExplode(',',$fields,1);
|
||
$fieldArr = self::trimExplode(',',$fields,1);
|
||
foreach ($fieldArr as $k => $v) {
|
||
$recCopy_temp[$k]=$uid_or_record[$v];
|
||
}
|
||
... | ... | |
$pA = array();
|
||
foreach($params as $theP) {
|
||
$pKV = explode('=', $theP); // Splitting single param by '=' sign
|
||
if (!t3lib_div::inList('id,type,no_cache,cHash,MP,ftu',$pKV[0]) && !preg_match('/TSFE_ADMIN_PANEL\[.*?\]/',$pKV[0])) {
|
||
if (!self::inList('id,type,no_cache,cHash,MP,ftu',$pKV[0]) && !preg_match('/TSFE_ADMIN_PANEL\[.*?\]/',$pKV[0])) {
|
||
$pA[rawurldecode($pKV[0])] = (string)rawurldecode($pKV[1]);
|
||
}
|
||
}
|
||
... | ... | |
);
|
||
$hookReference = null;
|
||
foreach ($cHashParamsHook as $hookFunction) {
|
||
t3lib_div::callUserFunction($hookFunction, $hookParameters, $hookReference);
|
||
self::callUserFunction($hookFunction, $hookParameters, $hookReference);
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
* @see t3lib_div::cHashParams(), t3lib_div::calculateCHash()
|
||
*/
|
||
public static function generateCHash($addQueryParams) {
|
||
$cHashParams = t3lib_div::cHashParams($addQueryParams);
|
||
$cHash = t3lib_div::calculateCHash($cHashParams);
|
||
$cHashParams = self::cHashParams($addQueryParams);
|
||
$cHash = self::calculateCHash($cHashParams);
|
||
return $cHash;
|
||
}
|
||
... | ... | |
public static function readLLfile($fileRef, $langKey, $charset = '', $errorMode = 0) {
|
||
$result = FALSE;
|
||
$file = t3lib_div::getFileAbsFileName($fileRef);
|
||
$file = self::getFileAbsFileName($fileRef);
|
||
if ($file) {
|
||
$baseFile = preg_replace('/\.(php|xml)$/', '', $file);
|
||
if (@is_file($baseFile.'.xml')) {
|
||
$LOCAL_LANG = t3lib_div::readLLXMLfile($baseFile.'.xml', $langKey, $charset);
|
||
$LOCAL_LANG = self::readLLXMLfile($baseFile.'.xml', $langKey, $charset);
|
||
} elseif (@is_file($baseFile.'.php')) {
|
||
if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] || $charset) {
|
||
$LOCAL_LANG = t3lib_div::readLLPHPfile($baseFile.'.php', $langKey, $charset);
|
||
$LOCAL_LANG = self::readLLPHPfile($baseFile.'.php', $langKey, $charset);
|
||
} else {
|
||
include($baseFile.'.php');
|
||
if (is_array($LOCAL_LANG)) {
|
||
... | ... | |
}
|
||
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'][$fileRef])) {
|
||
foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'][$fileRef] as $overrideFile) {
|
||
$languageOverrideFileName = t3lib_div::getFileAbsFileName($overrideFile);
|
||
$languageOverrideFileName = self::getFileAbsFileName($overrideFile);
|
||
if (@is_file($languageOverrideFileName)) {
|
||
$languageOverrideArray = t3lib_div::readLLXMLfile($languageOverrideFileName, $langKey, $charset);
|
||
$LOCAL_LANG = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG, $languageOverrideArray);
|
||
$languageOverrideArray = self::readLLXMLfile($languageOverrideFileName, $langKey, $charset);
|
||
$LOCAL_LANG = self::array_merge_recursive_overrule($LOCAL_LANG, $languageOverrideArray);
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
} elseif (is_object($GLOBALS['TSFE'])) {
|
||
$csConvObj = $GLOBALS['TSFE']->csConvObj;
|
||
} else {
|
||
$csConvObj = t3lib_div::makeInstance('t3lib_cs');
|
||
$csConvObj = self::makeInstance('t3lib_cs');
|
||
}
|
||
if (@is_file($fileRef) && $langKey) {
|
||
... | ... | |
$hashSource = substr($fileRef,strlen(PATH_site)).'|'.date('d-m-Y H:i:s',filemtime($fileRef)).'|version=2.3';
|
||
$cacheFileName = PATH_site.'typo3temp/llxml/'.
|
||
substr(basename($fileRef),10,15).
|
||
'_'.t3lib_div::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
|
||
'_'.self::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
|
||
// Check if cache file exists...
|
||
if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it:
|
||
... | ... | |
// Cache the content now:
|
||
$serContent = array('origFile'=>$hashSource, 'LOCAL_LANG'=>array('default'=>$LOCAL_LANG['default'], $langKey=>$LOCAL_LANG[$langKey]));
|
||
$res = t3lib_div::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
|
||
$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
|
||
if ($res) die('ERROR: '.$res);
|
||
} else {
|
||
// Get content from cache:
|
||
$serContent = unserialize(t3lib_div::getUrl($cacheFileName));
|
||
$serContent = unserialize(self::getUrl($cacheFileName));
|
||
$LOCAL_LANG = $serContent['LOCAL_LANG'];
|
||
}
|
||
... | ... | |
} elseif (is_object($GLOBALS['TSFE'])) {
|
||
$csConvObj = $GLOBALS['TSFE']->csConvObj;
|
||
} else {
|
||
$csConvObj = t3lib_div::makeInstance('t3lib_cs');
|
||
$csConvObj = self::makeInstance('t3lib_cs');
|
||
}
|
||
$LOCAL_LANG = NULL;
|
||
... | ... | |
$hashSource = substr($fileRef,strlen(PATH_site)).'|'.date('d-m-Y H:i:s',filemtime($fileRef)).'|version=2.3';
|
||
$cacheFileName = PATH_site.'typo3temp/llxml/'.
|
||
substr(basename($fileRef),10,15).
|
||
'_'.t3lib_div::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
|
||
'_'.self::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
|
||
// Check if cache file exists...
|
||
if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it:
|
||
// Read XML, parse it.
|
||
$xmlString = t3lib_div::getUrl($fileRef);
|
||
$xmlContent = t3lib_div::xml2array($xmlString);
|
||
$xmlString = self::getUrl($fileRef);
|
||
$xmlContent = self::xml2array($xmlString);
|
||
if (!is_array($xmlContent)) {
|
||
$fileName = substr($fileRef, strlen(PATH_site));
|
||
die('The file "' . $fileName . '" is no TYPO3 language file!');
|
||
... | ... | |
if ($langKey!='default') {
|
||
// If no entry is found for the language key, then force a value depending on meta-data setting. By default an automated filename will be used:
|
||
$LOCAL_LANG[$langKey] = t3lib_div::llXmlAutoFileName($fileRef, $langKey);
|
||
$localized_file = t3lib_div::getFileAbsFileName($LOCAL_LANG[$langKey]);
|
||
$LOCAL_LANG[$langKey] = self::llXmlAutoFileName($fileRef, $langKey);
|
||
$localized_file = self::getFileAbsFileName($LOCAL_LANG[$langKey]);
|
||
if (!@is_file($localized_file) && isset($xmlContent['data'][$langKey])) {
|
||
$LOCAL_LANG[$langKey] = $xmlContent['data'][$langKey];
|
||
}
|
||
... | ... | |
// Cache the content now:
|
||
$serContent = array('origFile'=>$hashSource, 'LOCAL_LANG'=>array('default'=>$LOCAL_LANG['default'], $langKey=>$LOCAL_LANG[$langKey]));
|
||
$res = t3lib_div::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
|
||
$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
|
||
if ($res) die('ERROR: '.$res);
|
||
} else {
|
||
// Get content from cache:
|
||
$serContent = unserialize(t3lib_div::getUrl($cacheFileName));
|
||
$serContent = unserialize(self::getUrl($cacheFileName));
|
||
$LOCAL_LANG = $serContent['LOCAL_LANG'];
|
||
}
|
||
... | ... | |
if ($langKey!='default' && is_string($LOCAL_LANG[$langKey]) && strlen($LOCAL_LANG[$langKey])) {
|
||
// Look for localized file:
|
||
$localized_file = t3lib_div::getFileAbsFileName($LOCAL_LANG[$langKey]);
|
||
$localized_file = self::getFileAbsFileName($LOCAL_LANG[$langKey]);
|
||
if ($localized_file && @is_file($localized_file)) {
|
||
// Cache file name:
|
||
$hashSource = substr($localized_file,strlen(PATH_site)).'|'.date('d-m-Y H:i:s',filemtime($localized_file)).'|version=2.3';
|
||
$cacheFileName = PATH_site.'typo3temp/llxml/EXT_'.
|
||
substr(basename($localized_file),10,15).
|
||
'_'.t3lib_div::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
|
||
'_'.self::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
|
||
// Check if cache file exists...
|
||
if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it:
|
||
// Read and parse XML content:
|
||
$local_xmlString = t3lib_div::getUrl($localized_file);
|
||
$local_xmlContent = t3lib_div::xml2array($local_xmlString);
|
||
$local_xmlString = self::getUrl($localized_file);
|
||
$local_xmlContent = self::xml2array($local_xmlString);
|
||
if (!is_array($local_xmlContent)) {
|
||
$fileName = substr($localized_file, strlen(PATH_site));
|
||
die('The file "' . $fileName . '" is no TYPO3 language file!');
|
||
... | ... | |
// Cache the content now:
|
||
$serContent = array('extlang'=>$langKey, 'origFile'=>$hashSource, 'EXT_DATA'=>$LOCAL_LANG[$langKey]);
|
||
$res = t3lib_div::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
|
||
$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
|
||
if ($res) {
|
||
die('ERROR: '.$res);
|
||
}
|
||
} else {
|
||
// Get content from cache:
|
||
$serContent = unserialize(t3lib_div::getUrl($cacheFileName));
|
||
$serContent = unserialize(self::getUrl($cacheFileName));
|
||
$LOCAL_LANG[$langKey] = $serContent['EXT_DATA'];
|
||
}
|
||
} else {
|
||
... | ... | |
public static function llXmlAutoFileName($fileRef,$language) {
|
||
// Analyse file reference:
|
||
$location = 'typo3conf/l10n/'.$language.'/'; // Default location of translations
|
||
if (t3lib_div::isFirstPartOfStr($fileRef,PATH_typo3.'sysext/')) { // Is system:
|
||
if (self::isFirstPartOfStr($fileRef,PATH_typo3.'sysext/')) { // Is system:
|
||
$validatedPrefix = PATH_typo3.'sysext/';
|
||
#$location = 'EXT:csh_'.$language.'/'; // For system extensions translations are found in "csh_*" extensions (language packs)
|
||
} elseif (t3lib_div::isFirstPartOfStr($fileRef,PATH_typo3.'ext/')) { // Is global:
|
||
} elseif (self::isFirstPartOfStr($fileRef,PATH_typo3.'ext/')) { // Is global:
|
||
$validatedPrefix = PATH_typo3.'ext/';
|
||
} elseif (t3lib_div::isFirstPartOfStr($fileRef,PATH_typo3conf.'ext/')) { // Is local:
|
||
} elseif (self::isFirstPartOfStr($fileRef,PATH_typo3conf.'ext/')) { // Is local:
|
||
$validatedPrefix = PATH_typo3conf.'ext/';
|
||
} else {
|
||
$validatedPrefix = '';
|
||
... | ... | |
// Divide file reference into extension key, directory (if any) and base name:
|
||
list($file_extKey,$file_extPath) = explode('/',substr($fileRef,strlen($validatedPrefix)),2);
|
||
$temp = t3lib_div::revExplode('/',$file_extPath,2);
|
||
$temp = self::revExplode('/',$file_extPath,2);
|
||
if (count($temp)==1) array_unshift($temp,''); // Add empty first-entry if not there.
|
||
list($file_extPath,$file_fileName) = $temp;
|
||
... | ... | |
if ($dcf) {
|
||
if (!strcmp(substr($dcf,0,6),'T3LIB:')) {
|
||
include(PATH_t3lib.'stddb/'.substr($dcf,6));
|
||
} elseif (t3lib_div::isAbsPath($dcf) && @is_file($dcf)) { // Absolute path...
|
||
} elseif (self::isAbsPath($dcf) && @is_file($dcf)) { // Absolute path...
|
||
include($dcf);
|
||
} else include(PATH_typo3conf.$dcf);
|
||
}
|
||
... | ... | |
// If not an array, but still set, then regard it as a relative reference to a file:
|
||
if ($dataStruct && !is_array($dataStruct)) {
|
||
$file = t3lib_div::getFileAbsFileName($dataStruct);
|
||
$file = self::getFileAbsFileName($dataStruct);
|
||
if ($file && @is_file($file)) {
|
||
$dataStruct = t3lib_div::xml2array(t3lib_div::getUrl($file));
|
||
$dataStruct = self::xml2array(self::getUrl($file));
|
||
}
|
||
}
|
||
} else {
|
||
... | ... | |
if (is_array($dataStructArray['sheets'])) {
|
||
$out=array('sheets'=>array());
|
||
foreach($dataStructArray['sheets'] as $sheetId => $sDat) {
|
||
list($ds,$aS) = t3lib_div::resolveSheetDefInDS($dataStructArray,$sheetId);
|
||
list($ds,$aS) = self::resolveSheetDefInDS($dataStructArray,$sheetId);
|
||
if ($sheetId==$aS) {
|
||
$out['sheets'][$aS]=$ds;
|
||
}
|
||
}
|
||
} else {
|
||
list($ds) = t3lib_div::resolveSheetDefInDS($dataStructArray);
|
||
list($ds) = self::resolveSheetDefInDS($dataStructArray);
|
||
$out = array('sheets' => array('sDEF' => $ds));
|
||
}
|
||
return $out;
|
||
... | ... | |
// Check file-reference prefix; if found, require_once() the file (should be library of code)
|
||
if (strpos($funcName,':') !== false) {
|
||
list($file,$funcRef) = t3lib_div::revExplode(':',$funcName,2);
|
||
$requireFile = t3lib_div::getFileAbsFileName($file);
|
||
if ($requireFile) t3lib_div::requireOnce($requireFile);
|
||
list($file,$funcRef) = self::revExplode(':',$funcName,2);
|
||
$requireFile = self::getFileAbsFileName($file);
|
||
if ($requireFile) self::requireOnce($requireFile);
|
||
} else {
|
||
$funcRef = $funcName;
|
||
}
|
||
... | ... | |
// Check prefix is valid:
|
||
if ($checkPrefix &&
|
||
!t3lib_div::isFirstPartOfStr(trim($funcRef),$checkPrefix) &&
|
||
!t3lib_div::isFirstPartOfStr(trim($funcRef),'tx_')
|
||
!self::isFirstPartOfStr(trim($funcRef),$checkPrefix) &&
|
||
!self::isFirstPartOfStr(trim($funcRef),'tx_')
|
||
) {
|
||
$errorMsg = "Function/class '$funcRef' was not prepended with '$checkPrefix'";
|
||
if ($errorMode == 2) {
|
||
... | ... | |
// Get/Create object of class:
|
||
if ($storePersistentObject) { // Get reference to current instance of class:
|
||
if (!is_object($GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]])) {
|
||
$GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]] = t3lib_div::makeInstance($parts[0]);
|
||
$GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]] = self::makeInstance($parts[0]);
|
||
}
|
||
$classObj = $GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]];
|
||
} else { // Create new object:
|
||
$classObj = t3lib_div::makeInstance($parts[0]);
|
||
$classObj = self::makeInstance($parts[0]);
|
||
}
|
||
if (method_exists($classObj, $parts[1])) {
|
||
... | ... | |
// Check file-reference prefix; if found, require_once() the file (should be library of code)
|
||
if (strpos($classRef,':') !== false) {
|
||
list($file,$class) = t3lib_div::revExplode(':',$classRef,2);
|
||
$requireFile = t3lib_div::getFileAbsFileName($file);
|
||
if ($requireFile) t3lib_div::requireOnce($requireFile);
|
||
list($file,$class) = self::revExplode(':',$classRef,2);
|
||
$requireFile = self::getFileAbsFileName($file);
|
||
if ($requireFile) self::requireOnce($requireFile);
|
||
} else {
|
||
$class = $classRef;
|
||
}
|
||
... | ... | |
// Check prefix is valid:
|
||
if ($checkPrefix &&
|
||
!t3lib_div::isFirstPartOfStr(trim($class),$checkPrefix) &&
|
||
!t3lib_div::isFirstPartOfStr(trim($class),'tx_')
|
||
!self::isFirstPartOfStr(trim($class),$checkPrefix) &&
|
||
!self::isFirstPartOfStr(trim($class),'tx_')
|
||
) {
|
||
if (!$silent) debug("Class '".$class."' was not prepended with '".$checkPrefix."'",1);
|
||
return FALSE;
|
||
... | ... | |
// Check if class exists:
|
||
if (class_exists($class)) {
|
||
$classObj = t3lib_div::makeInstance($class);
|
||
$classObj = self::makeInstance($class);
|
||
// If persistent object should be created, set reference:
|
||
if ($storePersistentObject) {
|
||
... | ... | |
public static function makeInstanceClassName($className) {
|
||
self::logDeprecatedFunction();
|
||
return (class_exists($className) && class_exists('ux_'.$className, false) ? t3lib_div::makeInstanceClassName('ux_' . $className) : $className);
|
||
return (class_exists($className) && class_exists('ux_'.$className, false) ? self::makeInstanceClassName('ux_' . $className) : $className);
|
||
}
|
||
/**
|
||
... | ... | |
$error = FALSE;
|
||
if (!is_array($excludeServiceKeys) ) {
|
||
$excludeServiceKeys = t3lib_div::trimExplode(',', $excludeServiceKeys, 1);
|
||
$excludeServiceKeys = self::trimExplode(',', $excludeServiceKeys, 1);
|
||
}
|
||
while ($info = t3lib_extMgm::findService($serviceType, $serviceSubType, $excludeServiceKeys)) {
|
||
... | ... | |
// include file and create object
|
||
} else {
|
||
$requireFile = t3lib_div::getFileAbsFileName($info['classFile']);
|
||
$requireFile = self::getFileAbsFileName($info['classFile']);
|
||
if (@is_file($requireFile)) {
|
||
t3lib_div::requireOnce ($requireFile);
|
||
$obj = t3lib_div::makeInstance($info['className']);
|
||
self::requireOnce ($requireFile);
|
||
$obj = self::makeInstance($info['className']);
|
||
if (is_object($obj)) {
|
||
if(!@is_callable(array($obj,'init'))) {
|
||
// use silent logging??? I don't think so.
|
||
die ('Broken service:'.t3lib_div::view_array($info));
|
||
die ('Broken service:'.self::view_array($info));
|
||
}
|
||
$obj->info = $info;
|
||
if ($obj->init()) { // service available?
|
||
... | ... | |
if (0 == strcasecmp($parts[0], 'from')) {
|
||
$parts[1] = self::normalizeMailAddress($parts[1]);
|
||
}
|
||
$parts[1] = t3lib_div::encodeHeader($parts[1],$encoding,$charset);
|
||
$parts[1] = self::encodeHeader($parts[1],$encoding,$charset);
|
||
$newHeaders[] = implode(': ',$parts);
|
||
} else {
|
||
$newHeaders[] = $line; // Should never happen - is such a mail header valid? Anyway, just add the unchanged line...
|
||
... | ... | |
$headers = implode(chr(10),$newHeaders);
|
||
unset($newHeaders);
|
||
$email = t3lib_div::encodeHeader($email,$encoding,$charset); // Email address must not be encoded, but it could be appended by a name which should be so (e.g. "Kasper Sk?rh?j <kasperYYYY@typo3.com>")
|
||
$subject = t3lib_div::encodeHeader($subject,$encoding,$charset);
|
||
$email = self::encodeHeader($email,$encoding,$charset); // Email address must not be encoded, but it could be appended by a name which should be so (e.g. "Kasper Sk?rh?j <kasperYYYY@typo3.com>")
|
||
$subject = self::encodeHeader($subject,$encoding,$charset);
|
||
}
|
||
switch ((string)$encoding) {
|
||
... | ... | |
'Content-Type: text/plain; charset='.$charset.chr(10).
|
||
'Content-Transfer-Encoding: quoted-printable';
|
||
$message=t3lib_div::quoted_printable($message);
|
||
$message=self::quoted_printable($message);
|
||
break;
|
||
}
|
||
// Headers must be separated by CRLF according to RFC 2822, not just LF.
|
||
// But many servers (Gmail, for example) behave incorectly and want only LF.
|
||
// So we stick to LF in all cases.
|
||
$headers = trim(implode(chr(10), t3lib_div::trimExplode(chr(10), $headers, true))); // Make sure no empty lines are there.
|
||
$headers = trim(implode(chr(10), self::trimExplode(chr(10), $headers, true))); // Make sure no empty lines are there.
|
||
$ret = @mail($email, $subject, $message, $headers);
|
||
if (!$ret) {
|
||
t3lib_div::sysLog('Mail to "'.$email.'" could not be sent (Subject: "'.$subject.'").', 'Core', 3);
|
||
self::sysLog('Mail to "'.$email.'" could not be sent (Subject: "'.$subject.'").', 'Core', 3);
|
||
}
|
||
return $ret;
|
||
}
|
||
... | ... | |
break;
|
||
case 'quoted-printable':
|
||
default:
|
||
$qpValue = t3lib_div::quoted_printable($part,1000);
|
||
$qpValue = self::quoted_printable($part,1000);
|
||
if ($part!=$qpValue) {
|
||
// Encoded words in the header should not contain non-encoded:
|
||
// * spaces. "_" is a shortcut for "=20". See RFC 2047 for details.
|
||
... | ... | |
switch ((string)$urlmode) {
|
||
case 'all':
|
||
$newURL = t3lib_div::makeRedirectUrl($newURL,0,$index_script_url);
|
||
$newURL = self::makeRedirectUrl($newURL,0,$index_script_url);
|
||
break;
|
||
case '76':
|
||
$newURL = t3lib_div::makeRedirectUrl($newURL,76,$index_script_url);
|
||
$newURL = self::makeRedirectUrl($newURL,76,$index_script_url);
|
||
break;
|
||
}
|
||
$v = $newURL . substr($v,strlen($newParts[0]));
|
||
... | ... | |
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_md5params', $insertFields);
|
||
}
|
||
$inUrl=($index_script_url ? $index_script_url : t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php').
|
||
$inUrl=($index_script_url ? $index_script_url : self::getIndpEnv('TYPO3_REQUEST_DIR').'index.php').
|
||
'?RDCT='.$md5;
|
||
}
|
||
... | ... | |
// for CLI logging name is <fqdn-hostname>:<TYPO3-path>
|
||
if (defined('TYPO3_cliMode') && TYPO3_cliMode) {
|
||
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = t3lib_div::getHostname($requestHost=FALSE).':'.PATH_site;
|
||
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = self::getHostname($requestHost=FALSE).':'.PATH_site;
|
||
}
|
||
// for Web logging name is <protocol>://<request-hostame>/<site-path>
|
||
else {
|
||
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
|
||
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = self::getIndpEnv('TYPO3_SITE_URL');
|
||
}
|
||
// init custom logging
|
||
... | ... | |
$params = array('initLog'=>TRUE);
|
||
$fakeThis = FALSE;
|
||
foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
|
||
t3lib_div::callUserFunction($hookMethod,$params,$fakeThis);
|
||
self::callUserFunction($hookMethod,$params,$fakeThis);
|
||
}
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
$TYPO3_CONF_VARS['SYS']['systemLogLevel'] = t3lib_div::intInRange($TYPO3_CONF_VARS['SYS']['systemLogLevel'],0,4);
|
||
$TYPO3_CONF_VARS['SYS']['systemLogLevel'] = self::intInRange($TYPO3_CONF_VARS['SYS']['systemLogLevel'],0,4);
|
||
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'] = TRUE;
|
||
}
|
||
... | ... | |
public static function sysLog($msg, $extKey, $severity=0) {
|
||
global $TYPO3_CONF_VARS;
|
||
$severity = t3lib_div::intInRange($severity,0,4);
|
||
$severity = self::intInRange($severity,0,4);
|
||
// is message worth logging?
|
||
if (intval($TYPO3_CONF_VARS['SYS']['systemLogLevel']) > $severity) return;
|
||
// initialize logging
|
||
if (!$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit']) {
|
||
t3lib_div::initSysLog();
|
||
self::initSysLog();
|
||
}
|
||
// do custom logging
|
||
... | ... | |
$params = array('msg'=>$msg, 'extKey'=>$extKey, 'backTrace'=>debug_backtrace(), 'severity'=>$severity);
|
||
$fakeThis = FALSE;
|
||
foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
|
||
t3lib_div::callUserFunction($hookMethod,$params,$fakeThis);
|
||
self::callUserFunction($hookMethod,$params,$fakeThis);
|
||
}
|
||
}
|
||
... | ... | |
$params = array('msg'=>$msg, 'extKey'=>$extKey, 'severity'=>$severity, 'dataVar'=>$dataVar);
|
||
$fakeThis = FALSE;
|
||
foreach($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'] as $hookMethod) {
|
||
t3lib_div::callUserFunction($hookMethod,$params,$fakeThis);
|
||
self::callUserFunction($hookMethod,$params,$fakeThis);
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
}
|
||
// write a longer message to the deprecation log
|
||
$destination = PATH_typo3conf . '/deprecation_' . t3lib_div::shortMD5(PATH_site . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) . '.log';
|
||
$destination = PATH_typo3conf . '/deprecation_' . self::shortMD5(PATH_site . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) . '.log';
|
||
$file = @fopen($destination, 'a');
|
||
if ($file) {
|
||
$date = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ': ');
|
||
... | ... | |
public static function arrayToLogString(array $arr, $valueList=array(), $valueLength=20) {
|
||
$str = '';
|
||
if (!is_array($valueList)) {
|
||
$valueList = t3lib_div::trimExplode(',', $valueList, 1);
|
||
$valueList = self::trimExplode(',', $valueList, 1);
|
||
}
|
||
$valListCnt = count($valueList);
|
||
foreach ($arr as $key => $value) {
|
||
if (!$valListCnt || in_array($key, $valueList)) {
|
||
$str .= (string)$key.trim(': '.t3lib_div::fixed_lgd_cs(str_replace("\n",'|',(string)$value), $valueLength)).'; ';
|
||
$str .= (string)$key.trim(': '.self::fixed_lgd_cs(str_replace("\n",'|',(string)$value), $valueLength)).'; ';
|
||
}
|
||
}
|
||
return $str;
|
||
... | ... | |
$cmdLine = $path.' '.$parameters;
|
||
if($command=='composite' && $switchCompositeParameters) { // Because of some weird incompatibilities between ImageMagick 4 and 6 (plus GraphicsMagick), it is needed to change the parameters order under some preconditions
|
||
$paramsArr = t3lib_div::unQuoteFilenames($parameters);
|
||
$paramsArr = self::unQuoteFilenames($parameters);
|
||
if(count($paramsArr)>5) { // The mask image has been specified => swap the parameters
|
||
$tmp = $paramsArr[count($paramsArr)-3];
|
||
... | ... | |
$headersList = headers_list();
|
||
foreach ($headersList as $header) {
|
||
// split it up at the :
|
||
list($key, $value) = t3lib_div::trimExplode(':', $header, TRUE);
|
||
list($key, $value) = self::trimExplode(':', $header, TRUE);
|
||
// check if we have a Content-Encoding other than 'None'
|
||
if (strtolower($key) === 'content-encoding' && strtolower($value) !== 'none') {
|
||
header('Content-Encoding: None');
|