128 static public function _GP($var) {
132 $value = isset($_POST[$var]) ? $_POST[$var] : $_GET[$var];
134 if (is_array($value)) {
135 self::stripSlashesOnArray($value);
137 $value = stripslashes($value);
150 $postParameter = isset($_POST[$parameter]) && is_array($_POST[$parameter]) ? $_POST[$parameter] : array();
151 $getParameter = isset($_GET[$parameter]) && is_array($_GET[$parameter]) ? $_GET[$parameter] : array();
152 $mergedParameters = $getParameter;
154 self::stripSlashesOnArray($mergedParameters);
155 return $mergedParameters;
166 static public function _GET($var = NULL) {
167 $value = $var === NULL ? $_GET : (empty($var) ? NULL : $_GET[$var]);
170 if (is_array($value)) {
171 self::stripSlashesOnArray($value);
173 $value = stripslashes($value);
187 static public function _POST($var = NULL) {
188 $value = $var === NULL ? $_POST : (empty($var) ? NULL : $_POST[$var]);
191 if (is_array($value)) {
192 self::stripSlashesOnArray($value);
194 $value = stripslashes($value);
207 static public function _GETset($inputGet, $key =
'') {
210 if (is_array($inputGet)) {
211 self::addSlashesOnArray($inputGet);
213 $inputGet = addslashes($inputGet);
216 if (strpos($key,
'|') !== FALSE) {
217 $pieces = explode(
'|', $key);
220 foreach ($pieces as $piece) {
221 $pointer = &$pointer[$piece];
223 $pointer = $inputGet;
227 $GLOBALS[
'HTTP_GET_VARS'] = $mergedGet;
229 $_GET[$key] = $inputGet;
230 $GLOBALS[
'HTTP_GET_VARS'][$key] = $inputGet;
232 } elseif (is_array($inputGet)) {
234 $GLOBALS[
'HTTP_GET_VARS'] = $inputGet;
248 require_once PATH_typo3 .
'contrib/RemoveXSS/RemoveXSS.php';
249 $string = \RemoveXSS::process($string);
277 $gfxConf =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'];
280 if ($gfxConf[
'gif_compress'] &&
strtolower(substr($theFile, -4, 4)) ==
'.gif') {
282 if (($type ==
'IM' || !$type) && $gfxConf[
'im'] && $gfxConf[
'im_path_lzw']) {
284 $temporaryName =
dirname($theFile) .
'/' . md5(uniqid(
'', TRUE)) .
'.gif';
286 if (@rename($theFile, $temporaryName)) {
287 $cmd = self::imageMagickCommand(
'convert',
'"' . $temporaryName .
'" "' . $theFile .
'"', $gfxConf[
'im_path_lzw']);
289 unlink($temporaryName);
292 if (@is_file($theFile)) {
293 self::fixPermissions($theFile);
295 } elseif (($type ==
'GD' || !$type) && $gfxConf[
'gdlib'] && !$gfxConf[
'gdlib_png']) {
297 $tempImage = imageCreateFromGif($theFile);
298 imageGif($tempImage, $theFile);
299 imageDestroy($tempImage);
301 if (@is_file($theFile)) {
302 self::fixPermissions($theFile);
317 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'png_to_gif'] &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im'] &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_path_lzw'] &&
strtolower(substr($theFile, -4, 4)) ==
'.png' && @is_file($theFile)) {
319 $newFile = substr($theFile, 0, -4) .
'.gif';
320 $cmd = self::imageMagickCommand(
'convert',
'"' . $theFile .
'" "' . $newFile .
'"',
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_path_lzw']);
323 if (@is_file($newFile)) {
324 self::fixPermissions($newFile);
339 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im'] && @is_file($theFile)) {
341 if ((
string) $ext ==
'.png' && $output_png || (
string) $ext ==
'.gif' && !$output_png) {
344 $newFile = PATH_site .
'typo3temp/readPG_' . md5(($theFile .
'|' . filemtime($theFile))) . ($output_png ?
'.png' :
'.gif');
345 $cmd = self::imageMagickCommand(
'convert',
'"' . $theFile .
'" "' . $newFile .
'"',
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_path']);
347 if (@is_file($newFile)) {
348 self::fixPermissions($newFile);
368 static public function fixed_lgd_cs($string, $chars, $appendString =
'...') {
370 return $GLOBALS[
'LANG']->csConvObj->crop(
$GLOBALS[
'LANG']->charSet, $string, $chars, $appendString);
371 } elseif (is_object(
$GLOBALS[
'TSFE']) && is_object(
$GLOBALS[
'TSFE']->csConvObj)) {
372 $charSet =
$GLOBALS[
'TSFE']->renderCharset !=
'' ?
$GLOBALS[
'TSFE']->renderCharset :
$GLOBALS[
'TSFE']->defaultCharSet;
373 return $GLOBALS[
'TSFE']->csConvObj->crop($charSet, $string, $chars, $appendString);
376 $csConvObj = self::makeInstance(
'TYPO3\\CMS\\Core\\Charset\\CharsetConverter');
377 return $csConvObj->crop(
'utf-8', $string, $chars, $appendString);
389 static public function cmpIP($baseIP, $list) {
393 } elseif ($list ===
'*') {
396 if (strpos($baseIP,
':') !== FALSE && self::validIPv6($baseIP)) {
397 return self::cmpIPv6($baseIP, $list);
399 return self::cmpIPv4($baseIP, $list);
410 static public function cmpIPv4($baseIP, $list) {
411 $IPpartsReq = explode(
'.', $baseIP);
412 if (count($IPpartsReq) == 4) {
413 $values = self::trimExplode(
',', $list, TRUE);
414 foreach ($values as $test) {
415 $testList = explode(
'/', $test);
416 if (count($testList) == 2) {
417 list($test, $mask) = $testList;
423 $lnet = ip2long($test);
424 $lip = ip2long($baseIP);
425 $binnet = str_pad(decbin($lnet), 32,
'0', STR_PAD_LEFT);
426 $firstpart = substr($binnet, 0, $mask);
427 $binip = str_pad(decbin($lip), 32,
'0', STR_PAD_LEFT);
428 $firstip = substr($binip, 0, $mask);
429 $yes = $firstpart === $firstip;
432 $IPparts = explode(
'.', $test);
434 foreach ($IPparts as $index => $val) {
436 if ($val !==
'*' && $IPpartsReq[$index] !== $val) {
456 static public function cmpIPv6($baseIP, $list) {
459 $baseIP = self::normalizeIPv6($baseIP);
460 $values = self::trimExplode(
',', $list, TRUE);
461 foreach ($values as $test) {
462 $testList = explode(
'/', $test);
463 if (count($testList) == 2) {
464 list($test, $mask) = $testList;
468 if (self::validIPv6($test)) {
469 $test = self::normalizeIPv6($test);
470 $maskInt = (int)$mask ?: 128;
474 } elseif ($maskInt == 128) {
475 $success = $test === $baseIP;
477 $testBin = self::IPv6Hex2Bin($test);
478 $baseIPBin = self::IPv6Hex2Bin($baseIP);
481 $maskIntModulo = $maskInt % 8;
482 $numFullCharactersUntilBoundary = (int)($maskInt / 8);
483 if (substr($testBin, 0, $numFullCharactersUntilBoundary) !== substr($baseIPBin, 0, $numFullCharactersUntilBoundary)) {
485 } elseif ($maskIntModulo > 0) {
487 $testLastBits = str_pad(decbin(ord(substr($testBin, $numFullCharactersUntilBoundary, 1))), 8,
'0', STR_PAD_LEFT);
488 $baseIPLastBits = str_pad(decbin(ord(substr($baseIPBin, $numFullCharactersUntilBoundary, 1))), 8,
'0', STR_PAD_LEFT);
489 if (strncmp($testLastBits, $baseIPLastBits, $maskIntModulo) != 0) {
510 return inet_pton($hex);
521 return inet_ntop($bin);
532 $normalizedAddress =
'';
533 $stageOneAddress =
'';
537 if (strlen($address) == 39) {
542 $chunks = explode(
'::', $address);
543 if (count($chunks) == 2) {
544 $chunksLeft = explode(
':', $chunks[0]);
545 $chunksRight = explode(
':', $chunks[1]);
546 $left = count($chunksLeft);
547 $right = count($chunksRight);
549 if ($left == 1 && strlen($chunksLeft[0]) == 0) {
552 $hiddenBlocks = 8 - ($left + $right);
555 while ($h < $hiddenBlocks) {
556 $hiddenPart .=
'0000:';
560 $stageOneAddress = $hiddenPart . $chunks[1];
562 $stageOneAddress = $chunks[0] .
':' . $hiddenPart . $chunks[1];
565 $stageOneAddress = $address;
568 $blocks = explode(
':', $stageOneAddress);
570 foreach ($blocks as $block) {
573 $hiddenZeros = 4 - strlen($block);
574 while ($i < $hiddenZeros) {
578 $normalizedAddress .= $tmpBlock . $block;
579 if ($divCounter < 7) {
580 $normalizedAddress .=
':';
584 return $normalizedAddress;
595 return inet_ntop(inet_pton($address));
607 return filter_var($ip, FILTER_VALIDATE_IP) !== FALSE;
619 return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== FALSE;
631 return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE;
641 static public function cmpFQDN($baseHost, $list) {
642 $baseHost = trim($baseHost);
643 if (empty($baseHost)) {
646 if (self::validIPv4($baseHost) || self::validIPv6($baseHost)) {
650 $baseHostName = gethostbyaddr($baseHost);
651 if ($baseHostName === $baseHost) {
656 $baseHostName = $baseHost;
658 $baseHostNameParts = explode(
'.', $baseHostName);
659 $values = self::trimExplode(
',', $list, TRUE);
660 foreach ($values as $test) {
661 $hostNameParts = explode(
'.', $test);
663 if (count($hostNameParts) > count($baseHostNameParts)) {
667 foreach ($hostNameParts as $index => $val) {
671 $wildcardStart = $index + 1;
673 if ($wildcardStart < count($hostNameParts)) {
674 $wildcardMatched = FALSE;
675 $tempHostName = implode(
'.', array_slice($hostNameParts, $index + 1));
676 while ($wildcardStart < count($baseHostNameParts) && !$wildcardMatched) {
677 $tempBaseHostName = implode(
'.', array_slice($baseHostNameParts, $wildcardStart));
678 $wildcardMatched = self::cmpFQDN($tempBaseHostName, $tempHostName);
681 if ($wildcardMatched) {
688 } elseif ($baseHostNameParts[$index] !== $val) {
708 return stripos($url .
'/', self::getIndpEnv(
'TYPO3_REQUEST_HOST') .
'/') === 0;
719 static public function inList($list, $item) {
720 return strpos(
',' . $list .
',',
',' . $item .
',') !== FALSE;
734 $items = explode(
',', $list);
735 foreach ($items as $k => $v) {
736 if ($v == $element) {
740 return implode(
',', $items);
751 $items = explode(
',', $list);
753 foreach ($items as $item) {
754 $range = explode(
'-', $item);
755 if (isset($range[1])) {
756 $runAwayBrake = 1000;
757 for ($n = $range[0]; $n <= $range[1]; $n++) {
760 if ($runAwayBrake <= 0) {
768 return implode(
',', $list);
779 self::logDeprecatedFunction();
792 $currVersionStr =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'compat_version'] ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'compat_version'] : TYPO3_branch;
807 return hexdec(substr(md5($str), 0, 7));
817 static public function shortMD5($input, $len = 10) {
818 return substr(md5($input), 0, $len);
828 static public function hmac($input, $additionalSecret =
'') {
829 $hashAlgorithm =
'sha1';
832 $secret =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'encryptionKey'] . $additionalSecret;
833 if (extension_loaded(
'hash') && function_exists(
'hash_hmac') && function_exists(
'hash_algos') && in_array($hashAlgorithm, hash_algos())) {
834 $hmac = hash_hmac($hashAlgorithm, $input, $secret);
837 $opad = str_repeat(chr(92), $hashBlocksize);
839 $ipad = str_repeat(chr(54), $hashBlocksize);
840 if (strlen($secret) > $hashBlocksize) {
842 $key = str_pad(pack(
'H*', call_user_func($hashAlgorithm, $secret)), $hashBlocksize, chr(0));
845 $key = str_pad($secret, $hashBlocksize, chr(0));
847 $hmac = call_user_func($hashAlgorithm, ($key ^ $opad) . pack(
'H*', call_user_func($hashAlgorithm, (($key ^ $ipad) . $input))));
860 static public function uniqueList($in_list, $secondParameter = NULL) {
861 if (is_array($in_list)) {
862 throw new \InvalidArgumentException(
'TYPO3 Fatal Error: TYPO3\\CMS\\Core\\Utility\\GeneralUtility::uniqueList() does NOT support array arguments anymore! Only string comma lists!', 1270853885);
864 if (isset($secondParameter)) {
865 throw new \InvalidArgumentException(
'TYPO3 Fatal Error: TYPO3\\CMS\\Core\\Utility\\GeneralUtility::uniqueList() does NOT support more than a single argument value anymore. You have specified more than one!', 1270853886);
867 return implode(
',', array_unique(self::trimExplode(
',', $in_list, TRUE)));
878 if (preg_match(
'/(.*\\/)(.*)$/', $fileNameWithPath, $reg)) {
879 $info[
'path'] = $reg[1];
880 $info[
'file'] = $reg[2];
883 $info[
'file'] = $fileNameWithPath;
887 if (!is_dir($fileNameWithPath) && preg_match(
'/(.*)\\.([^\\.]*$)/', $info[
'file'], $reg)) {
888 $info[
'filebody'] = $reg[1];
890 $info[
'realFileext'] = $reg[2];
892 $info[
'filebody'] = $info[
'file'];
893 $info[
'fileext'] =
'';
915 $p = self::revExplode(
'/', $path, 2);
916 return count($p) == 2 ? $p[0] :
'';
934 return '#' . substr((
'0' . dechex($nR)), -2) . substr((
'0' . dechex($nG)), -2) . substr((
'0' . dechex($nB)), -2);
946 return self::modifyHTMLColor($color, $all, $all, $all);
957 return $partStr !=
'' && strpos((
string) $str, (
string) $partStr, 0) === 0;
967 static public function formatSize($sizeInBytes, $labels =
'') {
969 if (strlen($labels) == 0) {
970 $labels =
' | K| M| G';
972 $labels = str_replace(
'"',
'', $labels);
974 $labelArr = explode(
'|', $labels);
976 if ($sizeInBytes > 900) {
978 if ($sizeInBytes > 900000000) {
979 $val = $sizeInBytes / (1024 * 1024 * 1024);
980 return number_format($val, ($val < 20 ? 1 : 0),
'.',
'') . $labelArr[3];
981 } elseif ($sizeInBytes > 900000) {
983 $val = $sizeInBytes / (1024 * 1024);
984 return number_format($val, ($val < 20 ? 1 : 0),
'.',
'') . $labelArr[2];
987 $val = $sizeInBytes / 1024;
988 return number_format($val, ($val < 20 ? 1 : 0),
'.',
'') . $labelArr[1];
992 return $sizeInBytes . $labelArr[0];
1003 $parts = explode(
' ', $microtime);
1004 return round(($parts[0] + $parts[1]) * 1000);
1019 $valueLen = strcspn($string, $operators);
1020 $value = substr($string, 0, $valueLen);
1021 $res[] = array($sign, trim($value));
1022 $sign = substr($string, $valueLen, 1);
1023 $string = substr($string, $valueLen + 1);
1038 self::logDeprecatedFunction();
1052 return preg_replace(
'/&([#[:alnum:]]*;)/',
'&\\1', $str);
1063 static public function slashJS($string, $extended = FALSE, $char =
'\'') {
1065 $string = str_replace(
'\\',
'\\\\', $string);
1067 return str_replace($char,
'\\' . $char, $string);
1078 return str_replace(
'%20',
' ', rawurlencode($str));
1089 return str_replace(
'%2F',
'/', rawurlencode($str));
1112 if (!is_string($email)) {
1115 $atPosition = strrpos($email,
'@');
1116 if (!$atPosition || $atPosition + 1 === strlen($email)) {
1120 $domain = substr($email, $atPosition + 1);
1121 $user = substr($email, 0, $atPosition);
1122 if (!preg_match(
'/^[a-z0-9.\\-]*$/i', $domain)) {
1123 $domain = self::idnaEncode($domain);
1125 return filter_var($user .
'@' . $domain, FILTER_VALIDATE_EMAIL) !== FALSE;
1141 return TYPO3_OS ==
'WIN' || FALSE !== strpos(ini_get(
'sendmail_path'),
'mini_sendmail');
1151 if (self::isBrokenEmailEnvironment() && FALSE !== ($pos1 = strrpos($address,
'<'))) {
1152 $pos2 = strpos($address,
'>', $pos1);
1153 $address = substr($address, $pos1 + 1, ($pos2 ? $pos2 : strlen($address)) - $pos1 - 1);
1167 return LF . htmlspecialchars($content);
1180 return strtr((
string) $str,
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
1193 return strtr((
string) $str,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz');
1210 $bytesToGenerate = max(4096, $bytesToReturn);
1212 if (!isset($bytes[($bytesToReturn - 1)])) {
1213 if (TYPO3_OS ===
'WIN') {
1215 $bytes .= self::generateRandomBytesMcrypt($bytesToGenerate);
1218 $bytes .= self::generateRandomBytesOpenSsl($bytesToGenerate);
1219 if (!isset($bytes[($bytesToReturn - 1)])) {
1220 $bytes .= self::generateRandomBytesMcrypt($bytesToGenerate);
1223 if (!isset($bytes[($bytesToReturn - 1)])) {
1224 $bytes .= self::generateRandomBytesUrandom($bytesToGenerate);
1228 if (!isset($bytes[($bytesToReturn - 1)])) {
1229 $bytes .= self::generateRandomBytesFallback($bytesToReturn);
1233 $output = substr($bytes, 0, $bytesToReturn);
1234 $bytes = substr($bytes, $bytesToReturn);
1245 if (!function_exists(
'openssl_random_pseudo_bytes')) {
1249 return (
string) openssl_random_pseudo_bytes($bytesToGenerate, $isStrong);
1259 if (!function_exists(
'mcrypt_create_iv')) {
1262 return (
string)(@mcrypt_create_iv($bytesToGenerate, MCRYPT_DEV_URANDOM));
1273 $fh = @fopen(
'/dev/urandom',
'rb');
1278 $bytes = fread($fh, $bytesToGenerate);
1293 $randomState =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'encryptionKey'] . base_convert(memory_get_usage() % pow(10, 6), 10, 2) . microtime() . uniqid(
'', TRUE) . getmypid();
1294 while (!isset($bytes[($bytesToReturn - 1)])) {
1295 $randomState = sha1(microtime() . mt_rand() . $randomState);
1296 $bytes .= sha1(mt_rand() . $randomState, TRUE);
1308 if (isset(self::$idnaStringCache[$value])) {
1309 return self::$idnaStringCache[$value];
1311 if (!self::$idnaConverter) {
1312 require_once PATH_typo3 .
'contrib/idna/idna_convert.class.php';
1313 self::$idnaConverter = new \idna_convert(array(
'idn_version' => 2008));
1315 self::$idnaStringCache[$value] = self::$idnaConverter->encode($value);
1316 return self::$idnaStringCache[$value];
1327 return substr(bin2hex(self::generateRandomBytes((
int)(($count + 1) / 2))), 0, $count);
1338 $upperCamelCase = str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', self::strtolower($string))));
1339 return $upperCamelCase;
1350 $upperCamelCase = str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', self::strtolower($string))));
1351 $lowerCamelCase = self::lcfirst($upperCamelCase);
1352 return $lowerCamelCase;
1363 return self::strtolower(preg_replace(
'/(?<=\\w)([A-Z])/',
'_\\1', $string));
1374 return self::strtolower($string[0]) . substr($string, 1);
1402 $parsedUrl = parse_url($url);
1403 if (!$parsedUrl || !isset($parsedUrl[
'scheme'])) {
1410 if (!self::isFirstPartOfStr($url, $parsedUrl[
'scheme'] .
'://')) {
1411 $url = str_replace($parsedUrl[
'scheme'] .
':', $parsedUrl[
'scheme'] .
'://', $url);
1414 if ($recomposedUrl !== $url) {
1418 if (isset($parsedUrl[
'host']) && !preg_match(
'/^[a-z0-9.\\-]*$/i', $parsedUrl[
'host'])) {
1419 $parsedUrl[
'host'] = self::idnaEncode($parsedUrl[
'host']);
1451 static public function inArray(array $in_array, $item) {
1452 foreach ($in_array as $val) {
1453 if (!is_array($val) && (
string)$val === (
string)$item) {
1470 static public function intExplode($delimiter, $string, $removeEmptyValues = FALSE, $limit = 0) {
1471 $result = explode($delimiter, $string);
1472 foreach (
$result as $key => &$value) {
1473 if ($removeEmptyValues && ($value ===
'' || trim($value) ===
'')) {
1476 $value = (int)$value;
1483 } elseif (count(
$result) > $limit) {
1484 $lastElements = array_slice(
$result, $limit - 1);
1486 $result[] = implode($delimiter, $lastElements);
1506 static public function revExplode($delimiter, $string, $count = 0) {
1509 $position = strrpos($string, strrev($delimiter));
1510 if ($position !== FALSE) {
1511 return array(substr($string, 0, $position), substr($string, $position + strlen($delimiter)));
1513 return array($string);
1515 } elseif ($count <= 1) {
1516 return array($string);
1518 $explodedValues = explode($delimiter, strrev($string), $count);
1519 $explodedValues = array_map(
'strrev', $explodedValues);
1520 return array_reverse($explodedValues);
1536 static public function trimExplode($delim, $string, $removeEmptyValues = FALSE, $limit = 0) {
1537 $result = explode($delim, $string);
1538 if ($removeEmptyValues) {
1541 if (trim($value) !==
'') {
1547 if ($limit > 0 && count(
$result) > $limit) {
1548 $lastElements = array_slice(
$result, $limit - 1);
1550 $result[] = implode($delim, $lastElements);
1551 } elseif ($limit < 0) {
1566 foreach ($array as $k => $v) {
1568 $array[$k] = self::removeArrayEntryByValue($v, $cmpValue);
1569 } elseif ((
string)$v === (
string)$cmpValue) {
1602 if (is_string($keepItems)) {
1603 $keepItems = self::trimExplode(
',', $keepItems);
1606 if (!is_callable($getValueFunc)) {
1607 $getValueFunc = NULL;
1610 if (is_array($keepItems) && count($keepItems)) {
1611 foreach ($array as $key => $value) {
1613 $keepValue = isset($getValueFunc) ? call_user_func($getValueFunc, $value) : $value;
1614 if (!in_array($keepValue, $keepItems)) {
1615 unset($array[$key]);
1634 static public function implodeArrayForUrl($name, array $theArray, $str =
'', $skipBlank = FALSE, $rawurlencodeParamName = FALSE) {
1635 foreach ($theArray as $Akey => $AVal) {
1636 $thisKeyName = $name ? $name .
'[' . $Akey .
']' : $Akey;
1637 if (is_array($AVal)) {
1638 $str = self::implodeArrayForUrl($thisKeyName, $AVal, $str, $skipBlank, $rawurlencodeParamName);
1640 if (!$skipBlank || (
string)$AVal !==
'') {
1641 $str .=
'&' . ($rawurlencodeParamName ? rawurlencode($thisKeyName) : $thisKeyName) .
'=' . rawurlencode($AVal);
1659 parse_str($string, $output);
1661 $p = explode(
'&', $string);
1662 foreach ($p as $v) {
1664 list($pK, $pV) = explode(
'=', $v, 2);
1665 $output[rawurldecode($pK)] = rawurldecode($pV);
1682 $keys = self::trimExplode(
',', $varList, TRUE);
1684 foreach ($keys as $v) {
1685 if (isset($getArray[$v])) {
1686 $outArr[$v] = $getArray[$v];
1687 } elseif ($GPvarAlt) {
1688 $outArr[$v] = self::_GP($v);
1704 foreach ($theArray as &$value) {
1705 if (is_array($value)) {
1706 self::addSlashesOnArray($value);
1708 $value = addslashes($value);
1725 foreach ($theArray as &$value) {
1726 if (is_array($value)) {
1727 self::stripSlashesOnArray($value);
1729 $value = stripslashes($value);
1744 if ($cmd ==
'strip') {
1745 self::stripSlashesOnArray($arr);
1747 if ($cmd ==
'add') {
1748 self::addSlashesOnArray($arr);
1760 if (is_array($mappingTable)) {
1761 foreach ($mappingTable as $old => $new) {
1762 if ($new && isset($array[$old])) {
1763 $array[$new] = $array[$old];
1764 unset($array[$old]);
1785 self::logDeprecatedFunction();
1799 return $arr2 + $arr1;
1811 $differenceArray = array();
1812 foreach ($array1 as $key => $value) {
1813 if (!array_key_exists($key, $array2)) {
1814 $differenceArray[$key] = $value;
1815 } elseif (is_array($value)) {
1816 if (is_array($array2[$key])) {
1817 $differenceArray[$key] = self::arrayDiffAssocRecursive($value, $array2[$key]);
1821 return $differenceArray;
1832 static public function csvValues(array $row, $delim =
',', $quote =
'"') {
1834 foreach ($row as $value) {
1835 $out[] = str_replace($quote, $quote . $quote, $value);
1837 $str = $quote . implode(($quote . $delim . $quote), $out) . $quote;
1850 foreach ($ts as $key => $value) {
1851 if (is_array($value)) {
1852 $key = rtrim($key,
'.');
1853 $out[$key] = self::removeDotsFromTS($value);
1855 $out[$key] = $value;
1868 if (!is_array($array)) {
1871 uksort($array,
'strnatcasecmp');
1872 foreach ($array as $key => $value) {
1873 self::naturalKeySortRecursive($array[$key]);
1892 $components = self::split_tag_attributes($tag);
1896 $attributes = array();
1897 foreach ($components as $key => $val) {
1902 $attributes[$name] = $val;
1906 if ($key =
strtolower(preg_replace(
'/[^[:alnum:]_\\:\\-]/',
'', $val))) {
1907 $attributes[$key] =
'';
1927 $tag_tmp = trim(preg_replace(
'/^<[^[:space:]]*/',
'', trim($tag)));
1929 $tag_tmp = trim(rtrim($tag_tmp,
'>'));
1932 while ($tag_tmp !==
'') {
1933 $firstChar = $tag_tmp[0];
1934 if ($firstChar ===
'"' || $firstChar ===
'\'') {
1935 $reg = explode($firstChar, $tag_tmp, 3);
1937 $tag_tmp = trim($reg[2]);
1938 } elseif ($firstChar ===
'=') {
1941 $tag_tmp = trim(substr($tag_tmp, 1));
1944 $reg = preg_split(
'/[[:space:]=]/', $tag_tmp, 2);
1945 $value[] = trim($reg[0]);
1946 $tag_tmp = trim(substr($tag_tmp, strlen($reg[0]), 1) . $reg[1]);
1961 static public function implodeAttributes(array $arr, $xhtmlSafe = FALSE, $dontOmitBlankAttribs = FALSE) {
1964 foreach ($arr as $p => $v) {
1966 $newArr[
strtolower($p)] = htmlspecialchars($v);
1972 foreach ($arr as $p => $v) {
1973 if ((
string)$v !==
'' || $dontOmitBlankAttribs) {
1974 $list[] = $p .
'="' . $v .
'"';
1977 return implode(
' ', $list);
1989 static public function wrapJS($string, $linebreak = TRUE) {
1990 if (trim($string)) {
1992 $cr = $linebreak ? LF :
'';
1994 $string = preg_replace(
'/^\\n+/',
'', $string);
1997 if (preg_match(
'/^(\\t+)/', $string, $match)) {
1998 $string = str_replace($match[1], TAB, $string);
2000 $string = $cr .
'<script type="text/javascript"> 2006 return trim($string);
2017 static public function xml2tree($string, $depth = 999) {
2019 $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
2020 $parser = xml_parser_create();
2023 xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
2024 xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
2025 xml_parse_into_struct($parser, $string, $vals, $index);
2026 libxml_disable_entity_loader($previousValueOfEntityLoader);
2027 if (xml_get_error_code($parser)) {
2028 return 'Line ' . xml_get_current_line_number($parser) .
': ' . xml_error_string(xml_get_error_code($parser));
2030 xml_parser_free($parser);
2031 $stack = array(array());
2035 foreach ($vals as $key => $val) {
2036 $type = $val[
'type'];
2038 if ($type ==
'open' || $type ==
'complete') {
2039 $stack[$stacktop++] = $tagi;
2040 if ($depth == $stacktop) {
2043 $tagi = array(
'tag' => $val[
'tag']);
2044 if (isset($val[
'attributes'])) {
2045 $tagi[
'attrs'] = $val[
'attributes'];
2047 if (isset($val[
'value'])) {
2048 $tagi[
'values'][] = $val[
'value'];
2052 if ($type ==
'complete' || $type ==
'close') {
2054 $tagi = $stack[--$stacktop];
2055 $oldtag = $oldtagi[
'tag'];
2056 unset($oldtagi[
'tag']);
2057 if ($depth == $stacktop + 1) {
2058 if ($key - $startPoint > 0) {
2059 $partArray = array_slice($vals, $startPoint + 1, $key - $startPoint - 1);
2060 $oldtagi[
'XMLvalue'] = self::xmlRecompileFromStructValArray($partArray);
2062 $oldtagi[
'XMLvalue'] = $oldtagi[
'values'][0];
2065 $tagi[
'ch'][$oldtag][] = $oldtagi;
2069 if ($type ==
'cdata') {
2070 $tagi[
'values'][] = $val[
'value'];
2086 static public function array2xml_cs(array $array, $docTag =
'phparray', array $options = array(), $charset =
'') {
2088 $charset = $charset ?:
'utf-8';
2090 return '<?xml version="1.0" encoding="' . htmlspecialchars($charset) .
'" standalone="yes" ?>' . LF . self::array2xml($array,
'', 0, $docTag, 0, $options);
2115 static public function array2xml(array $array, $NSprefix =
'', $level = 0, $docTag =
'phparray', $spaceInd = 0, array $options = array(), array $stackData = array()) {
2117 $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);
2119 $indentChar = $spaceInd ?
' ' : TAB;
2120 $indentN = $spaceInd > 0 ? $spaceInd : 1;
2121 $nl = $spaceInd >= 0 ? LF :
'';
2125 foreach ($array as $k => $v) {
2130 if (isset($options[
'grandParentTagMap'][$stackData[
'grandParentTagName'] .
'/' . $stackData[
'parentTagName']])) {
2131 $attr .=
' index="' . htmlspecialchars($tagName) .
'"';
2132 $tagName = (string) $options[
'grandParentTagMap'][($stackData[
'grandParentTagName'] .
'/' . $stackData[
'parentTagName'])];
2135 $attr .=
' index="' . htmlspecialchars($tagName) .
'"';
2136 $tagName = (string) $options[
'parentTagMap'][($stackData[
'parentTagName'] .
':_IS_NUM')];
2137 } elseif (isset($options[
'parentTagMap'][$stackData[
'parentTagName'] .
':' . $tagName])) {
2139 $attr .=
' index="' . htmlspecialchars($tagName) .
'"';
2140 $tagName = (string) $options[
'parentTagMap'][($stackData[
'parentTagName'] .
':' . $tagName)];
2141 } elseif (isset($options[
'parentTagMap'][$stackData[
'parentTagName']])) {
2143 $attr .=
' index="' . htmlspecialchars($tagName) .
'"';
2144 $tagName = (string) $options[
'parentTagMap'][$stackData[
'parentTagName']];
2147 if ($options[
'useNindex']) {
2149 $tagName =
'n' . $tagName;
2152 $attr .=
' index="' . $tagName .
'"';
2153 $tagName = $options[
'useIndexTagForNum'] ?:
'numIndex';
2155 } elseif ($options[
'useIndexTagForAssoc']) {
2157 $attr .=
' index="' . htmlspecialchars($tagName) .
'"';
2158 $tagName = $options[
'useIndexTagForAssoc'];
2161 $tagName = substr(preg_replace(
'/[^[:alnum:]_-]/',
'', $tagName), 0, 100);
2165 if ($options[
'alt_options'][$stackData[
'path'] .
'/' . $tagName]) {
2166 $subOptions = $options[
'alt_options'][$stackData[
'path'] .
'/' . $tagName];
2167 $clearStackPath = $subOptions[
'clearStackPath'];
2169 $subOptions = $options;
2170 $clearStackPath = FALSE;
2175 $content = $nl . self::array2xml($v, $NSprefix, ($level + 1),
'', $spaceInd, $subOptions, array(
2176 'parentTagName' => $tagName,
2177 'grandParentTagName' => $stackData[
'parentTagName'],
2178 'path' => ($clearStackPath ?
'' : $stackData[
'path'] .
'/' . $tagName)
2179 )) . ($spaceInd >= 0 ? str_pad(
'', ($level + 1) * $indentN, $indentChar) :
'');
2182 if ((
int)$options[
'disableTypeAttrib'] != 2) {
2183 $attr .=
' type="array"';
2191 if ($vLen && strcspn($v, $binaryChars) != $vLen) {
2193 $content = $nl . chunk_split(base64_encode($v));
2194 $attr .=
' base64="1"';
2197 $content = htmlspecialchars($v);
2198 $dType = gettype($v);
2199 if ($dType ==
'string') {
2200 if ($options[
'useCDATA'] && $content != $v) {
2201 $content =
'<![CDATA[' . $v .
']]>';
2203 } elseif (!$options[
'disableTypeAttrib']) {
2204 $attr .=
' type="' . $dType .
'"';
2208 if ((
string)$tagName !==
'') {
2210 $output .= ($spaceInd >= 0 ? str_pad(
'', ($level + 1) * $indentN, $indentChar) :
'')
2211 .
'<' . $NSprefix . $tagName . $attr .
'>' . $content .
'</' . $NSprefix . $tagName .
'>' . $nl;
2216 $output =
'<' . $docTag .
'>' . $nl . $output .
'</' . $docTag .
'>';
2232 static public function xml2array($string, $NSprefix =
'', $reportDocTag = FALSE) {
2233 static $firstLevelCache = array();
2234 $identifier = md5($string . $NSprefix . ($reportDocTag ?
'1' :
'0'));
2236 if (!empty($firstLevelCache[$identifier])) {
2237 $array = $firstLevelCache[$identifier];
2241 if (!is_array($array)) {
2242 $array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
2246 $firstLevelCache[$identifier] = $array;
2263 $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
2265 $parser = xml_parser_create();
2268 xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
2269 xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
2272 preg_match(
'/^[[:space:]]*<\\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"/', substr($string, 0, 200), $match);
2273 $theCharset = $match[1] ?:
'utf-8';
2275 xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $theCharset);
2277 xml_parse_into_struct($parser, $string, $vals, $index);
2278 libxml_disable_entity_loader($previousValueOfEntityLoader);
2280 if (xml_get_error_code($parser)) {
2281 return 'Line ' . xml_get_current_line_number($parser) .
': ' . xml_error_string(xml_get_error_code($parser));
2283 xml_parser_free($parser);
2285 $stack = array(array());
2291 foreach ($vals as $key => $val) {
2293 $tagName = $val[
'tag'];
2294 if (!$documentTag) {
2295 $documentTag = $tagName;
2298 $tagName = $NSprefix && substr($tagName, 0, strlen($NSprefix)) == $NSprefix ? substr($tagName, strlen($NSprefix)) : $tagName;
2300 $testNtag = substr($tagName, 1);
2304 if (strlen($val[
'attributes'][
'index'])) {
2305 $tagName = $val[
'attributes'][
'index'];
2308 switch ($val[
'type']) {
2312 $current[$tagName] = array();
2313 $stack[$stacktop++] = $current;
2318 $oldCurrent = $current;
2319 $current = $stack[--$stacktop];
2322 $current[key($current)] = $oldCurrent;
2327 if ($val[
'attributes'][
'base64']) {
2328 $current[$tagName] = base64_decode($val[
'value']);
2331 $current[$tagName] = (string) $val[
'value'];
2333 switch ((
string) $val[
'attributes'][
'type']) {
2335 $current[$tagName] = (int)$current[$tagName];
2338 $current[$tagName] = (double) $current[$tagName];
2341 $current[$tagName] = (bool) $current[$tagName];
2344 $current[$tagName] = NULL;
2348 $current[$tagName] = array();
2355 if ($reportDocTag) {
2356 $current[$tagName][
'_DOCUMENT_TAG'] = $documentTag;
2359 return $current[$tagName];
2370 foreach ($vals as $val) {
2371 $type = $val[
'type'];
2373 if ($type ==
'open' || $type ==
'complete') {
2374 $XMLcontent .=
'<' . $val[
'tag'];
2375 if (isset($val[
'attributes'])) {
2376 foreach ($val[
'attributes'] as $k => $v) {
2377 $XMLcontent .=
' ' . $k .
'="' . htmlspecialchars($v) .
'"';
2380 if ($type ==
'complete') {
2381 if (isset($val[
'value'])) {
2382 $XMLcontent .=
'>' . htmlspecialchars($val[
'value']) .
'</' . $val[
'tag'] .
'>';
2384 $XMLcontent .=
'/>';
2389 if ($type ==
'open' && isset($val[
'value'])) {
2390 $XMLcontent .= htmlspecialchars($val[
'value']);
2394 if ($type ==
'close') {
2395 $XMLcontent .=
'</' . $val[
'tag'] .
'>';
2398 if ($type ==
'cdata') {
2399 $XMLcontent .= htmlspecialchars($val[
'value']);
2413 if (preg_match(
'/^\\s*<\\?xml([^>]*)\\?\\>/', $xmlData, $match)) {
2414 return self::get_tag_attributes($match[1]);
2426 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'minifyJavaScript'])) {
2428 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'minifyJavaScript'] as $hookMethod) {
2431 $script = static::callUserFunction($hookMethod,
$parameters, $fakeThis);
2433 $errorMessage =
'Error minifying java script: ' . $e->getMessage();
2434 $error .= $errorMessage;
2435 static::devLog($errorMessage,
'TYPO3\\CMS\\Core\\Utility\\GeneralUtility', 2, array(
2436 'JavaScript' => $script,
2437 'Stack trace' => $e->getTrace(),
2438 'hook' => $hookMethod
2461 static public function getUrl($url, $includeHeader = 0, $requestHeaders = FALSE, &$report = NULL) {
2463 if (isset($report)) {
2464 $report[
'error'] = 0;
2465 $report[
'message'] =
'';
2468 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlUse'] ==
'1' && preg_match(
'/^(?:http|ftp)s?|s(?:ftp|cp):/', $url)) {
2469 if (isset($report)) {
2470 $report[
'lib'] =
'cURL';
2473 if (!function_exists(
'curl_init') || !($ch = curl_init())) {
2474 if (isset($report)) {
2475 $report[
'error'] = -1;
2476 $report[
'message'] =
'Couldn\'t initialize cURL.';
2481 $followLocationSucceeded = @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
2483 $curlIncludeHeaders = !$followLocationSucceeded || $includeHeader;
2484 curl_setopt($ch, CURLOPT_URL, $url);
2485 curl_setopt($ch, CURLOPT_HEADER, $curlIncludeHeaders ? 1 : 0);
2486 curl_setopt($ch, CURLOPT_NOBODY, $includeHeader == 2 ? 1 : 0);
2487 curl_setopt($ch, CURLOPT_HTTPGET, $includeHeader == 2 ?
'HEAD' :
'GET');
2488 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
2489 curl_setopt($ch, CURLOPT_FAILONERROR, 1);
2490 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, max(0, (
int)
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlTimeout']));
2492 if (is_array($requestHeaders)) {
2493 curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
2496 if ($GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlProxyServer']) {
2497 curl_setopt($ch, CURLOPT_PROXY, $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlProxyServer']);
2498 if ($GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlProxyNTLM']) {
2499 curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
2501 if ($GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlProxyTunnel']) {
2502 curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlProxyTunnel']);
2504 if ($GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlProxyUserPass']) {
2505 curl_setopt($ch, CURLOPT_PROXYUSERPWD, $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlProxyUserPass']);
2508 $content = curl_exec($ch);
2509 $curlInfo = curl_getinfo($ch);
2520 if ($GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlProxyServer']
2521 && $curlIncludeHeaders
2522 && preg_match(
'/^https:/', $url)
2523 && strpos($content,
"\r\n\r\nHTTP/") !==
false 2525 $content = self::stripHttpHeaders($content);
2528 if (!$followLocationSucceeded) {
2530 if ($curlInfo[
'http_code'] >= 300 && $curlInfo[
'http_code'] < 400) {
2531 $locationUrl = $curlInfo[
'redirect_url'];
2532 if (!$locationUrl) {
2534 $locationUrl = self::getRedirectUrlFromHttpHeaders($content);
2537 $content = self::getUrl($locationUrl, $includeHeader, $requestHeaders, $report);
2538 $followLocationSucceeded = TRUE;
2544 if ($content && !$includeHeader) {
2545 $content = self::stripHttpHeaders($content);
2549 if (isset($report)) {
2550 if (!$followLocationSucceeded && $curlInfo[
'http_code'] >= 300 && $curlInfo[
'http_code'] < 400) {
2551 $report[
'http_code'] = $curlInfo[
'http_code'];
2552 $report[
'content_type'] = $curlInfo[
'content_type'];
2553 $report[
'error'] = CURLE_GOT_NOTHING;
2554 $report[
'message'] =
'Expected "Location" header but got nothing.';
2555 } elseif ($content === FALSE) {
2556 $report[
'error'] = curl_errno($ch);
2557 $report[
'message'] = curl_error($ch);
2558 } elseif ($includeHeader) {
2560 $report[
'http_code'] = $curlInfo[
'http_code'];
2561 $report[
'content_type'] = $curlInfo[
'content_type'];
2565 } elseif ($includeHeader) {
2566 if (isset($report)) {
2567 $report[
'lib'] =
'socket';
2569 $parsedURL = parse_url($url);
2570 if (!preg_match(
'/^https?/', $parsedURL[
'scheme'])) {
2571 if (isset($report)) {
2572 $report[
'error'] = -1;
2573 $report[
'message'] =
'Reading headers is not allowed for this protocol.';
2577 $port = (int)$parsedURL[
'port'];
2579 if ($parsedURL[
'scheme'] ==
'http') {
2580 $port = $port > 0 ? $port : 80;
2583 $port = $port > 0 ? $port : 443;
2588 $fp = @fsockopen(($scheme . $parsedURL[
'host']), $port, $errno, $errstr, 2.0);
2589 if (!$fp || $errno > 0) {
2590 if (isset($report)) {
2591 $report[
'error'] = $errno ?: -1;
2592 $report[
'message'] = $errno ? ($errstr ?:
'Socket error.') :
'Socket initialization error.';
2596 $method = $includeHeader == 2 ?
'HEAD' :
'GET';
2597 $msg = $method .
' ' . (isset($parsedURL[
'path']) ? $parsedURL[
'path'] :
'/')
2598 . ($parsedURL[
'query'] ?
'?' . $parsedURL[
'query'] :
'') .
' HTTP/1.0' . CRLF
2599 .
'Host: ' . $parsedURL[
'host'] . CRLF
2600 .
'Connection: close' . CRLF;
2601 if (is_array($requestHeaders)) {
2602 $msg .= implode(CRLF, $requestHeaders) . CRLF;
2606 while (!feof($fp)) {
2607 $line = fgets($fp, 2048);
2608 if (isset($report)) {
2609 if (preg_match(
'|^HTTP/\\d\\.\\d +(\\d+)|', $line, $status)) {
2610 $report[
'http_code'] = $status[1];
2611 } elseif (preg_match(
'/^Content-Type: *(.*)/i', $line, $type)) {
2612 $report[
'content_type'] = $type[1];
2616 if (!strlen(trim($line))) {
2621 if ($includeHeader != 2) {
2622 $content .= stream_get_contents($fp);
2625 } elseif (is_array($requestHeaders)) {
2626 if (isset($report)) {
2627 $report[
'lib'] =
'file/context';
2629 $parsedURL = parse_url($url);
2630 if (!preg_match(
'/^https?/', $parsedURL[
'scheme'])) {
2631 if (isset($report)) {
2632 $report[
'error'] = -1;
2633 $report[
'message'] =
'Sending request headers is not allowed for this protocol.';
2637 $ctx = stream_context_create(array(
2639 'header' => implode(CRLF, $requestHeaders)
2642 $content = @file_get_contents($url, FALSE, $ctx);
2643 if ($content === FALSE && isset($report)) {
2644 $report[
'error'] = -1;
2645 $report[
'message'] =
'Couldn\'t get URL: ' . (isset($http_response_header) ? implode(LF, $http_response_header) : $url);
2648 if (isset($report)) {
2649 $report[
'lib'] =
'file';
2651 $content = @file_get_contents($url);
2652 if ($content === FALSE && isset($report)) {
2653 $report[
'error'] = -1;
2654 $report[
'message'] =
'Couldn\'t get URL: ' . (isset($http_response_header) ? implode(LF, $http_response_header) : $url);
2669 $headers = explode(
"\r\n", $content);
2670 foreach ($headers as $header) {
2671 if ($header ==
'') {
2674 if (preg_match(
'/^\s*Location\s*:/i', $header)) {
2675 list(,
$result) = self::trimExplode(
':', $header, FALSE, 2);
2692 $headersEndPos = strpos($content,
"\r\n\r\n");
2693 if ($headersEndPos) {
2694 $content = substr($content, $headersEndPos + 4);
2707 static public function writeFile($file, $content, $changePermissions = FALSE) {
2708 if (!@is_file($file)) {
2709 $changePermissions = TRUE;
2711 if ($fd = fopen($file,
'wb')) {
2712 $res = fwrite($fd, $content);
2714 if ($res === FALSE) {
2718 if ($changePermissions) {
2719 self::fixPermissions($file);
2734 if (TYPO3_OS !=
'WIN') {
2737 if (!self::isAbsPath($path)) {
2738 $path = self::getFileAbsFileName($path, FALSE);
2740 if (self::isAllowedAbsPath($path)) {
2741 if (@is_file($path)) {
2742 $targetFilePermissions = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileCreateMask'])
2743 ? octdec(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileCreateMask'])
2746 $result = @chmod($path, $targetFilePermissions);
2747 } elseif (@is_dir($path)) {
2748 $targetDirectoryPermissions = isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'folderCreateMask'])
2749 ? octdec(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'folderCreateMask'])
2752 $result = @chmod($path, $targetDirectoryPermissions);
2756 isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'createGroup'])
2757 && strlen(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'createGroup']) > 0
2760 $changeGroupResult = @chgrp($path,
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'createGroup']);
2764 if ($recursive && @is_dir($path)) {
2765 $handle = opendir($path);
2766 while (($file = readdir($handle)) !== FALSE) {
2767 $recursionResult = NULL;
2768 if ($file !==
'.' && $file !==
'..') {
2769 if (@is_file(($path .
'/' . $file))) {
2770 $recursionResult = self::fixPermissions($path .
'/' . $file);
2771 } elseif (@is_dir(($path .
'/' . $file))) {
2772 $recursionResult = self::fixPermissions($path .
'/' . $file, TRUE);
2774 if (isset($recursionResult) && !$recursionResult) {
2798 $fI = pathinfo($filepath);
2799 $fI[
'dirname'] .=
'/';
2801 if (self::validPathStr($filepath) && $fI[
'basename'] && strlen($fI[
'basename']) < 60) {
2802 if (defined(
'PATH_site')) {
2804 $dirName = PATH_site .
'typo3temp/';
2805 if (@is_dir($dirName)) {
2806 if (self::isFirstPartOfStr($fI[
'dirname'], $dirName)) {
2808 $subdir = substr($fI[
'dirname'], strlen($dirName));
2810 if (preg_match(
'/^[[:alnum:]_]+\\/$/', $subdir) || preg_match(
'/^[[:alnum:]_]+\\/[[:alnum:]_]+\\/$/', $subdir)) {
2811 $dirName .= $subdir;
2812 if (!@is_dir($dirName)) {
2813 self::mkdir_deep(PATH_site .
'typo3temp/', $subdir);
2816 return 'Subdir, "' . $subdir .
'", was NOT on the form "[[:alnum:]_]/" or "[[:alnum:]_]/[[:alnum:]_]/"';
2820 if (@is_dir($dirName)) {
2821 if ($filepath == $dirName . $fI[
'basename']) {
2822 self::writeFile($filepath, $content);
2823 if (!@is_file($filepath)) {
2824 return 'The file was not written to the disk. Please, check that you have write permissions to the typo3temp/ directory.';
2827 return 'Calculated filelocation didn\'t match input $filepath!';
2830 return '"' . $dirName .
'" is not a directory!';
2833 return '"' . $fI[
'dirname'] .
'" was not within directory PATH_site + "typo3temp/"';
2836 return 'PATH_site + "typo3temp/" was not a directory!';
2839 return 'PATH_site constant was NOT defined!';
2842 return 'Input filepath "' . $filepath .
'" was generally invalid!';
2854 static public function mkdir($newFolder) {
2857 self::fixPermissions($newFolder);
2872 static public function mkdir_deep($directory, $deepDirectory =
'') {
2873 if (!is_string($directory)) {
2874 throw new \InvalidArgumentException(
'The specified directory is of type "' . gettype($directory) .
'" but a string is expected.', 1303662955);
2876 if (!is_string($deepDirectory)) {
2877 throw new \InvalidArgumentException(
'The specified directory is of type "' . gettype($deepDirectory) .
'" but a string is expected.', 1303662956);
2880 $fullPath = rtrim($directory,
'/') .
'/' . ltrim($deepDirectory,
'/');
2881 if (!is_dir($fullPath) && strlen($fullPath) > 0) {
2882 $firstCreatedPath = self::createDirectoryPath($fullPath);
2883 if ($firstCreatedPath !==
'') {
2884 self::fixPermissions($firstCreatedPath, TRUE);
2901 $currentPath = $fullDirectoryPath;
2902 $firstCreatedPath =
'';
2903 $permissionMask = octdec(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'folderCreateMask']);
2904 if (!@is_dir($currentPath)) {
2906 $firstCreatedPath = $currentPath;
2907 $separatorPosition = strrpos($currentPath, DIRECTORY_SEPARATOR);
2908 $currentPath = substr($currentPath, 0, $separatorPosition);
2909 }
while (!is_dir($currentPath) && $separatorPosition !== FALSE);
2910 $result = @
mkdir($fullDirectoryPath, $permissionMask, TRUE);
2912 if (!
$result && !@is_dir($fullDirectoryPath)) {
2913 throw new \RuntimeException(
'Could not create directory "' . $fullDirectoryPath .
'"!', 1170251401);
2916 return $firstCreatedPath;
2926 static public function rmdir($path, $removeNonEmpty = FALSE) {
2929 $path = preg_replace(
'|/$|',
'', $path);
2930 if (file_exists($path)) {
2932 if (!is_link($path) && is_dir($path)) {
2933 if ($removeNonEmpty == TRUE && ($handle = @opendir($path))) {
2934 while ($OK && FALSE !== ($file = readdir($handle))) {
2935 if ($file ==
'.' || $file ==
'..') {
2938 $OK = self::rmdir($path .
'/' . $file, $removeNonEmpty);
2943 $OK = @
rmdir($path);
2945 } elseif (is_link($path) && is_dir($path) && TYPO3_OS ===
'WIN') {
2946 $OK = @
rmdir($path);
2949 $OK = @unlink($path);
2952 } elseif (is_link($path)) {
2953 $OK = @unlink($path);
2969 static public function flushDirectory($directory, $keepOriginalDirectory = FALSE, $flushOpcodeCache = FALSE) {
2972 if (is_dir($directory)) {
2973 $temporaryDirectory = rtrim($directory,
'/') .
'.' . uniqid(
'remove', TRUE) .
'/';
2974 if (rename($directory, $temporaryDirectory)) {
2975 if ($keepOriginalDirectory) {
2976 self::mkdir($directory);
2980 $result = self::rmdir($temporaryDirectory, TRUE);
2996 if (is_dir($path)) {
2997 $dir = scandir($path);
2999 foreach ($dir as $entry) {
3000 if (is_dir($path .
'/' . $entry) && $entry !=
'..' && $entry !=
'.') {
3023 static public function getFilesInDir($path, $extensionList =
'', $prependPath = FALSE, $order =
'', $excludePattern =
'') {
3024 $excludePattern = (string)$excludePattern;
3025 $path = rtrim($path,
'/');
3026 if (!@is_dir($path)) {
3030 $rawFileList = scandir($path);
3031 if ($rawFileList === FALSE) {
3032 return 'error opening path: "' . $path .
'"';
3035 $pathPrefix = $path .
'/';
3036 $extensionList =
',' . $extensionList .
',';
3038 foreach ($rawFileList as $entry) {
3039 $completePathToEntry = $pathPrefix . $entry;
3040 if (!@is_file($completePathToEntry)) {
3045 ($extensionList ===
',,' || stripos($extensionList,
',' . pathinfo($entry, PATHINFO_EXTENSION) .
',') !== FALSE)
3046 && ($excludePattern ===
'' || !preg_match((
'/^' . $excludePattern .
'$/'), $entry))
3048 if ($order !==
'mtime') {
3052 $files[$entry] = filemtime($completePathToEntry);
3057 $valueName =
'value';
3058 if ($order ===
'mtime') {
3063 $valuePathPrefix = $prependPath ? $pathPrefix :
'';
3064 $foundFiles = array();
3065 foreach ($files as $key => $value) {
3067 $foundFiles[md5($pathPrefix . ${$valueName})] = $valuePathPrefix . ${$valueName};
3084 static public function getAllFilesAndFoldersInPath(array $fileArr, $path, $extList =
'', $regDirs = FALSE, $recursivityLevels = 99, $excludePattern =
'') {
3088 $fileArr =
array_merge($fileArr, self::getFilesInDir($path, $extList, 1, 1, $excludePattern));
3089 $dirs = self::get_dirs($path);
3090 if ($recursivityLevels > 0 && is_array($dirs)) {
3091 foreach ($dirs as $subdirs) {
3092 if ((
string) $subdirs !=
'' && (!strlen($excludePattern) || !preg_match((
'/^' . $excludePattern .
'$/'), $subdirs))) {
3093 $fileArr = self::getAllFilesAndFoldersInPath($fileArr, $path . $subdirs .
'/', $extList, $regDirs, $recursivityLevels - 1, $excludePattern);
3108 foreach ($fileArr as $k => &$absFileRef) {
3109 if (self::isFirstPartOfStr($absFileRef, $prefixToRemove)) {
3110 $absFileRef = substr($absFileRef, strlen($prefixToRemove));
3112 return 'ERROR: One or more of the files was NOT prefixed with the prefix-path!';
3126 return str_replace(array(
'\\',
'//'),
'/', $theFile);
3137 if (strpos($pathStr,
'..') === FALSE) {
3140 $parts = explode(
'/', $pathStr);
3143 foreach ($parts as $part) {
3144 if ($part ===
'..') {
3156 return implode(
'/', $output);
3170 $uI = parse_url($path);
3172 if ($path[0] ===
'/') {
3173 $path = self::getIndpEnv(
'TYPO3_REQUEST_HOST') . $path;
3174 } elseif (!$uI[
'scheme']) {
3176 $path = self::getIndpEnv(
'TYPO3_REQUEST_DIR') . $path;
3178 if (strpbrk($path,
"\r\n") !==
false) {
3179 throw new \InvalidArgumentException(
'HTTP header injection attempt in "' . $path .
'"', 1448194036);
3195 $t3Limit = (int)($localLimit > 0 ? $localLimit :
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'maxFileSize']);
3197 $t3Limit = $t3Limit * 1024;
3199 $phpUploadLimit = self::getBytesFromSizeMeasurement(ini_get(
'upload_max_filesize'));
3201 $phpPostLimit = self::getBytesFromSizeMeasurement(ini_get(
'post_max_size'));
3204 $phpUploadLimit = $phpPostLimit > 0 && $phpPostLimit < $phpUploadLimit ? $phpPostLimit : $phpUploadLimit;
3206 return floor(($phpUploadLimit < $t3Limit ? $phpUploadLimit : $t3Limit)) / 1024;
3216 $bytes = doubleval($measurement);
3217 if (stripos($measurement,
'G')) {
3218 $bytes *= 1024 * 1024 * 1024;
3219 } elseif (stripos($measurement,
'M')) {
3220 $bytes *= 1024 * 1024;
3221 } elseif (stripos($measurement,
'K')) {
3233 return PHP_MAXPATHLEN;
3254 $lookupFile = explode(
'?', $file);
3255 $path = self::resolveBackPath(self::dirname(PATH_thisScript) .
'/' . $lookupFile[0]);
3260 if ($mode ===
'embed') {
3263 if ($mode ===
'querystring') {
3272 if (!file_exists($path) || $doNothing) {
3276 if (!$mode || $forceQueryString) {
3279 if ($lookupFile[1]) {
3284 $fullName = $file . $separator . filemtime($path);
3287 $name = explode(
'.', $lookupFile[0]);
3288 $extension = array_pop($name);
3289 array_push($name, filemtime($path), $extension);
3290 $fullName = implode(
'.', $name);
3292 $fullName .= $lookupFile[1] ?
'?' . $lookupFile[1] :
'';
3310 $p = parse_url(self::getIndpEnv(
'TYPO3_REQUEST_SCRIPT'));
3311 $dir = self::dirname($p[
'path']) .
'/';
3313 $url = str_replace(
'//',
'/', $p[
'host'] . ($p[
'port'] ?
':' . $p[
'port'] :
'') . $dir);
3326 $parts = self::getIndpEnv(
'SCRIPT_NAME');
3327 $params = self::_GET();
3328 foreach ($getParams as $key => $value) {
3329 if ($value !==
'') {
3330 $params[$key] = $value;
3332 unset($params[$key]);
3335 $pString = self::implodeArrayForUrl(
'', $params);
3336 return $pString ? $parts .
'?' . preg_replace(
'/^&/',
'', $pString) : $parts;
3347 static public function linkThisUrl($url, array $getParams = array()) {
3348 $parts = parse_url($url);
3350 if ($parts[
'query']) {
3351 parse_str($parts[
'query'], $getP);
3354 $uP = explode(
'?', $url);
3355 $params = self::implodeArrayForUrl(
'', $getP);
3356 $outurl = $uP[0] . ($params ?
'?' . substr($params, 1) :
'');
3413 switch ((
string) $getEnvName) {
3415 $retVal = self::isRunningOnCgiServerApi()
3416 && ($_SERVER[
'ORIG_PATH_INFO'] ?: $_SERVER[
'PATH_INFO'])
3417 ? ($_SERVER[
'ORIG_PATH_INFO'] ?: $_SERVER[
'PATH_INFO'])
3418 : ($_SERVER[
'ORIG_SCRIPT_NAME'] ?: $_SERVER[
'SCRIPT_NAME']);
3420 if (self::cmpIP($_SERVER[
'REMOTE_ADDR'],
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyIP'])) {
3421 if (self::getIndpEnv(
'TYPO3_SSL') &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyPrefixSSL']) {
3422 $retVal =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyPrefixSSL'] . $retVal;
3423 } elseif (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyPrefix']) {
3424 $retVal =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyPrefix'] . $retVal;
3428 case 'SCRIPT_FILENAME':
3429 $retVal = PATH_thisScript;
3433 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'requestURIvar']) {
3435 list($v, $n) = explode(
'|',
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'requestURIvar']);
3437 } elseif (!$_SERVER[
'REQUEST_URI']) {
3439 $retVal =
'/' . ltrim(self::getIndpEnv(
'SCRIPT_NAME'),
'/') . ($_SERVER[
'QUERY_STRING'] ?
'?' . $_SERVER[
'QUERY_STRING'] :
'');
3441 $retVal =
'/' . ltrim($_SERVER[
'REQUEST_URI'],
'/');
3444 if (self::cmpIP($_SERVER[
'REMOTE_ADDR'],
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyIP'])) {
3445 if (self::getIndpEnv(
'TYPO3_SSL') &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyPrefixSSL']) {
3446 $retVal =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyPrefixSSL'] . $retVal;
3447 } elseif (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyPrefix']) {
3448 $retVal =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyPrefix'] . $retVal;
3461 if (!self::isRunningOnCgiServerApi()) {
3462 $retVal = $_SERVER[
'PATH_INFO'];
3465 case 'TYPO3_REV_PROXY':
3466 $retVal = self::cmpIP($_SERVER[
'REMOTE_ADDR'],
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyIP']);
3469 $retVal = $_SERVER[
'REMOTE_ADDR'];
3470 if (self::cmpIP($_SERVER[
'REMOTE_ADDR'],
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyIP'])) {
3471 $ip = self::trimExplode(
',', $_SERVER[
'HTTP_X_FORWARDED_FOR']);
3474 switch (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyHeaderMultiValue']) {
3476 $ip = array_pop($ip);
3479 $ip = array_shift($ip);
3487 if (self::validIP($ip)) {
3493 $retVal = $_SERVER[
'HTTP_HOST'];
3494 if (self::cmpIP($_SERVER[
'REMOTE_ADDR'],
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyIP'])) {
3495 $host = self::trimExplode(
',', $_SERVER[
'HTTP_X_FORWARDED_HOST']);
3498 switch (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyHeaderMultiValue']) {
3515 if (!static::isAllowedHostHeaderValue($retVal)) {
3516 throw new \UnexpectedValueException(
3517 'The current host header value does not match the configured trusted hosts pattern! Check the pattern defined in $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'trustedHostsPattern\'] and adapt it, if you want to allow the current host header \'' . $retVal .
'\' for your installation.
', 3522 case 'HTTP_REFERER
': 3524 case 'HTTP_USER_AGENT
': 3526 case 'HTTP_ACCEPT_ENCODING
': 3528 case 'HTTP_ACCEPT_LANGUAGE
': 3532 case 'QUERY_STRING
': 3534 if (isset($_SERVER[$getEnvName])) { 3535 $retVal = $_SERVER[$getEnvName]; 3538 case 'TYPO3_DOCUMENT_ROOT
': 3539 // Get the web root (it is not the root of the TYPO3 installation) 3540 // The absolute path of the script can be calculated with TYPO3_DOCUMENT_ROOT + SCRIPT_FILENAME 3541 // 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. 3542 // Therefore the DOCUMENT_ROOT is now always calculated as the SCRIPT_FILENAME minus the end part shared with SCRIPT_NAME. 3543 $SFN = self::getIndpEnv('SCRIPT_FILENAME
'); 3544 $SN_A = explode('/
', strrev(self::getIndpEnv('SCRIPT_NAME
'))); 3545 $SFN_A = explode('/
', strrev($SFN)); 3547 foreach ($SN_A as $kk => $vv) { 3548 if ((string)$SFN_A[$kk] === (string)$vv) { 3554 $commonEnd = strrev(implode('/
', $acc)); 3555 if ((string)$commonEnd !== '') { 3556 $DR = substr($SFN, 0, -(strlen($commonEnd) + 1)); 3560 case 'TYPO3_HOST_ONLY
': 3561 $httpHost = self::getIndpEnv('HTTP_HOST
'); 3562 $httpHostBracketPosition = strpos($httpHost, ']
'); 3563 $httpHostParts = explode(':
', $httpHost); 3564 $retVal = $httpHostBracketPosition !== FALSE ? substr($httpHost, 0, $httpHostBracketPosition + 1) : array_shift($httpHostParts); 3567 $httpHost = self::getIndpEnv('HTTP_HOST
'); 3568 $httpHostOnly = self::getIndpEnv('TYPO3_HOST_ONLY
'); 3569 $retVal = strlen($httpHost) > strlen($httpHostOnly) ? substr($httpHost, strlen($httpHostOnly) + 1) : ''; 3571 case 'TYPO3_REQUEST_HOST
': 3572 $retVal = (self::getIndpEnv('TYPO3_SSL
') ? 'https:
3574 case 'TYPO3_REQUEST_URL':
3575 $retVal = self::getIndpEnv(
'TYPO3_REQUEST_HOST') . self::getIndpEnv(
'REQUEST_URI');
3577 case 'TYPO3_REQUEST_SCRIPT':
3578 $retVal = self::getIndpEnv(
'TYPO3_REQUEST_HOST') . self::getIndpEnv(
'SCRIPT_NAME');
3580 case 'TYPO3_REQUEST_DIR':
3581 $retVal = self::getIndpEnv(
'TYPO3_REQUEST_HOST') . self::dirname(self::getIndpEnv(
'SCRIPT_NAME')) .
'/';
3583 case 'TYPO3_SITE_URL':
3584 $url = self::getIndpEnv(
'TYPO3_REQUEST_DIR');
3586 if (defined(
'TYPO3_PATH_WEB')) {
3588 } elseif (defined(
'PATH_thisScript') && defined(
'PATH_site')) {
3590 $siteUrl = substr($url, 0, -strlen($lPath));
3591 if (substr($siteUrl, -1) !=
'/') {
3597 case 'TYPO3_SITE_PATH':
3598 $retVal = substr(self::getIndpEnv(
'TYPO3_SITE_URL'), strlen(self::getIndpEnv(
'TYPO3_REQUEST_HOST')));
3600 case 'TYPO3_SITE_SCRIPT':
3601 $retVal = substr(self::getIndpEnv(
'TYPO3_REQUEST_URL'), strlen(self::getIndpEnv(
'TYPO3_SITE_URL')));
3604 $proxySSL = trim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxySSL']);
3605 if ($proxySSL ==
'*') {
3606 $proxySSL =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'reverseProxyIP'];
3608 if (self::cmpIP($_SERVER[
'REMOTE_ADDR'], $proxySSL)) {
3611 $retVal = $_SERVER[
'SSL_SESSION_ID'] ||
strtolower($_SERVER[
'HTTPS']) ===
'on' || (string)$_SERVER[
'HTTPS'] ===
'1' ? TRUE : FALSE;
3617 $envTestVars = array(
3625 'TYPO3_REQUEST_HOST',
3626 'TYPO3_REQUEST_URL',
3627 'TYPO3_REQUEST_SCRIPT',
3628 'TYPO3_REQUEST_DIR',
3630 'TYPO3_SITE_SCRIPT',
3634 'TYPO3_DOCUMENT_ROOT',
3639 'HTTP_ACCEPT_LANGUAGE' 3641 foreach ($envTestVars as $v) {
3642 $out[$v] = self::getIndpEnv($v);
3659 if (static::$allowHostHeaderValue === TRUE) {
3663 if (static::isInternalRequestType()) {
3664 return static::$allowHostHeaderValue = TRUE;
3668 if (empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'trustedHostsPattern'])) {
3672 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'trustedHostsPattern'] === self::ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL) {
3673 static::$allowHostHeaderValue = TRUE;
3674 } elseif (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'trustedHostsPattern'] === self::ENV_TRUSTED_HOSTS_PATTERN_SERVER_NAME) {
3677 $defaultPort = self::getIndpEnv(
'TYPO3_SSL') ?
'443' :
'80';
3678 $parsedHostValue = parse_url(
'http://' . $hostHeaderValue);
3679 if (isset($parsedHostValue[
'port'])) {
3680 static::$allowHostHeaderValue = (
strtolower($parsedHostValue[
'host']) ===
strtolower($_SERVER[
'SERVER_NAME']) && (string)$parsedHostValue[
'port'] === $_SERVER[
'SERVER_PORT']);
3682 static::$allowHostHeaderValue = (
strtolower($hostHeaderValue) ===
strtolower($_SERVER[
'SERVER_NAME']) && $defaultPort === $_SERVER[
'SERVER_PORT']);
3687 static::$allowHostHeaderValue = (bool)preg_match(
'/^' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'trustedHostsPattern'] .
'$/i', $hostHeaderValue);
3690 return static::$allowHostHeaderValue;
3702 return (defined(
'TYPO3_REQUESTTYPE') && TYPO3_REQUESTTYPE & (TYPO3_REQUESTTYPE_INSTALL | TYPO3_REQUESTTYPE_CLI));
3711 return round(microtime(TRUE) * 1000);
3722 $useragent = self::getIndpEnv(
'HTTP_USER_AGENT');
3726 if (strpos($useragent,
'Konqueror') !== FALSE) {
3727 $bInfo[
'BROWSER'] =
'konqu';
3728 } elseif (strpos($useragent,
'Opera') !== FALSE) {
3729 $bInfo[
'BROWSER'] =
'opera';
3730 } elseif (strpos($useragent,
'MSIE') !== FALSE) {
3731 $bInfo[
'BROWSER'] =
'msie';
3732 } elseif (strpos($useragent,
'Mozilla') !== FALSE) {
3733 $bInfo[
'BROWSER'] =
'net';
3734 } elseif (strpos($useragent,
'Flash') !== FALSE) {
3735 $bInfo[
'BROWSER'] =
'flash';
3737 if (isset($bInfo[
'BROWSER'])) {
3739 switch ($bInfo[
'BROWSER']) {
3741 $bInfo[
'VERSION'] = doubleval(substr($useragent, 8));
3742 if (strpos($useragent,
'Netscape6/') !== FALSE) {
3743 $bInfo[
'VERSION'] = doubleval(substr(strstr($useragent,
'Netscape6/'), 10));
3746 if (strpos($useragent,
'Netscape/6') !== FALSE) {
3747 $bInfo[
'VERSION'] = doubleval(substr(strstr($useragent,
'Netscape/6'), 10));
3749 if (strpos($useragent,
'Netscape/7') !== FALSE) {
3750 $bInfo[
'VERSION'] = doubleval(substr(strstr($useragent,
'Netscape/7'), 9));
3754 $tmp = strstr($useragent,
'MSIE');
3755 $bInfo[
'VERSION'] = doubleval(preg_replace(
'/^[^0-9]*/',
'', substr($tmp, 4)));
3758 $tmp = strstr($useragent,
'Opera');
3759 $bInfo[
'VERSION'] = doubleval(preg_replace(
'/^[^0-9]*/',
'', substr($tmp, 5)));
3762 $tmp = strstr($useragent,
'Konqueror/');
3763 $bInfo[
'VERSION'] = doubleval(substr($tmp, 10));
3767 if (strpos($useragent,
'Win') !== FALSE) {
3768 $bInfo[
'SYSTEM'] =
'win';
3769 } elseif (strpos($useragent,
'Mac') !== FALSE) {
3770 $bInfo[
'SYSTEM'] =
'mac';
3771 } elseif (strpos($useragent,
'Linux') !== FALSE || strpos($useragent,
'X11') !== FALSE || strpos($useragent,
'SGI') !== FALSE || strpos($useragent,
' SunOS ') !== FALSE || strpos($useragent,
' HP-UX ') !== FALSE) {
3772 $bInfo[
'SYSTEM'] =
'unix';
3788 if ($requestHost && (!defined(
'TYPO3_cliMode') || !TYPO3_cliMode)) {
3789 $host = self::getIndpEnv(
'HTTP_HOST');
3793 $host = @php_uname(
'n');
3795 if (strpos(
$host,
' ')) {
3801 $ip = gethostbyname(
$host);
3804 $fqdn = gethostbyaddr($ip);
3811 $host =
'localhost.localdomain';
3832 static public function getFileAbsFileName($filename, $onlyRelative = TRUE, $relToTYPO3_mainDir = FALSE) {
3833 if ((
string)$filename ===
'') {
3836 $relPathPrefix = PATH_site;
3837 if ($relToTYPO3_mainDir) {
3838 $relPathPrefix = PATH_typo3;
3842 if (strpos($filename,
'EXT:') === 0) {
3843 list($extKey, $local) = explode(
'/', substr($filename, 4), 2);
3848 } elseif (!self::isAbsPath($filename)) {
3850 $filename = $relPathPrefix . $filename;
3851 } elseif ($onlyRelative && !self::isFirstPartOfStr($filename, $relPathPrefix)) {
3855 if ((
string)$filename !==
'' && self::validPathStr($filename)) {
3875 return strpos($theFile,
'//') === FALSE && strpos($theFile,
'\\') === FALSE
3876 && preg_match(
'#(?:^\\.\\.|/\\.\\./|[[:cntrl:]])#u', $theFile) === 0;
3886 return $path[0] ===
'/' || TYPO3_OS ===
'WIN' && (strpos($path,
':/') === 1 || strpos($path,
':\\') === 1);
3896 $lockRootPath =
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'lockRootPath'];
3897 return self::isAbsPath($path) && self::validPathStr($path)
3898 && (self::isFirstPartOfStr($path, PATH_site)
3899 || $lockRootPath && self::isFirstPartOfStr($path, $lockRootPath));
3912 $pattern =
'/[[:cntrl:]]/';
3913 if ((
string)$filename !==
'' && (
string)
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileDenyPattern'] !==
'') {
3914 $pattern =
'/(?:[[:cntrl:]]|' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileDenyPattern'] .
')/i';
3916 return !preg_match($pattern, $filename);
3926 if (strpos($source, PATH_site) === FALSE) {
3927 $source = PATH_site . $source;
3929 if (strpos($destination, PATH_site) === FALSE) {
3930 $destination = PATH_site . $destination;
3932 if (static::isAllowedAbsPath($source) && static::isAllowedAbsPath($destination)) {
3933 $iterator = new \RecursiveIteratorIterator(
3934 new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
3935 \RecursiveIteratorIterator::SELF_FIRST
3937 foreach ($iterator as $item) {
3938 $target = $destination .
'/' . $iterator->getSubPathName();
3939 if ($item->isDir()) {
3940 static::mkdir($target);
3942 static::upload_copy_move($item, $target);
3957 $decodedUrl = rawurldecode($url);
3958 if (!empty($url) && self::removeXSS($decodedUrl) === $decodedUrl) {
3959 $parsedUrl = parse_url($decodedUrl);
3960 $testAbsoluteUrl = self::resolveBackPath($decodedUrl);
3961 $testRelativeUrl = self::resolveBackPath(self::dirname(self::getIndpEnv(
'SCRIPT_NAME')) .
'/' . $decodedUrl);
3963 if (self::isValidUrl($decodedUrl)) {
3964 if (self::isOnCurrentHost($decodedUrl) && strpos($decodedUrl, self::getIndpEnv(
'TYPO3_SITE_URL')) === 0) {
3965 $sanitizedUrl = $url;
3967 } elseif (self::isAbsPath($decodedUrl) && self::isAllowedAbsPath($decodedUrl)) {
3968 $sanitizedUrl = $url;
3969 } elseif (strpos($testAbsoluteUrl, self::getIndpEnv(
'TYPO3_SITE_PATH')) === 0 && $decodedUrl[0] ===
'/') {
3970 $sanitizedUrl = $url;
3971 } elseif (empty($parsedUrl[
'scheme']) && strpos($testRelativeUrl, self::getIndpEnv(
'TYPO3_SITE_PATH')) === 0 && $decodedUrl[0] !==
'/') {
3972 $sanitizedUrl = $url;
3975 if (!empty($url) && empty($sanitizedUrl)) {
3976 self::sysLog(
'The URL "' . $url .
'" is not considered to be local and was denied.',
'Core', self::SYSLOG_SEVERITY_NOTICE);
3978 return $sanitizedUrl;
3991 if (is_uploaded_file($source)) {
3994 $uploadedResult = move_uploaded_file($source, $destination);
3997 @copy($source, $destination);
4000 self::fixPermissions($destination);
4002 return $uploaded ? $uploadedResult : FALSE;
4015 if (is_uploaded_file($uploadedFileName)) {
4016 $tempFile = self::tempnam(
'upload_temp_');
4017 move_uploaded_file($uploadedFileName, $tempFile);
4018 return @is_file($tempFile) ? $tempFile :
'';
4032 if ($uploadedTempFileName) {
4033 $uploadedTempFileName = self::fixWindowsFilePath($uploadedTempFileName);
4035 self::validPathStr($uploadedTempFileName)
4036 && self::isFirstPartOfStr($uploadedTempFileName, PATH_site .
'typo3temp/')
4037 && @is_file($uploadedTempFileName)
4039 if (unlink($uploadedTempFileName)) {
4056 static public function tempnam($filePrefix, $fileSuffix =
'') {
4057 $temporaryPath = PATH_site .
'typo3temp/';
4058 if ($fileSuffix ===
'') {
4059 $tempFileName = $temporaryPath . basename(
tempnam($temporaryPath, $filePrefix));
4062 $tempFileName = $temporaryPath . $filePrefix . mt_rand(1, PHP_INT_MAX) . $fileSuffix;
4063 }
while (file_exists($tempFileName));
4064 touch($tempFileName);
4065 clearstatcache(NULL, $tempFileName);
4067 return $tempFileName;
4078 static public function stdAuthCode($uid_or_record, $fields =
'', $codeLength = 8) {
4079 if (is_array($uid_or_record)) {
4080 $recCopy_temp = array();
4082 $fieldArr = self::trimExplode(
',', $fields, TRUE);
4083 foreach ($fieldArr as $k => $v) {
4084 $recCopy_temp[$k] = $uid_or_record[$v];
4087 $recCopy_temp = $uid_or_record;
4089 $preKey = implode(
'|', $recCopy_temp);
4091 $preKey = $uid_or_record;
4093 $authCode = $preKey .
'||' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'encryptionKey'];
4094 $authCode = substr(md5($authCode), 0, $codeLength);
4105 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'hidePagesIfNotTranslatedByDefault']) {
4106 return $l18n_cfg_fieldValue & 2 ? FALSE : TRUE;
4108 return $l18n_cfg_fieldValue & 2 ? TRUE : FALSE;
4120 return $localizationConfiguration & 1;
4132 static public function readLLfile($fileRef, $langKey, $charset =
'', $errorMode = 0) {
4134 $languageFactory = self::makeInstance(
'TYPO3\\CMS\\Core\\Localization\\LocalizationFactory');
4135 return $languageFactory->getParsedData($fileRef, $langKey, $charset, $errorMode);
4148 $fileName = basename($fileRef);
4149 if (self::isFirstPartOfStr($fileName, $language .
'.')) {
4153 if ($sameLocation) {
4154 return str_replace($fileName, $language .
'.' . $fileName, $fileRef);
4159 if (self::isFirstPartOfStr($fileRef, PATH_typo3 .
'sysext/')) {
4160 $validatedPrefix = PATH_typo3 .
'sysext/';
4161 } elseif (self::isFirstPartOfStr($fileRef, PATH_typo3 .
'ext/')) {
4163 $validatedPrefix = PATH_typo3 .
'ext/';
4164 } elseif (self::isFirstPartOfStr($fileRef, PATH_typo3conf .
'ext/')) {
4166 $validatedPrefix = PATH_typo3conf .
'ext/';
4168 $validatedPrefix =
'';
4170 if ($validatedPrefix) {
4172 list($file_extKey, $file_extPath) = explode(
'/', substr($fileRef, strlen($validatedPrefix)), 2);
4173 $temp = self::revExplode(
'/', $file_extPath, 2);
4174 if (count($temp) === 1) {
4175 array_unshift($temp,
'');
4178 list($file_extPath, $file_fileName) = $temp;
4180 $location =
'typo3conf/l10n/' . $language .
'/' . $file_extKey .
'/' . ($file_extPath ? $file_extPath .
'/' :
'');
4181 return $location . $language .
'.' . $file_fileName;
4200 static::logDeprecatedFunction();
4212 if (!is_array($dataStructArray)) {
4213 return 'Data structure must be an array';
4215 if (is_array($dataStructArray[
'sheets'])) {
4216 $singleSheet = FALSE;
4217 if (!isset($dataStructArray[
'sheets'][$sheet])) {
4220 $dataStruct = $dataStructArray[
'sheets'][$sheet];
4222 if ($dataStruct && !is_array($dataStruct)) {
4223 $file = self::getFileAbsFileName($dataStruct);
4224 if ($file && @is_file($file)) {
4225 $dataStruct = self::xml2array(self::getUrl($file));
4229 $singleSheet = TRUE;
4230 $dataStruct = $dataStructArray;
4231 if (isset($dataStruct[
'meta'])) {
4232 unset($dataStruct[
'meta']);
4238 return array($dataStruct, $sheet, $singleSheet);
4249 if (is_array($dataStructArray[
'sheets'])) {
4250 $out = array(
'sheets' => array());
4251 foreach ($dataStructArray[
'sheets'] as $sheetId => $sDat) {
4252 list($ds, $aS) = self::resolveSheetDefInDS($dataStructArray, $sheetId);
4253 if ($sheetId == $aS) {
4254 $out[
'sheets'][$aS] = $ds;
4258 list($ds) = self::resolveSheetDefInDS($dataStructArray);
4259 $out = array(
'sheets' => array(
'sDEF' => $ds));
4276 static public function callUserFunction($funcName, &$params, &$ref, $checkPrefix =
'', $errorMode = 0) {
4279 if (is_object($funcName) && is_a($funcName,
'Closure')) {
4280 return call_user_func_array($funcName, array(&$params, &$ref));
4283 if (is_array(
$GLOBALS[
'T3_VAR'][
'callUserFunction'][$funcName])) {
4284 return call_user_func_array(array(
4285 &
$GLOBALS[
'T3_VAR'][
'callUserFunction'][$funcName][
'obj'],
4286 $GLOBALS[
'T3_VAR'][
'callUserFunction'][$funcName][
'method']
4287 ), array(&$params, &$ref));
4290 if (strpos($funcName,
':') !== FALSE) {
4291 list($file, $funcRef) = self::revExplode(
':', $funcName, 2);
4292 $requireFile = self::getFileAbsFileName($file);
4294 self::requireOnce($requireFile);
4297 $funcRef = $funcName;
4300 if ($funcRef[0] ===
'&') {
4301 $funcRef = substr($funcRef, 1);
4302 $storePersistentObject = TRUE;
4304 $storePersistentObject = FALSE;
4307 $parts = explode(
'->', $funcRef);
4308 if (count($parts) == 2) {
4311 if (class_exists($parts[0])) {
4313 if ($storePersistentObject) {
4315 if (!is_object(
$GLOBALS[
'T3_VAR'][
'callUserFunction_classPool'][$parts[0]])) {
4316 $GLOBALS[
'T3_VAR'][
'callUserFunction_classPool'][$parts[0]] = self::makeInstance($parts[0]);
4318 $classObj =
$GLOBALS[
'T3_VAR'][
'callUserFunction_classPool'][$parts[0]];
4321 $classObj = self::makeInstance($parts[0]);
4323 if (method_exists($classObj, $parts[1])) {
4325 if ($storePersistentObject) {
4326 $GLOBALS[
'T3_VAR'][
'callUserFunction'][$funcName] = array(
4327 'method' => $parts[1],
4332 $content = call_user_func_array(array(&$classObj, $parts[1]), array(&$params, &$ref));
4334 $errorMsg =
'No method name \'' . $parts[1] .
'\' in
class ' . $parts[0];
4335 if ($errorMode == 2) {
4336 throw new \InvalidArgumentException($errorMsg, 1294585865);
4337 } elseif (!$errorMode) {
4338 debug($errorMsg,
'TYPO3\\CMS\\Core\\Utility\\GeneralUtility::callUserFunction');
4342 $errorMsg =
'No class named ' . $parts[0];
4343 if ($errorMode == 2) {
4344 throw new \InvalidArgumentException($errorMsg, 1294585866);
4345 } elseif (!$errorMode) {
4346 debug($errorMsg,
'TYPO3\\CMS\\Core\\Utility\\GeneralUtility::callUserFunction');
4351 if (function_exists($funcRef)) {
4352 $content = call_user_func_array($funcRef, array(&$params, &$ref));
4354 $errorMsg =
'No function named: ' . $funcRef;
4355 if ($errorMode == 2) {
4356 throw new \InvalidArgumentException($errorMsg, 1294585867);
4357 } elseif (!$errorMode) {
4358 debug($errorMsg,
'TYPO3\\CMS\\Core\\Utility\\GeneralUtility::callUserFunction');
4378 static public function getUserObj($classRef, $checkPrefix =
'', $silent = FALSE) {
4380 if (is_object(
$GLOBALS[
'T3_VAR'][
'getUserObj'][$classRef])) {
4381 return $GLOBALS[
'T3_VAR'][
'getUserObj'][$classRef];
4384 if (strpos($classRef,
':') !== FALSE) {
4385 list($file, $class) = self::revExplode(
':', $classRef, 2);
4386 $requireFile = self::getFileAbsFileName($file);
4388 self::requireOnce($requireFile);
4394 if ($class[0] ===
'&') {
4395 $class = substr($class, 1);
4396 $storePersistentObject = TRUE;
4398 $storePersistentObject = FALSE;
4401 if (class_exists($class)) {
4402 $classObj = self::makeInstance($class);
4404 if ($storePersistentObject) {
4405 $GLOBALS[
'T3_VAR'][
'getUserObj'][$classRef] = $classObj;
4425 if (!is_string($className) || empty($className)) {
4426 throw new \InvalidArgumentException(
'$className must be a non empty string.', 1288965219);
4429 if ($className[0] ===
'\\') {
4430 $className = substr($className, 1);
4432 if (isset(static::$finalClassNameCache[$className])) {
4433 $finalClassName = static::$finalClassNameCache[$className];
4435 $finalClassName = self::getClassName($className);
4436 static::$finalClassNameCache[$className] = $finalClassName;
4439 if (isset(self::$singletonInstances[$finalClassName])) {
4440 return self::$singletonInstances[$finalClassName];
4444 isset(self::$nonSingletonInstances[$finalClassName])
4445 && !empty(self::$nonSingletonInstances[$finalClassName])
4447 return array_shift(self::$nonSingletonInstances[$finalClassName]);
4450 $instance = static::instantiateClass($finalClassName, func_get_args());
4453 self::$singletonInstances[$finalClassName] = $instance;
4466 switch (count($arguments)) {
4468 $instance =
new $className();
4471 $instance =
new $className($arguments[1]);
4474 $instance =
new $className($arguments[1], $arguments[2]);
4477 $instance =
new $className($arguments[1], $arguments[2], $arguments[3]);
4480 $instance =
new $className($arguments[1], $arguments[2], $arguments[3], $arguments[4]);
4483 $instance =
new $className($arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5]);
4486 $instance =
new $className($arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5], $arguments[6]);
4489 $instance =
new $className($arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5], $arguments[6], $arguments[7]);
4492 $instance =
new $className($arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5], $arguments[6], $arguments[7], $arguments[8]);
4498 $class = new \ReflectionClass($className);
4499 array_shift($arguments);
4500 $instance = $class->newInstanceArgs($arguments);
4514 if (class_exists($className)) {
4515 while (static::classHasImplementation($className)) {
4516 $className = static::getImplementationForClass($className);
4519 return \TYPO3\CMS\Core\Core\ClassLoader::getClassNameForAlias($className);
4529 return $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'Objects'][$className][
'className'];
4540 if (!isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'Objects'])) {
4544 return isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'Objects'][$className])
4545 && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'Objects'][$className])
4546 && !empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'Objects'][$className][
'className']);
4568 self::checkInstanceClassName($className, $instance);
4569 self::$singletonInstances[$className] = $instance;
4589 self::checkInstanceClassName($className, $instance);
4590 if (!isset(self::$singletonInstances[$className])) {
4591 throw new \InvalidArgumentException(
'No Instance registered for ' . $className .
'.', 1394099179);
4593 if ($instance !== self::$singletonInstances[$className]) {
4594 throw new \InvalidArgumentException(
'The instance you are trying to remove has not been registered before.', 1394099256);
4596 unset(self::$singletonInstances[$className]);
4614 static::$singletonInstances = array();
4615 foreach ($newSingletonInstances as $className => $instance) {
4616 static::setSingletonInstance($className, $instance);
4633 return static::$singletonInstances;
4652 self::checkInstanceClassName($className, $instance);
4654 throw new \InvalidArgumentException(
'$instance must not be an instance of TYPO3\\CMS\\Core\\SingletonInterface. ' .
'For setting singletons, please use setSingletonInstance.', 1288969325);
4656 if (!isset(self::$nonSingletonInstances[$className])) {
4657 self::$nonSingletonInstances[$className] = array();
4659 self::$nonSingletonInstances[$className][] = $instance;
4672 if ($className ===
'') {
4673 throw new \InvalidArgumentException(
'$className must not be empty.', 1288967479);
4675 if (!$instance instanceof $className) {
4676 throw new \InvalidArgumentException(
'$instance must be an instance of ' . $className .
', but actually is an instance of ' . get_class($instance) .
'.', 1288967686);
4692 self::$singletonInstances = array();
4693 self::$nonSingletonInstances = array();
4705 static public function makeInstanceService($serviceType, $serviceSubType =
'', $excludeServiceKeys = array()) {
4707 if (!is_array($excludeServiceKeys)) {
4708 $excludeServiceKeys = self::trimExplode(
',', $excludeServiceKeys, TRUE);
4710 $requestInfo = array(
4711 'requestedServiceType' => $serviceType,
4712 'requestedServiceSubType' => $serviceSubType,
4713 'requestedExcludeServiceKeys' => $excludeServiceKeys
4719 if (is_object(
$GLOBALS[
'T3_VAR'][
'makeInstanceService'][$info[
'className']])) {
4721 $GLOBALS[
'T3_VAR'][
'makeInstanceService'][$info[
'className']]->info = $info;
4723 $GLOBALS[
'T3_VAR'][
'makeInstanceService'][$info[
'className']]->reset();
4724 return $GLOBALS[
'T3_VAR'][
'makeInstanceService'][$info[
'className']];
4726 if (isset($info[
'classFile'])) {
4729 self::deprecationLog(
4730 'The option "classFile" of "' . $info[
'className'] .
4731 '" in T3_SERVICES has been deprecated, as this should now be done by the respective ' .
4732 'ext_autoload.php of each extension. This option will be removed in TYPO3 CMS v6.3.' 4734 $requireFile = self::getFileAbsFileName($info[
'classFile']);
4735 if (@is_file($requireFile)) {
4736 self::requireOnce($requireFile);
4740 $obj = self::makeInstance($info[
'className']);
4741 if (is_object($obj)) {
4742 if (!@is_callable(array($obj,
'init'))) {
4750 $GLOBALS[
'T3_VAR'][
'makeInstanceService'][$info[
'className']] = $obj;
4753 $error = $obj->getLastErrorArray();
4773 require_once $requireFile;
4787 require $requireFile;
4805 static public function plainMailEncoded($email, $subject, $message, $headers =
'', $encoding =
'quoted-printable', $charset =
'', $dontEncodeHeader = FALSE) {
4806 self::logDeprecatedFunction();
4810 $email = self::normalizeMailAddress($email);
4811 if (!$dontEncodeHeader) {
4813 $newHeaders = array();
4815 foreach (explode(LF, $headers) as $line) {
4817 $parts = explode(
': ', $line, 2);
4818 if (count($parts) == 2) {
4819 if (0 == strcasecmp($parts[0],
'from')) {
4820 $parts[1] = self::normalizeMailAddress($parts[1]);
4822 $parts[1] = self::encodeHeader($parts[1], $encoding, $charset);
4823 $newHeaders[] = implode(
': ', $parts);
4826 $newHeaders[] = $line;
4829 $headers = implode(LF, $newHeaders);
4832 $email = self::encodeHeader($email, $encoding, $charset);
4833 $subject = self::encodeHeader($subject, $encoding, $charset);
4835 switch ((
string) $encoding) {
4837 $headers = trim($headers) . LF .
'Mime-Version: 1.0' . LF .
'Content-Type: text/plain; charset="' . $charset .
'"' . LF .
'Content-Transfer-Encoding: base64';
4839 $message = trim(chunk_split(base64_encode(($message . LF)))) . LF;
4842 $headers = trim($headers) . LF .
'Mime-Version: 1.0' . LF .
'Content-Type: text/plain; charset=' . $charset . LF .
'Content-Transfer-Encoding: 8bit';
4844 case 'quoted-printable':
4847 $headers = trim($headers) . LF .
'Mime-Version: 1.0' . LF .
'Content-Type: text/plain; charset=' . $charset . LF .
'Content-Transfer-Encoding: quoted-printable';
4848 $message = self::quoted_printable($message);
4854 $headers = trim(implode(LF, self::trimExplode(LF, $headers, TRUE)));
4855 return \TYPO3\CMS\Core\Utility\MailUtility::mail($email, $subject, $message, $headers);
4869 $string = str_replace(CRLF, LF, $string);
4871 $string = str_replace(CR, LF, $string);
4874 if (TYPO3_OS ==
'WIN') {
4880 $theLines = explode(LF, $string);
4881 foreach ($theLines as $val) {
4883 $theValLen = strlen($val);
4886 for ($index = 0; $index < $theValLen; $index++) {
4887 $char = substr($val, $index, 1);
4888 $ordVal = ord($char);
4889 if ($len > $maxlen - 4 || $len > $maxlen - 14 && $ordVal == 32) {
4891 $newVal .=
'=' . $linebreak;
4895 if ($ordVal >= 33 && $ordVal <= 60 || $ordVal >= 62 && $ordVal <= 126 || $ordVal == 9 || $ordVal == 32) {
4901 $newVal .= sprintf(
'=%02X', $ordVal);
4906 $newVal = preg_replace(
'/' . chr(32) .
'$/',
'=20', $newVal);
4908 $newVal = preg_replace(
'/' . TAB .
'$/',
'=09', $newVal);
4909 $newString .= $newVal . $linebreak;
4912 return preg_replace(
'/' . $linebreak .
'$/',
'', $newString);
4924 static public function encodeHeader($line, $enc =
'quoted-printable', $charset =
'utf-8') {
4926 if (strpos($line,
'###') !== FALSE) {
4930 if (!preg_match((
'/[^' . chr(32) .
'-' . chr(127) .
']/'), $line)) {
4934 $line = preg_replace(
'/([^ ]+@[^ ]+)/',
'###$1###', $line);
4935 $matches = preg_split(
'/(.?###.+###.?|\\(|\\))/', $line, -1, PREG_SPLIT_NO_EMPTY);
4936 foreach ($matches as $part) {
4938 $partWasQuoted = $part[0] ==
'"';
4939 $part = trim($part,
'"');
4940 switch ((
string) $enc) {
4942 $part =
'=?' . $charset .
'?B?' . base64_encode($part) .
'?=';
4944 case 'quoted-printable':
4947 $qpValue = self::quoted_printable($part, 1000);
4948 if ($part != $qpValue) {
4952 $search = array(
' ',
'?');
4953 $replace = array(
'_',
'=3F');
4954 $qpValue = str_replace($search, $replace, $qpValue);
4955 $part =
'=?' . $charset .
'?Q?' . $qpValue .
'?=';
4958 if ($partWasQuoted) {
4959 $part =
'"' . $part .
'"';
4961 $line = str_replace($oldPart, $part, $line);
4964 $line = preg_replace(
'/###(.+?)###/',
'$1', $line);
4979 switch ((
string) $urlmode) {
4981 $lengthLimit = FALSE;
4989 $lengthLimit = (int)$urlmode;
4991 if ($lengthLimit === FALSE) {
4993 $messageSubstituted = $message;
4995 $messageSubstituted = preg_replace_callback(
4996 '/(http|https):\\/\\/.+(?=[\\]\\.\\?]*([\\! \'"()<>]+|$))/iU',
4997 function (array $matches) use ($lengthLimit, $index_script_url) {
5003 return $messageSubstituted;
5015 if (strlen($inUrl) > $l) {
5016 $md5 = substr(md5($inUrl), 0, 20);
5017 $count =
$GLOBALS[
'TYPO3_DB']->exec_SELECTcountRows(
'*',
'cache_md5params',
'md5hash=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($md5,
'cache_md5params'));
5019 $insertFields = array(
5025 $GLOBALS[
'TYPO3_DB']->exec_INSERTquery(
'cache_md5params', $insertFields);
5027 $inUrl = ($index_script_url ? $index_script_url : self::getIndpEnv(
'TYPO3_REQUEST_DIR') .
'index.php') .
'?RDCT=' . $md5;
5039 $dpi = (int)
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'TTFdpi'];
5041 $font_size = $font_size / $dpi * 72;
5055 if (defined(
'TYPO3_cliMode') && TYPO3_cliMode) {
5056 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLogHost'] = self::getHostname(($requestHost = FALSE)) .
':' . PATH_site;
5058 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLogHost'] = self::getIndpEnv(
'TYPO3_SITE_URL');
5061 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLog'])) {
5062 $params = array(
'initLog' => TRUE);
5064 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLog'] as $hookMethod) {
5065 self::callUserFunction($hookMethod, $params, $fakeThis);
5069 foreach (explode(
';',
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'systemLog'], 2) as $log) {
5070 list($type, $destination) = explode(
',', $log, 3);
5071 if ($type ==
'syslog') {
5072 if (TYPO3_OS ==
'WIN') {
5073 $facility = LOG_USER;
5075 $facility = constant(
'LOG_' .
strtoupper($destination));
5077 openlog(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLogHost'], LOG_ODELAY, $facility);
5081 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLogInit'] = TRUE;
5095 static public function sysLog($msg, $extKey, $severity = 0) {
5098 if ((
int)
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'systemLogLevel'] > $severity) {
5102 if (!
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLogInit']) {
5106 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLog']) && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLog'])) {
5107 $params = array(
'msg' => $msg,
'extKey' => $extKey,
'backTrace' => debug_backtrace(),
'severity' => $severity);
5109 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLog'] as $hookMethod) {
5110 self::callUserFunction($hookMethod, $params, $fakeThis);
5114 if (!
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'systemLog']) {
5117 $dateFormat =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'ddmmyy'];
5118 $timeFormat =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'hhmm'];
5120 foreach (explode(
';',
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'systemLog'], 2) as $log) {
5121 list($type, $destination, $level) = explode(
',', $log, 4);
5123 if ((
int)$level > $severity) {
5126 $msgLine =
' - ' . $extKey .
': ' . $msg;
5128 if ($type ==
'file') {
5129 $file = fopen($destination,
'a');
5131 fwrite($file, date(($dateFormat .
' ' . $timeFormat)) . $msgLine . LF);
5133 self::fixPermissions($destination);
5135 } elseif ($type ==
'mail') {
5136 list($to, $from) = explode(
'/', $destination);
5137 if (!self::validEmail($from)) {
5141 $mail = self::makeInstance(
'TYPO3\\CMS\\Core\\Mail\\MailMessage');
5142 $mail->setTo($to)->setFrom($from)->setSubject(
'Warning - error in TYPO3 installation')->setBody(
'Host: ' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLogHost'] . LF .
'Extension: ' . $extKey . LF .
'Severity: ' . $severity . LF . LF . $msg);
5144 } elseif ($type ==
'error_log') {
5145 error_log(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'systemLogHost'] . $msgLine, 0);
5146 } elseif ($type ==
'syslog') {
5147 $priority = array(LOG_INFO, LOG_NOTICE, LOG_WARNING, LOG_ERR, LOG_CRIT);
5148 syslog($priority[(
int)$severity], $msgLine);
5167 static public function devLog($msg, $extKey, $severity = 0, $dataVar = FALSE) {
5168 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'devLog'])) {
5169 $params = array(
'msg' => $msg,
'extKey' => $extKey,
'severity' => $severity,
'dataVar' => $dataVar);
5171 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_div.php'][
'devLog'] as $hookMethod) {
5172 self::callUserFunction($hookMethod, $params, $fakeThis);
5184 if (!
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'enableDeprecationLog']) {
5188 $log =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'enableDeprecationLog'];
5189 if ($log === TRUE || $log ==
'1') {
5190 $log = array(
'file');
5192 $log = self::trimExplode(
',',
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'enableDeprecationLog'], TRUE);
5194 $date = date(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'ddmmyy'] .
' ' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'hhmm'] .
': ');
5195 if (in_array(
'file', $log) !== FALSE) {
5197 if (class_exists(
'TYPO3\\CMS\\Core\\Locking\\Locker') === FALSE) {
5201 $destination = self::getDeprecationLogFileName();
5202 $file = @fopen($destination,
'a');
5204 @fwrite($file, ($date . $msg . LF));
5206 self::fixPermissions($destination);
5209 if (in_array(
'devlog', $log) !== FALSE) {
5211 self::devLog($msg,
'Core', self::SYSLOG_SEVERITY_WARNING);
5214 if (in_array(
'console', $log) !== FALSE && isset($GLOBALS[
'BE_USER']->user[
'uid'])) {
5225 return PATH_typo3conf .
'deprecation_' . self::shortMD5((PATH_site .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'encryptionKey'])) .
'.log';
5235 if (!
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'enableDeprecationLog']) {
5243 require_once
'DebugUtility.php';
5245 $trail = debug_backtrace();
5246 if ($trail[1][
'type']) {
5247 $function = new \ReflectionMethod($trail[1][
'class'], $trail[1][
'function']);
5249 $function = new \ReflectionFunction($trail[1][
'function']);
5252 if (preg_match(
'/@deprecated\\s+(.*)/', $function->getDocComment(), $match)) {
5256 $logMsg = $trail[1][
'class'] . $trail[1][
'type'] . $trail[1][
'function'];
5259 self::deprecationLog($logMsg);
5273 if (!is_array($valueList)) {
5274 $valueList = self::trimExplode(
',', $valueList, TRUE);
5276 $valListCnt = count($valueList);
5277 foreach ($arr as $key => $value) {
5278 if (!$valListCnt || in_array($key, $valueList)) {
5279 $str .= ((string) $key . trim((
': ' . self::fixed_lgd_cs(str_replace(LF,
'|', (
string) $value), $valueLength)))) .
'; ';
5294 return \TYPO3\CMS\Core\Utility\CommandUtility::imageMagickCommand($command,
$parameters, $path);
5308 foreach ($paramsArr as $k => $v) {
5309 if ($quoteActive > -1) {
5310 $paramsArr[$quoteActive] .=
' ' . $v;
5311 unset($paramsArr[$k]);
5312 if (substr($v, -1) === $paramsArr[$quoteActive][0]) {
5315 } elseif (!trim($v)) {
5317 unset($paramsArr[$k]);
5318 } elseif (preg_match(
'/^(["\'])/', $v) && substr($v, -1) !== $v[0]) {
5323 foreach ($paramsArr as $key => &$val) {
5324 $val = preg_replace(
'/(^"|"$)/',
'', $val);
5325 $val = preg_replace(
'/(^\'|\'$)/',
'', $val);
5330 return array_values($paramsArr);
5341 json_encode((
string)$value, JSON_HEX_AMP|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_TAG),
5344 '\\\\' =>
'\\u005C',
5360 while (ob_end_clean()) {
5363 header(
'Content-Encoding: None', TRUE);
5373 while ($content = ob_get_clean()) {
5374 $obContent .= $content;
5377 if (!headers_sent()) {
5378 $headersList = headers_list();
5379 foreach ($headersList as $header) {
5381 list($key, $value) = self::trimExplode(
':', $header, TRUE);
5384 header(
'Content-Encoding: None');
5403 if (is_null(static::$applicationContext)) {
5406 throw new \RuntimeException(
'Trying to override applicationContext which has already been defined!', 1376084316);
5416 return static::$applicationContext;
5424 return in_array(PHP_SAPI, self::$supportedCgiServerApis, TRUE);
static modifyHTMLColor($color, $R, $G, $B)
static idnaEncode($value)
static createDirectoryPath($fullDirectoryPath)
static imageMagickCommand($command, $parameters, $path='')
static stripSlashesOnArray(array &$theArray)
static cmpIPv6($baseIP, $list)
static getSingletonInstances()
static minifyJavaScript($script, &$error='')
static implodeAttributes(array $arr, $xhtmlSafe=FALSE, $dontOmitBlankAttribs=FALSE)
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
static uniqueList($in_list, $secondParameter=NULL)
$TYPO3_CONF_VARS['SYS']['contentTable']
static setSingletonInstance($className, \TYPO3\CMS\Core\SingletonInterface $instance)
static classHasImplementation($className)
static unlink_tempfile($uploadedTempFileName)
static substUrlsInPlainText($message, $urlmode='76', $index_script_url='')
static explodeUrl2Array($string, $multidim=FALSE)
static isAllowedAbsPath($path)
static mkdir_deep($directory, $deepDirectory='')
static addInstance($className, $instance)
static getClassName($className)
static isRunningOnCgiServerApi()
static requireFile($requireFile)
static getAllFilesAndFoldersInPath(array $fileArr, $path, $extList='', $regDirs=FALSE, $recursivityLevels=99, $excludePattern='')
static writeFile($file, $content, $changePermissions=FALSE)
static quoted_printable($string, $maxlen=76)
static cmpIPv4($baseIP, $list)
static formatForTextarea($content)
static getRandomHexString($count)
static getHash($hash, $expTime=0)
static stdAuthCode($uid_or_record, $fields='', $codeLength=8)
static xml2tree($string, $depth=999)
static png_to_gif_by_imagemagick($theFile)
static debug($var='', $header='', $group='Debug')
const SYSLOG_SEVERITY_FATAL
static devLog($msg, $extKey, $severity=0, $dataVar=FALSE)
static split_tag_attributes($tag)
static isFirstPartOfStr($str, $partStr)
static slashJS($string, $extended=FALSE, $char='\'')
static validPathStr($theFile)
static array2xml_cs(array $array, $docTag='phparray', array $options=array(), $charset='')
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
static extPath($key, $script='')
static cmpFQDN($baseHost, $list)
static csvValues(array $row, $delim=',', $quote='"')
static generateRandomBytesUrandom($bytesToGenerate)
static resolveAllSheetsInDS(array $dataStructArray)
static quoteJSvalue($value)
static arrayToLogString(array $arr, $valueList=array(), $valueLength=20)
static validEmail($email)
static getImplementationForClass($className)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
const ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL
static llXmlAutoFileName($fileRef, $language, $sameLocation=FALSE)
static writeFileToTypo3tempDir($filepath, $content)
static int_from_ver($verNumberStr)
static canBeInterpretedAsInteger($var)
static isInternalRequestType()
static getIndpEnv($getEnvName)
static modifyHTMLColorAll($color, $all)
static rmdir($path, $removeNonEmpty=FALSE)
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
static $finalClassNameCache
static clearAllActive($fileAbsPath=NULL)
static getMaxUploadFileSize($localLimit=0)
static hmac($input, $additionalSecret='')
static getRedirectUrlFromHttpHeaders($content)
static makeInstanceService($serviceType, $serviceSubType='', $excludeServiceKeys=array())
static fixPermissions($path, $recursive=FALSE)
static underscoredToLowerCamelCase($string)
static logDeprecatedFunction()
static generateRandomBytes($bytesToReturn)
static camelCaseToLowerCaseUnderscored($string)
static getMaximumPathLength()
static isAllowedHostHeaderValue($hostHeaderValue)
static rmFromList($element, $list)
static getDeprecationLogFileName()
static makeInstance($className)
static hideIfDefaultLanguage($localizationConfiguration)
static shortMD5($input, $len=10)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static verifyFilenameAgainstDenyPattern($filename)
static $allowHostHeaderValue
static remapArrayKeys(&$array, $mappingTable)
const SYSLOG_SEVERITY_ERROR
static normalizeMailAddress($address)
static copyDirectory($source, $destination)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
static removeXSS($string)
static removeSingletonInstance($className, \TYPO3\CMS\Core\SingletonInterface $instance)
static isOnCurrentHost($url)
static hideIfNotTranslated($l18n_cfg_fieldValue)
static _GETset($inputGet, $key='')
static array2xml(array $array, $NSprefix='', $level=0, $docTag='phparray', $spaceInd=0, array $options=array(), array $stackData=array())
static read_png_gif($theFile, $output_png=FALSE)
static cmpIP($baseIP, $list)
static compressIPv6($address)
static htmlspecialchars_decode($value)
static unQuoteFilenames($parameters, $unQuote=FALSE)
static resetSingletonInstances(array $newSingletonInstances)
const SYSLOG_SEVERITY_WARNING
static split_fileref($fileNameWithPath)
static naturalKeySortRecursive(&$array)
static get_tag_attributes($tag)
static deprecationLog($msg)
static stripHttpHeaders($content)
static addSlashesOnArray(array &$theArray)
static normalizeIPv6($address)
static flushDirectory($directory, $keepOriginalDirectory=FALSE, $flushOpcodeCache=FALSE)
static slashArray(array $arr, $cmd)
static resolveSheetDefInDS($dataStructArray, $sheet='sDEF')
static deHSCentities($str)
static underscoredToUpperCamelCase($string)
static linkThisScript(array $getParams=array())
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
static compat_version($verNumberStr)
static gif_compress($theFile, $type)
static compileSelectedGetVarsFromArray($varList, array $getArray, $GPvarAlt=TRUE)
static createVersionNumberedFilename($file, $forceQueryString=FALSE)
static getUrl($url, $includeHeader=0, $requestHeaders=FALSE, &$report=NULL)
static buildUrl(array $urlParts)
static getBytesFromSizeMeasurement($measurement)
static storeHash($hash, $data, $ident, $lifetime=0)
static inArray(array $in_array, $item)
static isLoaded($key, $exitOnError=FALSE)
static flushOutputBuffers()
static upload_to_tempfile($uploadedFileName)
static deactivateService($serviceType, $serviceKey)
static locationHeaderUrl($path)
static fixWindowsFilePath($theFile)
static xml2arrayProcess($string, $NSprefix='', $reportDocTag=FALSE)
static tempnam($filePrefix, $fileSuffix='')
static convertVersionNumberToInteger($versionNumber)
static removeDotsFromTS(array $ts)
static rawUrlEncodeFP($str)
static generateRandomBytesMcrypt($bytesToGenerate)
const SYSLOG_SEVERITY_INFO
static viewArray($array_in)
static $applicationContext
static getHostname($requestHost=TRUE)
static $singletonInstances
static splitCalc($string, $operators)
static isBrokenEmailEnvironment()
static convertMicrotime($microtime)
static presetApplicationContext(\TYPO3\CMS\Core\Core\ApplicationContext $applicationContext)
static implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=FALSE, $rawurlencodeParamName=FALSE)
static formatSize($sizeInBytes, $labels='')
debug($variable='', $name=' *variable *', $line=' *line *', $file=' *file *', $recursiveDepth=3, $debugLevel=E_DEBUG)
static requireOnce($requireFile)
static array_merge(array $arr1, array $arr2)
static getFilesInDir($path, $extensionList='', $prependPath=FALSE, $order='', $excludePattern='')
static array_merge_recursive_overrule(array $arr0, array $arr1, $notAddKeys=FALSE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
static freetypeDpiComp($font_size)
static fixed_lgd_cs($string, $chars, $appendString='...')
static getApplicationContext()
if(isset($ajaxID)) if(in_array( $ajaxID, $noUserAjaxIDs))
Re-apply pairs of single-quotes to the text.
static _GPmerged($parameter)
static sanitizeLocalUrl($url='')
static plainMailEncoded($email, $subject, $message, $headers='', $encoding='quoted-printable', $charset='', $dontEncodeHeader=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static removeArrayEntryByValue(array $array, $cmpValue)
static revExplode($delimiter, $string, $count=0)
static checkInstanceClassName($className, $instance)
static generateRandomBytesFallback($bytesToReturn)
static inList($list, $item)
static xml2array($string, $NSprefix='', $reportDocTag=FALSE)
static getFileAbsFileName($filename, $onlyRelative=TRUE, $relToTYPO3_mainDir=FALSE)
static linkThisUrl($url, array $getParams=array())
static removePrefixPathFromList(array $fileArr, $prefixToRemove)
static findService($serviceType, $serviceSubType='', $excludeServiceKeys=array())
const ENV_TRUSTED_HOSTS_PATTERN_SERVER_NAME
static stripPathSitePrefix($path)
static xmlRecompileFromStructValArray(array $vals)
static encodeHeader($line, $enc='quoted-printable', $charset='utf-8')
static arrayDiffAssocRecursive(array $array1, array $array2)
static exec($command, &$output=NULL, &$returnValue=0)
static resolveBackPath($pathStr)
static $nonSingletonInstances
static rawUrlEncodeJS($str)
static xmlGetHeaderAttribs($xmlData)
static generateRandomBytesOpenSsl($bytesToGenerate)
static makeRedirectUrl($inUrl, $l=0, $index_script_url='')
static upload_copy_move($source, $destination)
static wrapJS($string, $linebreak=TRUE)
static clientInfo($useragent='')
static $supportedCgiServerApis
static keepItemsInArray(array $array, $keepItems, $getValueFunc=NULL)
static instantiateClass($className, $arguments)
const SYSLOG_SEVERITY_NOTICE
static cleanOutputBuffers()