Project

General

Profile

Bug #22227 ยป dotspacing.diff

Administrator Admin, 2010-03-03 14:21

View differences:

t3lib/class.t3lib_div.php (working copy)
* @return string Input string with potential XSS code removed
*/
public static function removeXSS($string) {
require_once(PATH_typo3.'contrib/RemoveXSS/RemoveXSS.php');
require_once(PATH_typo3 . 'contrib/RemoveXSS/RemoveXSS.php');
$string = RemoveXSS::process($string);
return $string;
}
......
$returnCode='';
if ($gfxConf['gif_compress'] && strtolower(substr($theFile,-4,4))=='.gif') { // GIF...
if (($type=='IM' || !$type) && $gfxConf['im'] && $gfxConf['im_path_lzw']) { // IM
$cmd = self::imageMagickCommand('convert', '"'.$theFile.'" "'.$theFile.'"', $gfxConf['im_path_lzw']);
$cmd = self::imageMagickCommand('convert', '"' . $theFile . '" "' . $theFile . '"', $gfxConf['im_path_lzw']);
exec($cmd);
$returnCode='IM';
......
&& $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']
&& strtolower(substr($theFile,-4,4))=='.png'
&& @is_file($theFile)) { // IM
$newFile = substr($theFile,0,-4).'.gif';
$cmd = self::imageMagickCommand('convert', '"'.$theFile.'" "'.$newFile.'"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']);
$newFile = substr($theFile,0,-4) . '.gif';
$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 = self::imageMagickCommand('convert', '"'.$theFile.'" "'.$newFile.'"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path']);
$newFile = PATH_site . 'typo3temp/readPG_' . md5($theFile . '|' . filemtime($theFile)) . ($output_png?'.png':'.gif');
$cmd = self::imageMagickCommand('convert', '"' . $theFile . '" "' . $newFile . '"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path']);
exec($cmd);
if (@is_file($newFile)) return $newFile;
}
......
if ($chars >= 4) {
if(strlen($string)>$chars) {
return $origChars < 0 ?
$preStr.trim(substr($string, -($chars-3))) :
trim(substr($string, 0, $chars-3)).$preStr;
$preStr . trim(substr($string, -($chars-3))) :
trim(substr($string, 0, $chars-3)) . $preStr;
}
}
return $string;
......
$theLine = strrev($parts[1]);
} else {
$afterParts = explode(' ',substr($str,$l+$p),2);
$theLine = $substr.$afterParts[0];
$theLine = $substr . $afterParts[0];
}
if (!strlen($theLine)) {break; } // Error, because this would keep us in an endless loop.
} else {
......
* @return boolean true if $item is in $list
*/
public static function inList($list, $item) {
return (strpos(','.$list.',', ','.$item.',')!==false ? true : false);
return (strpos(',' . $list . ',', ',' . $item . ',')!==false ? true : false);
}
/**
......
*/
public static function int_from_ver($verNumberStr) {
$verParts = explode('.',$verNumberStr);
return intval((int)$verParts[0].str_pad((int)$verParts[1],3,'0',STR_PAD_LEFT).str_pad((int)$verParts[2],3,'0',STR_PAD_LEFT));
return intval((int)$verParts[0] . str_pad((int)$verParts[1],3,'0',STR_PAD_LEFT) . str_pad((int)$verParts[2],3,'0',STR_PAD_LEFT));
}
/**
......
$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).
substr('0'.dechex($nB),-2);
return '#' .
substr('0' . dechex($nR),-2) .
substr('0' . dechex($nG),-2) .
substr('0' . dechex($nB),-2);
}
/**
......
if ($sizeInBytes>900) {
if ($sizeInBytes>900000000) { // GB
$val = $sizeInBytes/(1024*1024*1024);
return number_format($val, (($val<20)?1:0), '.', '').$labelArr[3];
return number_format($val, (($val<20)?1:0), '.', '') . $labelArr[3];
}
elseif ($sizeInBytes>900000) { // MB
$val = $sizeInBytes/(1024*1024);
return number_format($val, (($val<20)?1:0), '.', '').$labelArr[2];
return number_format($val, (($val<20)?1:0), '.', '') . $labelArr[2];
} else { // KB
$val = $sizeInBytes/(1024);
return number_format($val, (($val<20)?1:0), '.', '').$labelArr[1];
return number_format($val, (($val<20)?1:0), '.', '') . $labelArr[1];
}
} else { // Bytes
return $sizeInBytes.$labelArr[0];
return $sizeInBytes . $labelArr[0];
}
}
......
*/
public static function calcPriority($string) {
$string=preg_replace('/[[:space:]]*/','',$string); // removing all whitespace
$string='+'.$string; // Ensuring an operator for the first entrance
$string='+' . $string; // Ensuring an operator for the first entrance
$qm='\*\/\+-^%';
$regex = '(['.$qm.'])(['.$qm.']?[0-9\.]*)';
$regex = '([' . $qm . '])([' . $qm . ']?[0-9\.]*)';
// split the expression here:
$reg = array();
preg_match_all('/'.$regex.'/',$string,$reg);
preg_match_all('/' . $regex . '/',$string,$reg);
reset($reg[2]);
$number=0;
......
}
}
$number = $Msign=='-' ? $number-=$buffer : $number+=$buffer;
return $err ? 'ERROR: '.$err : $number;
return $err ? 'ERROR: ' . $err : $number;
}
/**
......
$valueLenC=strcspn($string,')');
if ($valueLenC==strlen($string) || $valueLenC < $valueLenO) {
$value = self::calcPriority(substr($string,0,$valueLenC));
$string = $value.substr($string,$valueLenC+1);
$string = $value . substr($string,$valueLenC+1);
return $string;
} else {
$string = substr($string,0,$valueLenO).self::calcParenthesis(substr($string,$valueLenO+1));
$string = substr($string,0,$valueLenO) . self::calcParenthesis(substr($string,$valueLenO+1));
}
// Security:
$securC--;
......
*/
public static function slashJS($string,$extended=0,$char="'") {
if ($extended) {$string = str_replace ("\\", "\\\\", $string);}
return str_replace ($char, "\\".$char, $string);
return str_replace ($char, "\\" . $char, $string);
}
/**
......
* @return string Formatted for <textarea>-tags
*/
public static function formatForTextarea($content) {
return chr(10).htmlspecialchars($content);
return chr(10) . htmlspecialchars($content);
}
/**
......
*/
public static function implodeArrayForUrl($name, array $theArray, $str = '', $skipBlank = false, $rawurlencodeParamName = false) {
foreach($theArray as $Akey => $AVal) {
$thisKeyName = $name ? $name.'['.$Akey.']' : $Akey;
$thisKeyName = $name ? $name . '[' . $Akey . ']' : $Akey;
if (is_array($AVal)) {
$str = self::implodeArrayForUrl($thisKeyName,$AVal,$str,$skipBlank,$rawurlencodeParamName);
} else {
if (!$skipBlank || strcmp($AVal,'')) {
$str.='&'.($rawurlencodeParamName ? rawurlencode($thisKeyName) : $thisKeyName).
'='.rawurlencode($AVal);
$str.='&' . ($rawurlencodeParamName ? rawurlencode($thisKeyName) : $thisKeyName).
'=' . rawurlencode($AVal);
}
}
}
......
reset($row);
$out=array();
foreach ($row as $value) {
$out[] = str_replace($quote, $quote.$quote, $value);
$out[] = str_replace($quote, $quote . $quote, $value);
}
$str = $quote.implode($quote.$delim.$quote,$out).$quote;
$str = $quote . implode($quote . $delim . $quote,$out) . $quote;
return $str;
}
......
// There are '' around the value. We look for the next ' ' or '>'
$reg = preg_split('/[[:space:]=]/', $tag_tmp, 2);
$value[] = trim($reg[0]);
$tag_tmp = trim(substr($tag_tmp,strlen($reg[0]),1).$reg[1]);
$tag_tmp = trim(substr($tag_tmp,strlen($reg[0]),1) . $reg[1]);
}
}
reset($value);
......
}
$list = array();
foreach($arr as $p => $v) {
if (strcmp($v,'') || $dontOmitBlankAttribs) {$list[]=$p.'="'.$v.'"';}
if (strcmp($v,'') || $dontOmitBlankAttribs) {$list[]=$p . '="' . $v . '"';}
}
return implode(' ',$list);
}
......
if(preg_match('/^(\t+)/',$string,$match)) {
$string = str_replace($match[1],"\t", $string);
}
$string = $cr.'<script type="text/javascript">
$string = $cr . '<script type="text/javascript">
/*<![CDATA[*/
'.$string.'
' . $string . '
/*]]>*/
</script>'.$cr;
</script>' . $cr;
}
return trim($string);
}
......
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
xml_parse_into_struct($parser, $string, $vals, $index);
if (xml_get_error_code($parser)) return 'Line '.xml_get_current_line_number($parser).': '.xml_error_string(xml_get_error_code($parser));
if (xml_get_error_code($parser)) return 'Line ' . xml_get_current_line_number($parser) . ': ' . xml_error_string(xml_get_error_code($parser));
xml_parser_free($parser);
$stack = array( array() );
......
}
// Return XML:
return '<?xml version="1.0" encoding="'.htmlspecialchars($charset).'" standalone="yes" ?>'.chr(10).
return '<?xml version="1.0" encoding="' . htmlspecialchars($charset) . '" standalone="yes" ?>' . chr(10) .
self::array2xml($array,'',0,$docTag,0, $options);
}
......
*/
public static function array2xml(array $array,$NSprefix='',$level=0,$docTag='phparray',$spaceInd=0,array $options=array(),array $stackData=array()) {
// The list of byte values which will trigger binary-safe storage. If any value has one of these char values in it, it will be encoded in base64
$binaryChars = chr(0).chr(1).chr(2).chr(3).chr(4).chr(5).chr(6).chr(7).chr(8).
chr(11).chr(12).chr(14).chr(15).chr(16).chr(17).chr(18).chr(19).
chr(20).chr(21).chr(22).chr(23).chr(24).chr(25).chr(26).chr(27).chr(28).chr(29).
chr(30).chr(31);
$binaryChars = chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . chr(6) . chr(7) . chr(8) .
chr(11) . chr(12) . chr(14) . chr(15) . chr(16) . chr(17) . chr(18) . chr(19) .
chr(20) . chr(21) . chr(22) . chr(23) . chr(24) . chr(25) . chr(26) . chr(27) . chr(28) . chr(29) .
chr(30) . chr(31);
// Set indenting mode:
$indentChar = $spaceInd ? ' ' : chr(9);
$indentN = $spaceInd>0 ? $spaceInd : 1;
......
$tagName = $k;
// Construct the tag name.
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']) && 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
$attr.=' index="'.htmlspecialchars($tagName).'"';
$tagName = (string)$options['parentTagMap'][$stackData['parentTagName'].':'.$tagName];
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']) && 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
$attr.=' index="' . htmlspecialchars($tagName) . '"';
$tagName = (string)$options['parentTagMap'][$stackData['parentTagName'] . ':' . $tagName];
} elseif(isset($options['parentTagMap'][$stackData['parentTagName']])) { // Use tag based on parent tag name:
$attr.=' index="'.htmlspecialchars($tagName).'"';
$attr.=' index="' . htmlspecialchars($tagName) . '"';
$tagName = (string)$options['parentTagMap'][$stackData['parentTagName']];
} elseif (!strcmp(intval($tagName),$tagName)) { // If integer...;
if ($options['useNindex']) { // If numeric key, prefix "n"
$tagName = 'n'.$tagName;
$tagName = 'n' . $tagName;
} else { // Use special tag for num. keys:
$attr.=' index="'.$tagName.'"';
$attr.=' index="' . $tagName . '"';
$tagName = $options['useIndexTagForNum'] ? $options['useIndexTagForNum'] : 'numIndex';
}
} elseif($options['useIndexTagForAssoc']) { // Use tag for all associative keys:
$attr.=' index="'.htmlspecialchars($tagName).'"';
$attr.=' index="' . htmlspecialchars($tagName) . '"';
$tagName = $options['useIndexTagForAssoc'];
}
......
if (is_array($v)) {
// Sub elements:
if ($options['alt_options'][$stackData['path'].'/'.$tagName]) {
$subOptions = $options['alt_options'][$stackData['path'].'/'.$tagName];
if ($options['alt_options'][$stackData['path'] . '/' . $tagName]) {
$subOptions = $options['alt_options'][$stackData['path'] . '/' . $tagName];
$clearStackPath = $subOptions['clearStackPath'];
} else {
$subOptions = $options;
......
array(
'parentTagName' => $tagName,
'grandParentTagName' => $stackData['parentTagName'],
'path' => $clearStackPath ? '' : $stackData['path'].'/'.$tagName,
'path' => $clearStackPath ? '' : $stackData['path'] . '/' . $tagName,
)
).
) .
($spaceInd >= 0 ? str_pad('',($level+1)*$indentN,$indentChar) : '');
if ((int)$options['disableTypeAttrib']!=2) { // Do not set "type = array". Makes prettier XML but means that empty arrays are not restored with xml2array
$attr.=' type="array"';
......
$vLen = strlen($v); // check for length, because PHP 5.2.0 may crash when first argument of strcspn is empty
if ($vLen && strcspn($v,$binaryChars) != $vLen) { // Go for base64 encoding if the initial segment NOT matching any binary char has the same length as the whole string!
// If the value contained binary chars then we base64-encode it an set an attribute to notify this situation:
$content = $nl.chunk_split(base64_encode($v));
$content = $nl . chunk_split(base64_encode($v));
$attr.=' base64="1"';
} else {
// Otherwise, just htmlspecialchar the stuff:
......
$content = '<![CDATA[' . $v . ']]>';
}
} elseif (!$options['disableTypeAttrib']) {
$attr.= ' type="'.$dType.'"';
$attr.= ' type="' . $dType . '"';
}
}
}
// Add the element to the output string:
$output.=($spaceInd >= 0 ? str_pad('',($level+1)*$indentN,$indentChar) : '').'<'.$NSprefix.$tagName.$attr.'>'.$content.'</'.$NSprefix.$tagName.'>'.$nl;
$output.=($spaceInd >= 0 ? str_pad('',($level+1)*$indentN,$indentChar) : '') . '<' . $NSprefix . $tagName . $attr . '>' . $content . '</' . $NSprefix . $tagName . '>' . $nl;
}
// If we are at the outer-most level, then we finally wrap it all in the document tags and return that as the value:
if (!$level) {
$output =
'<'.$docTag.'>'.$nl.
$output.
'</'.$docTag.'>';
'<' . $docTag . '>' . $nl .
$output .
'</' . $docTag . '>';
}
return $output;
......
// If error, return error message:
if (xml_get_error_code($parser)) {
return 'Line '.xml_get_current_line_number($parser).': '.xml_error_string(xml_get_error_code($parser));
return 'Line ' . xml_get_current_line_number($parser) . ': ' . xml_error_string(xml_get_error_code($parser));
}
xml_parser_free($parser);
......
// open tag:
if ($type=='open' || $type=='complete') {
$XMLcontent.='<'.$val['tag'];
$XMLcontent.='<' . $val['tag'];
if(isset($val['attributes'])) {
foreach($val['attributes'] as $k => $v) {
$XMLcontent.=' '.$k.'="'.htmlspecialchars($v).'"';
$XMLcontent.=' ' . $k . '="' . htmlspecialchars($v) . '"';
}
}
if ($type=='complete') {
if(isset($val['value'])) {
$XMLcontent.='>'.htmlspecialchars($val['value']).'</'.$val['tag'].'>';
$XMLcontent.='>' . htmlspecialchars($val['value']) . '</' . $val['tag'] . '>';
} else $XMLcontent.='/>';
} else $XMLcontent.='>';
......
}
// finish tag:
if ($type=='close') {
$XMLcontent.='</'.$val['tag'].'>';
$XMLcontent.='</' . $val['tag'] . '>';
}
// cdata
if($type=='cdata') {
......
}
$errno = 0;
// $errstr = '';
$fp = @fsockopen($scheme.$parsedURL['host'], $port, $errno, $errstr, 2.0);
$fp = @fsockopen($scheme . $parsedURL['host'], $port, $errno, $errstr, 2.0);
if (!$fp || $errno > 0) {
if (isset($report)) {
$report['error'] = $errno ? $errno : -1;
......
* Writes $content to a filename in the typo3temp/ folder (and possibly one or two subfolders...)
* Accepts an additional subdirectory in the file path!
*
* @param string Absolute filepath to write to inside "typo3temp/". First part of this string must match PATH_site."typo3temp/"
* @param string Absolute filepath to write to inside "typo3temp/". First part of this string must match PATH_site . "typo3temp/"
* @param string Content string to write
* @return string Returns false on success, otherwise an error string telling about the problem.
*/
......
// Check parts:
if (self::validPathStr($filepath) && $fI['basename'] && strlen($fI['basename'])<60) {
if (defined('PATH_site')) {
$dirName = PATH_site.'typo3temp/'; // Setting main temporary directory name (standard)
$dirName = PATH_site . 'typo3temp/'; // Setting main temporary directory name (standard)
if (@is_dir($dirName)) {
if (self::isFirstPartOfStr($fI['dirname'],$dirName)) {
......
if (preg_match('/^[[:alnum:]_]+\/$/',$subdir) || preg_match('/^[[:alnum:]_]+\/[[:alnum:]_]+\/$/',$subdir)) {
$dirName.= $subdir;
if (!@is_dir($dirName)) {
self::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:]_]/"';
} 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']) {
if ($filepath == $dirName . $fI['basename']) {
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!';
} else return '"'.$fI['dirname'].'" was not within directory PATH_site + "typo3temp/"';
} else return '"' . $dirName . '" is not a directory!';
} else return '"' . $fI['dirname'] . '" was not within directory PATH_site + "typo3temp/"';
} else return 'PATH_site + "typo3temp/" was not a directory!';
} else return 'PATH_site constant was NOT defined!';
} else return 'Input filepath "'.$filepath.'" was generally invalid!';
} else return 'Input filepath "' . $filepath . '" was generally invalid!';
}
/**
......
$allParts = self::trimExplode('/',$deepDir,1);
$root = '';
foreach($allParts as $part) {
$root.= $part.'/';
if (!is_dir($destination.$root)) {
self::mkdir($destination.$root);
if (!@is_dir($destination.$root)) {
return 'Error: The directory "'.$destination.$root.'" could not be created...';
$root.= $part . '/';
if (!is_dir($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 = self::rmdir($path.'/'.$file,$removeNonEmpty);
$OK = self::rmdir($path . '/' . $file,$removeNonEmpty);
}
closedir($handle);
}
......
$d = dir($path);
if (is_object($d)) {
while($entry=$d->read()) {
if (@is_file($path.'/'.$entry)) {
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) || 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);}
$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) || 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;}
}
}
}
$d->close();
} else return 'error opening path: "'.$path.'"';
} else return 'error opening path: "' . $path . '"';
}
// Sort them:
......
$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 = self::getAllFilesAndFoldersInPath($fileArr,$path.$subdirs.'/',$extList,$regDirs,$recursivityLevels-1,$excludePattern);
if ((string)$subdirs!='' && (!strlen($excludePattern) || !preg_match('/^' . $excludePattern . '$/',$subdirs))) {
$fileArr = self::getAllFilesAndFoldersInPath($fileArr,$path . $subdirs . '/',$extList,$regDirs,$recursivityLevels-1,$excludePattern);
}
}
}
......
public static function locationHeaderUrl($path) {
$uI = parse_url($path);
if (substr($path,0,1)=='/') { // relative to HOST
$path = self::getIndpEnv('TYPO3_REQUEST_HOST').$path;
$path = self::getIndpEnv('TYPO3_REQUEST_HOST') . $path;
} elseif (!$uI['scheme']) { // No scheme either
$path = self::getIndpEnv('TYPO3_REQUEST_DIR').$path;
$path = self::getIndpEnv('TYPO3_REQUEST_DIR') . $path;
}
return $path;
}
......
public static function debug_ordvalue($string,$characters=100) {
if(strlen($string) < $characters) $characters = strlen($string);
for ($i=0; $i<$characters; $i++) {
$valuestring.=' '.ord(substr($string,$i,1));
$valuestring.=' ' . ord(substr($string,$i,1));
}
return trim($valuestring);
}
......
} else {
foreach ($array_in as $key => $val) {
$result.= '<tr>
<td valign="top"><font face="Verdana,Arial" size="1">'.htmlspecialchars((string)$key).'</font></td>
<td valign="top"><font face="Verdana,Arial" size="1">' . htmlspecialchars((string)$key) . '</font></td>
<td>';
if (is_array($val)) {
$result.=self::view_array($val);
} elseif (is_object($val)) {
$string = get_class($val);
if (method_exists($val, '__toString')) {
$string .= ': '.(string)$val;
$string .= ': ' . (string)$val;
}
$result .= '<font face="Verdana,Arial" size="1" color="red">'.nl2br(htmlspecialchars($string)).'<br /></font>';
$result .= '<font face="Verdana,Arial" size="1" color="red">' . nl2br(htmlspecialchars($string)) . '<br /></font>';
} else {
if (gettype($val) == 'object') {
$string = 'Unknown object';
} else {
$string = (string)$val;
}
$result.= '<font face="Verdana,Arial" size="1" color="red">'.nl2br(htmlspecialchars($string)).'<br /></font>';
$result.= '<font face="Verdana,Arial" size="1" color="red">' . nl2br(htmlspecialchars($string)) . '<br /></font>';
}
$result.= '</td>
</tr>';
......
} else {
$result = '<table border="1" cellpadding="1" cellspacing="0" bgcolor="white">
<tr>
<td><font face="Verdana,Arial" size="1" color="red">'.nl2br(htmlspecialchars((string)$array_in)).'<br /></font></td>
<td><font face="Verdana,Arial" size="1" color="red">' . nl2br(htmlspecialchars((string)$array_in)) . '<br /></font></td>
</tr>
</table>'; // Output it as a string.
}
......
}
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>';
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 />';}
}
......
print_r($var);
echo '</pre>|</b>';
} elseif ((string)$var!='') {
echo '<b>|'.htmlspecialchars((string)$var).'|</b>';
echo '<b>|' . htmlspecialchars((string)$var) . '|</b>';
} else {
echo '<b>| debug |</b>';
}
......
$path = array();
foreach($trail as $dat) {
$path[] = $dat['class'].$dat['type'].$dat['function'].'#'.$dat['line'];
$path[] = $dat['class'] . $dat['type'] . $dat['function'] . '#' . $dat['line'];
}
return implode(' // ',$path);
......
$tRows = array();
// Header:
$tRows[] = '<tr><td colspan="'.count($headerColumns).'" style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;"><strong>'.htmlspecialchars($header).'</strong></td></tr>';
$tRows[] = '<tr><td colspan="' . count($headerColumns) . '" style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;"><strong>' . htmlspecialchars($header) . '</strong></td></tr>';
$tCells = array();
foreach($headerColumns as $key) {
$tCells[] = '
<td><font face="Verdana,Arial" size="1"><strong>'.htmlspecialchars($key).'</strong></font></td>';
<td><font face="Verdana,Arial" size="1"><strong>' . htmlspecialchars($key) . '</strong></font></td>';
}
$tRows[] = '
<tr>'.implode('',$tCells).'
<tr>' . implode('',$tCells) . '
</tr>';
// Rows:
......
$tCells = array();
foreach($headerColumns as $key) {
$tCells[] = '
<td><font face="Verdana,Arial" size="1">'.(is_array($singleRow[$key]) ? self::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).'
<tr>' . implode('',$tCells) . '
</tr>';
}
$table = '
<table border="1" cellpadding="1" cellspacing="0" bgcolor="white">'.implode('',$tRows).'
<table border="1" cellpadding="1" cellspacing="0" bgcolor="white">' . implode('',$tRows) . '
</table>';
if ($returnHTML) return $table; else echo $table;
} else debug('Empty array of rows',$header);
......
*/
public static function getThisUrl() {
$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);
$dir=self::dirname($p['path']) . '/'; // Strip file
$url = str_replace('//','/',$p['host'] . ($p['port']?':' . $p['port']:'') . $dir);
return $url;
}
......
$uP = explode('?',$url);
$params = self::implodeArrayForUrl('',$getP);
$outurl = $uP[0].($params ? '?'.substr($params, 1) : '');
$outurl = $uP[0] . ($params ? '?' . substr($params, 1) : '');
return $outurl;
}
......
// add a prefix if TYPO3 is behind a proxy: ext-domain.com => int-server.com/prefix
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;
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'] . $retVal;
} elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix']) {
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'].$retVal;
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'] . $retVal;
}
}
break;
......
$retVal = str_replace('//','/', str_replace('\\','/', (PHP_SAPI=='cgi'||PHP_SAPI=='isapi' ||PHP_SAPI=='cgi-fcgi')&&($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED'])? ($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED']):($_SERVER['ORIG_SCRIPT_FILENAME']?$_SERVER['ORIG_SCRIPT_FILENAME']:$_SERVER['SCRIPT_FILENAME'])));
break;
case 'REQUEST_URI':
// Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))
// Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar']) { // This is for URL rewriters that store the original URI in a server variable (eg ISAPI_Rewriter for IIS: HTTP_X_REWRITE_URL)
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(self::getIndpEnv('SCRIPT_NAME'), '/').
($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:'');
$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 (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;
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'] . $retVal;
} elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix']) {
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'].$retVal;
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'] . $retVal;
}
}
break;
......
$retVal = $p[1];
break;
case 'TYPO3_REQUEST_HOST':
$retVal = (self::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://').
$retVal = (self::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://') .
self::getIndpEnv('HTTP_HOST');
break;
case 'TYPO3_REQUEST_URL':
$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST').self::getIndpEnv('REQUEST_URI');
$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST') . self::getIndpEnv('REQUEST_URI');
break;
case 'TYPO3_REQUEST_SCRIPT':
$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST').self::getIndpEnv('SCRIPT_NAME');
$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST') . self::getIndpEnv('SCRIPT_NAME');
break;
case 'TYPO3_REQUEST_DIR':
$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST').self::dirname(self::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)).'/';
$lPath = substr(dirname(PATH_thisScript),strlen(PATH_site)) . '/';
$url = self::getIndpEnv('TYPO3_REQUEST_DIR');
$siteUrl = substr($url,0,-strlen($lPath));
if (substr($siteUrl,-1)!='/') $siteUrl.='/';
......
list($extKey,$local) = explode('/',substr($filename,4),2);
$filename='';
if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
$filename = t3lib_extMgm::extPath($extKey).$local;
$filename = t3lib_extMgm::extPath($extKey) . $local;
}
} elseif (!self::isAbsPath($filename)) { // relative. Prepended with $relPathPrefix
$filename=$relPathPrefix.$filename;
$filename=$relPathPrefix . $filename;
} elseif ($onlyRelative && !self::isFirstPartOfStr($filename,$relPathPrefix)) { // absolute, but set to blank if not allowed
$filename='';
}
......
*/
public static function verifyFilenameAgainstDenyPattern($filename) {
if (strcmp($filename,'') && strcmp($GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'],'')) {
$result = preg_match('/'.$GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'].'/i',$filename);
$result = preg_match('/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] . '/i',$filename);
if ($result) return false; // so if a matching filename is found, return false;
}
return true;
......
}
/**
* Will move an uploaded file (normally in "/tmp/xxxxx") to a temporary filename in PATH_site."typo3temp/" from where TYPO3 can use it under safe_mode.
* Will move an uploaded file (normally in "/tmp/xxxxx") to a temporary filename in PATH_site . "typo3temp/" from where TYPO3 can use it under safe_mode.
* Use this function to move uploaded files to where you can work on them.
* REMEMBER to use t3lib_div::unlink_tempfile() afterwards - otherwise temp-files will build up! They are NOT automatically deleted in PATH_site."typo3temp/"!
* REMEMBER to use t3lib_div::unlink_tempfile() afterwards - otherwise temp-files will build up! They are NOT automatically deleted in PATH_site . "typo3temp/"!
* Usage: 6
*
* @param string The temporary uploaded filename, eg. $_FILES['[upload field name here]']['tmp_name']
......
}
/**
* Deletes (unlink) a temporary filename in 'PATH_site."typo3temp/"' given as input.
* The function will check that the file exists, is in PATH_site."typo3temp/" and does not contain back-spaces ("../") so it should be pretty safe.
* Deletes (unlink) a temporary filename in 'PATH_site . "typo3temp/"' given as input.
* The function will check that the file exists, is in PATH_site . "typo3temp/" and does not contain back-spaces ("../") so it should be pretty safe.
* Use this after upload_to_tempfile() or tempnam() from this class!
* Usage: 9
*
* @param string Filepath for a file in PATH_site."typo3temp/". Must be absolute.
* @param string Filepath for a file in PATH_site . "typo3temp/". Must be absolute.
* @return boolean Returns true if the file was unlink()'ed
* @see upload_to_tempfile(), tempnam()
*/
public static function unlink_tempfile($uploadedTempFileName) {
if ($uploadedTempFileName && self::validPathStr($uploadedTempFileName) && self::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;
}
}
......
* Usage: 7
*
* @param string Prefix to temp file (which will have no extension btw)
* @return string result from PHP function tempnam() with PATH_site.'typo3temp/' set for temp path.
* @return string result from PHP function tempnam() with PATH_site . 'typo3temp/' set for temp path.
* @see unlink_tempfile(), upload_to_tempfile()
*/
public static function tempnam($filePrefix) {
return tempnam(PATH_site.'typo3temp/',$filePrefix);
return tempnam(PATH_site . 'typo3temp/',$filePrefix);
}
/**
......
$preKey = $uid_or_record;
}
$authCode = $preKey.'||'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
$authCode = $preKey . '||' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
$authCode = substr(md5($authCode),0,$codeLength);
return $authCode;
}
......
if ($file) {
$baseFile = preg_replace('/\.(php|xml)$/', '', $file);
if (@is_file($baseFile.'.xml')) {
$LOCAL_LANG = self::readLLXMLfile($baseFile.'.xml', $langKey, $charset);
} elseif (@is_file($baseFile.'.php')) {
if (@is_file($baseFile . '.xml')) {
$LOCAL_LANG = self::readLLXMLfile($baseFile . '.xml', $langKey, $charset);
} elseif (@is_file($baseFile . '.php')) {
if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] || $charset) {
$LOCAL_LANG = self::readLLPHPfile($baseFile.'.php', $langKey, $charset);
$LOCAL_LANG = self::readLLPHPfile($baseFile . '.php', $langKey, $charset);
} else {
include($baseFile.'.php');
include($baseFile . '.php');
if (is_array($LOCAL_LANG)) {
$LOCAL_LANG = array('default'=>$LOCAL_LANG['default'], $langKey=>$LOCAL_LANG[$langKey]); }
}
} else {
$errorMsg = 'File "' . $fileRef. '" not found!';
$errorMsg = 'File "' . $fileRef . '" not found!';
if ($errorMode == 2) {
throw new t3lib_exception($errorMsg);
} elseif(!$errorMode) {
......
}
// Cache file name:
$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).
'_'.self::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
$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) .
'_' . 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 = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
if ($res) die('ERROR: '.$res);
if ($res) die('ERROR: ' . $res);
} else {
// Get content from cache:
$serContent = unserialize(self::getUrl($cacheFileName));
......
}
// Cache file name:
$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).
'_'.self::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
$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) .
'_' . 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 = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
if ($res) die('ERROR: '.$res);
if ($res) die('ERROR: ' . $res);
} else {
// Get content from cache:
$serContent = unserialize(self::getUrl($cacheFileName));
......
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).
'_'.self::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
$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) .
'_' . self::shortMD5($hashSource) . '.' . $langKey . '.' . $targetCharset . '.cache';
// Check if cache file exists...
if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it:
......
$serContent = array('extlang'=>$langKey, 'origFile'=>$hashSource, 'EXT_DATA'=>$LOCAL_LANG[$langKey]);
$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
if ($res) {
die('ERROR: '.$res);
die('ERROR: ' . $res);
}
} else {
// Get content from cache:
......
*/
public static function llXmlAutoFileName($fileRef,$language) {
// Analyse file reference:
$location = 'typo3conf/l10n/'.$language.'/'; // Default location of translations
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 (self::isFirstPartOfStr($fileRef,PATH_typo3.'ext/')) { // Is global:
$validatedPrefix = PATH_typo3.'ext/';
} elseif (self::isFirstPartOfStr($fileRef,PATH_typo3conf.'ext/')) { // Is local:
$validatedPrefix = PATH_typo3conf.'ext/';
$location = 'typo3conf/l10n/' . $language . '/'; // Default location of translations
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 (self::isFirstPartOfStr($fileRef,PATH_typo3 . 'ext/')) { // Is global:
$validatedPrefix = PATH_typo3 . 'ext/';
} elseif (self::isFirstPartOfStr($fileRef,PATH_typo3conf . 'ext/')) { // Is local:
$validatedPrefix = PATH_typo3conf . 'ext/';
} else {
$validatedPrefix = '';
}
......
list($file_extPath,$file_fileName) = $temp;
// The filename is prefixed with "[language key]." because it prevents the llxmltranslate tool from detecting it.
return $location.
$file_extKey.'/'.
($file_extPath?$file_extPath.'/':'').
$language.'.'.$file_fileName;
return $location .
$file_extKey . '/' .
($file_extPath?$file_extPath . '/':'') .
$language . '.' . $file_fileName;
} else {
return NULL;
}
......
$dcf = $tca['ctrl']['dynamicConfigFile'];
if ($dcf) {
if (!strcmp(substr($dcf,0,6),'T3LIB:')) {
include(PATH_t3lib.'stddb/'.substr($dcf,6));
include(PATH_t3lib . 'stddb/' . substr($dcf,6));
} elseif (self::isAbsPath($dcf) && @is_file($dcf)) { // Absolute path...
include($dcf);
} else include(PATH_typo3conf.$dcf);
} else include(PATH_typo3conf . $dcf);
}
}
}
......
array(&$params, &$ref)
);
} else {
$errorMsg = "<strong>ERROR:</strong> No method name '".$parts[1]."' in class ".$parts[0];
$errorMsg = "<strong>ERROR:</strong> No method name '" . $parts[1] . "' in class " . $parts[0];
if ($errorMode == 2) {
throw new Exception($errorMsg);
} elseif(!$errorMode) {
......
}
}
} else {
$errorMsg = "<strong>ERROR:</strong> No class named: ".$parts[0];
$errorMsg = "<strong>ERROR:</strong> No class named: " . $parts[0];
if ($errorMode == 2) {
throw new Exception($errorMsg);
} elseif(!$errorMode) {
......
if (function_exists($funcRef)) {
$content = call_user_func_array($funcRef, array(&$params, &$ref));
} else {
$errorMsg = "<strong>ERROR:</strong> No function named: ".$funcRef;
$errorMsg = "<strong>ERROR:</strong> No function named: " . $funcRef;
if ($errorMode == 2) {
throw new Exception($errorMsg);
} elseif(!$errorMode) {
......
!self::isFirstPartOfStr(trim($class),$checkPrefix) &&
!self::isFirstPartOfStr(trim($class),'tx_')
) {
if (!$silent) debug("Class '".$class."' was not prepended with '".$checkPrefix."'",1);
if (!$silent) debug("Class '" . $class . "' was not prepended with '" . $checkPrefix. "'",1);
return FALSE;
}
......
return $classObj;
} else {
if (!$silent) debug("<strong>ERROR:</strong> No class named: ".$class,1);
if (!$silent) debug("<strong>ERROR:</strong> No class named: " . $class,1);
}
}
}
......
public static function makeInstanceClassName($className) {
self::logDeprecatedFunction();
return (class_exists($className) && class_exists('ux_'.$className, false) ? self::makeInstanceClassName('ux_' . $className) : $className);
return (class_exists($className) && class_exists('ux_' . $className, false) ? self::makeInstanceClassName('ux_' . $className) : $className);
}
/**
......
if (is_object($obj)) {
if(!@is_callable(array($obj,'init'))) {
// use silent logging??? I don't think so.
die ('Broken service:'.self::view_array($info));
die ('Broken service:' . self::view_array($info));
}
$obj->info = $info;
if ($obj->init()) { // service available?
......
switch ((string)$encoding) {
case 'base64':
$headers=trim($headers).chr(10).
'Mime-Version: 1.0'.chr(10).
'Content-Type: text/plain; charset="'.$charset.'"'.chr(10).
$headers=trim($headers) . chr(10) .
'Mime-Version: 1.0' . chr(10) .
'Content-Type: text/plain; charset="' . $charset . '"' . chr(10) .
'Content-Transfer-Encoding: base64';
$message=trim(chunk_split(base64_encode($message.chr(10)))).chr(10); // Adding chr(10) because I think MS outlook 2002 wants it... may be removed later again.
$message=trim(chunk_split(base64_encode($message . chr(10)))) . chr(10); // Adding chr(10) because I think MS outlook 2002 wants it... may be removed later again.
break;
case '8bit':
$headers=trim($headers).chr(10).
'Mime-Version: 1.0'.chr(10).
'Content-Type: text/plain; charset='.$charset.chr(10).
$headers=trim($headers) . chr(10) .
'Mime-Version: 1.0' . chr(10) .
'Content-Type: text/plain; charset=' . $charset . chr(10) .
'Content-Transfer-Encoding: 8bit';
break;
case 'quoted-printable':
default:
$headers=trim($headers).chr(10).
'Mime-Version: 1.0'.chr(10).
'Content-Type: text/plain; charset='.$charset.chr(10).
$headers=trim($headers) . chr(10) .
'Mime-Version: 1.0' . chr(10) .
'Content-Type: text/plain; charset=' . $charset . chr(10) .
'Content-Transfer-Encoding: quoted-printable';
$message=self::quoted_printable($message);
......
$ret = @mail($email, $subject, $message, $headers);
if (!$ret) {
self::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;
}
......
*/
public static function quoted_printable($string,$maxlen=76) {
// Make sure the string contains only Unix linebreaks
$string = str_replace(chr(13).chr(10), chr(10), $string); // Replace Windows breaks (\r\n)
$string = str_replace(chr(13) . chr(10), chr(10), $string); // Replace Windows breaks (\r\n)
$string = str_replace(chr(13), chr(10), $string); // Replace Mac breaks (\r)
$linebreak = chr(10); // Default line break for Unix systems.
if (TYPO3_OS=='WIN') {
$linebreak = chr(13).chr(10); // Line break for Windows. This is needed because PHP on Windows systems send mails via SMTP instead of using sendmail, and thus the linebreak needs to be \r\n.
$linebreak = chr(13) . chr(10); // Line break for Windows. This is needed because PHP on Windows systems send mails via SMTP instead of using sendmail, and thus the linebreak needs to be \r\n.
}
$newString = '';
......
$char = substr($val,$index,1);
$ordVal = ord($char);
if ($len>($maxlen-4) || ($len>($maxlen-14) && $ordVal==32)) {
$newVal.='='.$linebreak; // Add a line break
$newVal.='=' . $linebreak; // Add a line break
$len=0; // Reset the length counter
}
if (($ordVal>=33 && $ordVal<=60) || ($ordVal>=62 && $ordVal<=126) || $ordVal==9 || $ordVal==32) {
......
$len+=3;
}
}
$newVal = preg_replace('/'.chr(32).'$/','=20',$newVal); // Replaces a possible SPACE-character at the end of a line
$newVal = preg_replace('/'.chr(9).'$/','=09',$newVal); // Replaces a possible TAB-character at the end of a line
$newString.=$newVal.$linebreak;
$newVal = preg_replace('/' . chr(32) . '$/','=20',$newVal); // Replaces a possible SPACE-character at the end of a line
$newVal = preg_replace('/' . chr(9) . '$/','=09',$newVal); // Replaces a possible TAB-character at the end of a line
$newString.=$newVal . $linebreak;
}
return preg_replace('/'.$linebreak.'$/','',$newString); // Remove last newline
return preg_replace('/' . $linebreak . '$/','',$newString); // Remove last newline
}
/**
......
return $line;
}
// Check if any non-ASCII characters are found - otherwise encoding is not needed
if (!preg_match('/[^'.chr(32).'-'.chr(127).']/',$line)) {
if (!preg_match('/[^' . chr(32) . '-' . chr(127) . ']/',$line)) {
return $line;
}
// Wrap email addresses in a special marker
......
$oldPart = $part;
switch ((string)$enc) {
case 'base64':
$part = '=?'.$charset.'?B?'.base64_encode($part).'?=';
$part = '=?' . $charset . '?B?' . base64_encode($part) . '?=';
break;
case 'quoted-printable':
default:
......
$search = array(' ', '?');
$replace = array('_', '=3F');
$qpValue = str_replace($search, $replace, $qpValue);
$part = '=?'.$charset.'?Q?'.$qpValue.'?=';
$part = '=?' . $charset . '?Q?' . $qpValue . '?=';
}
break;
}
......
public static function substUrlsInPlainText($message,$urlmode='76',$index_script_url='') {
// Substitute URLs with shorter links:
foreach (array('http','https') as $protocol) {
$urlSplit = explode($protocol.'://',$message);
$urlSplit = explode($protocol . '://',$message);
foreach ($urlSplit as $c => &$v) {
if ($c) {
$newParts = preg_split('/\s|[<>"{}|\\\^`()\']/', $v, 2);
$newURL = $protocol.'://'.$newParts[0];
$newURL = $protocol . '://' . $newParts[0];
switch ((string)$urlmode) {
case 'all':
......
*
* @param string Input URL
* @param integer URL string length limit
* @param string URL of "index script" - the prefix of the "?RDCT=..." parameter. If not supplyed it will default to t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php'
* @param string URL of "index script" - the prefix of the "?RDCT=..." parameter. If not supplyed it will default to t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR') . 'index.php'
* @return string Processed URL
*/
public static function makeRedirectUrl($inUrl,$l=0,$index_script_url='') {
......
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_md5params', $insertFields);
}
$inUrl=($index_script_url ? $index_script_url : self::getIndpEnv('TYPO3_REQUEST_DIR').'index.php').
'?RDCT='.$md5;
$inUrl=($index_script_url ? $index_script_url : self::getIndpEnv('TYPO3_REQUEST_DIR') . 'index.php').
'?RDCT=' . $md5;
}
return $inUrl;
......
// 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'] = self::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 {
......
if (TYPO3_OS == 'WIN') {
$facility = LOG_USER;
} else {
$facility = constant('LOG_'.strtoupper($destination));
$facility = constant('LOG_' . strtoupper($destination));
}
openlog($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'], LOG_ODELAY, $facility);
}
......
// is message worth logging for this log type?
if (intval($level) > $severity) continue;
$msgLine = ' - '.$extKey.': '.$msg;
$msgLine = ' - ' . $extKey . ': ' . $msg;
// write message to a file
if ($type == 'file') {
$file = fopen($destination, 'a');
if ($file) {
flock($file, LOCK_EX); // try locking, but ignore if not available (eg. on NFS and FAT)
fwrite($file, date($dateFormat.' '.$timeFormat).$msgLine.chr(10));
fwrite($file, date($dateFormat . ' ' . $timeFormat) . $msgLine . chr(10));
flock($file, LOCK_UN); // release the lock
fclose($file);
}
......
elseif ($type == 'mail') {
list($to,$from) = explode('/',$destination);
mail($to, 'Warning - error in TYPO3 installation',
'Host: '.$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost']."\n".
'Extension: '.$extKey."\n".
'Severity: '.$severity."\n".
"\n".$msg,
($from ? 'From: '.$from : '')
'Host: ' . $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . "\n" .
'Extension: ' . $extKey . "\n" .
'Severity: ' . $severity . "\n" .
"\n" . $msg,
($from ? 'From: ' . $from : '')
);
}
// use the PHP error log
elseif ($type == 'error_log') {
error_log($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'].$msgLine, 0);
error_log($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . $msgLine, 0);
}
// use the system log
elseif ($type == 'syslog') {
......
if ($file) {
$date = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ': ');
flock($file, LOCK_EX); // try locking, but ignore if not available (eg. on NFS and FAT)
@fwrite($file, $date.$msg.chr(10));
@fwrite($file, $date . $msg . chr(10));
flock($file, LOCK_UN); // release the lock
@fclose($file);
}
......
if ($trail[1]['class']) {
$errorMsg .= ' of class ' . $trail[1]['class'];
}
$errorMsg .= ' is deprecated (called from '.$trail[1]['file'] . '#' . $trail[1]['line'] . ', defined in ' . $function->getFileName() . '#' . $function->getStartLine() . ')';
$errorMsg .= ' is deprecated (called from ' . $trail[1]['file'] . '#' . $trail[1]['line'] . ', defined in ' . $function->getFileName() . '#' . $function->getStartLine() . ')';
// michael@typo3.org: Temporary disabled until error handling is implemented (follows later this week...)
/*
......
// write a longer message to the deprecation log: <function> <annotion> - <trace> (<source>)
$logMsg = $trail[1]['class'] . $trail[1]['type'] . $trail[1]['function'];
$logMsg .= '() - ' . $msg.' - ' . self::debug_trail();
$logMsg .= '() - ' . $msg . ' - ' . self::debug_trail();
$logMsg .= ' (' . substr($function->getFileName(), strlen(PATH_site)) . '#' . $function->getStartLine() . ')';
self::deprecationLog($logMsg);
}
......
$valListCnt = count($valueList);
foreach ($arr as $key => $value) {
if (!$valListCnt || in_array($key, $valueList)) {
$str .= (string)$key.trim(': '.self::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;
......
// Compile the path & command
if($im_version==='gm') {
$switchCompositeParameters=true;
$path .= 'gm'.$isExt.' '.$command;
$path .= 'gm' . $isExt . ' ' . $command;
} else {
if($im_version==='im6') { $switchCompositeParameters=true; }
$path .= (($command=='composite') ? $combineScript : $command).$isExt;
$path .= (($command=='composite') ? $combineScript : $command) . $isExt;
}
// strip profile information for thumbnails and reduce their size
......
}
}
$cmdLine = $path.' '.$parameters;
$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 = self::unQuoteFilenames($parameters);
......
$paramsArr[count($paramsArr)-4] = $tmp;
}
$cmdLine = $path.' '.implode(' ', $paramsArr);
$cmdLine = $path . ' ' . implode(' ', $paramsArr);
}
return $cmdLine;
......
$quoteActive = -1; // Whenever a quote character (") is found, $quoteActive is set to the element number inside of $params. A value of -1 means that there are not open quotes at the current position.
foreach ($paramsArr as $k => $v) {
if($quoteActive > -1) {
$paramsArr[$quoteActive] .= ' '.$v;
$paramsArr[$quoteActive] .= ' ' . $v;
unset($paramsArr[$k]);
if(preg_match('/"$/', $v)) { $quoteActive = -1; }
    (1-1/1)